How can I get the bitcoin balance of a public key in C#?
E.g. for this public key: 1FqLoEpbQpMxow5bqEPpFbPVnBEbFcsg3J
How can I get its balance in C#?
Bitcoin Stack Exchange is a question and answer site for Bitcoin users, developers, and enthusiasts. It only takes a minute to sign up.
Sign up to join this communityHow can I get the bitcoin balance of a public key in C#?
E.g. for this public key: 1FqLoEpbQpMxow5bqEPpFbPVnBEbFcsg3J
How can I get its balance in C#?
If you are ok with a third party service check out the Blockchain API.
They have a C# library and it's fairly easy to use.
If you need only the balance of an address you can use the code below as described on their BlockExplorer page:
// calculate the balanace of an address by fetching a list of all its unspent outputs
var outs = blockExplorer.GetUnspentOutputs("1EjmmDULiZT2GCbJSeXRbjbJVvAPYkSDBw");
long totalUnspentValue = outs.Sum(x => x.Value);
Take a look at Blockparser: https://github.com/znort987/blockparser**
It will let you parse blockchain data to verify balances (among other things)
using Info.Blockchain.API.BlockExplorer;
using Info.Blockchain.API.Models;
internal decimal CheckBalance(string[] base58Addresses) {
BlockExplorer be = new BlockExplorer();
IEnumerable<UnspentOutput> outs = be.GetUnspentOutputsAsync(base58Addresses).Result;
decimal totalUnspentValue = outs.Sum(x => x.Value.GetBtc());
return totalUnspentValue;
}