getBalance With A Block Number
You can pass in the block number as part of the parameter.
Here is Kraken's address: 0x2910543af39aba0cd09dbb2d50200b3e800a63d2.
Let's check what the latest block number is:
> eth.blockNumber
1456129
Let's get the latest balance for Kraken:
> eth.getBalance("0x2910543af39aba0cd09dbb2d50200b3e800a63d2", "latest")
4.46304933021672757555818e+23
Let's get the balance at block 1456109:
> eth.getBalance("0x2910543af39aba0cd09dbb2d50200b3e800a63d2", 1456109)
4.46511558309272757555818e+23
Let's get the balance at block 145110:
> eth.getBalance("0x2910543af39aba0cd09dbb2d50200b3e800a63d2", 1456110)
4.46304933021672757555818e+23
Confirmations
The number of confirmations is just the current block number minus the block number you specified for the getBalance(...)
call.
In this example, the balance at block 1456109 had 10 confirmations (= 1456129 - 1456109).
Pending
The balance with the "pending" parameter will include any transactions that are pending, i.e., broadcasted onto the peer-to-peer network, but not included into any mined blocks yet.
Latest
The balance with the "latest" parameter will be the balance as of the latest block, which is the block number reported by eth.blockNumber
.
Best Answer
When you send a transaction, you will receive back a transaction hash.
Use the command getTransactionByHash({transaction hash}) to retrieve the transaction details. Your blockNumber should be non-null if the transaction has been mined and included into a block.
The call is documented in https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_gettransactionbyhash with the following example:
Then call eth_blockNumber (https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_blocknumber) to get the current block height. Your number of confirmations is the eth_blockNumber result minus the eth_getTransaction blockNumber result.