Blockchain development often requires interacting directly with cryptocurrency nodes to retrieve critical on-chain data such as wallet balances, unspent transaction outputs (UTXOs), and transaction counters (nonces). Whether you're building a wallet, exchange, or decentralized application (dApp), understanding how to properly query this information from Bitcoin (BTC) and Ethereum (ETH) nodes is essential.
In this guide, we’ll walk through the technical steps for retrieving:
- Ethereum (ETH) balance using the
eth_getBalanceRPC method - Bitcoin (BTC) balance and UTXO list via blockchain explorer APIs
- Ethereum transaction nonce using
eth_getTransactionCount
We'll also explain why certain approaches are more efficient than others and how to avoid common pitfalls in production environments.
Retrieving Ethereum (ETH) Balance Using RPC
Getting the balance of an Ethereum address is straightforward thanks to the built-in JSON-RPC interface provided by Ethereum nodes like Geth or Infura.
The key method used is:
👉 eth_getBalance
This method returns the account balance in wei (the smallest denomination of ether), which can then be converted into ETH by dividing by 10¹⁸.
Parameters
- Address: The Ethereum address to check (e.g.,
0xc94770007dda54cF92009BFF0dE90c06F603a09f) Block state: Specify which block state to query:
"latest"– confirmed transactions only"earliest"– balance at genesis block"pending"– includes unconfirmed, pending transactions
Example Request
curl -X POST --data '{
"jsonrpc":"2.0",
"method":"eth_getBalance",
"params":["0xc94770007dda54cF92009BFF0dE90c06F603a09f", "latest"],
"id":1
}' https://your-ethereum-node.comExample Response
{
"id": 1,
"jsonrpc": "2.0",
"result": "0x0234c8a3397aab58"
}The result is in hexadecimal format — convert it to decimal to get the value in wei. In this case, 0x0234c8a3397aab58 equals approximately 158,972,490,234,375,000 wei, or about 0.15897 ETH.👉 Learn how to connect to real-time blockchain data securely and efficiently.
Why You Can't Easily Get BTC Balance via Standard RPC
Unlike Ethereum, Bitcoin does not store account balances directly. Instead, it uses a UTXO (Unspent Transaction Output) model, where each transaction consumes previous outputs and creates new ones.
To calculate a Bitcoin address’s balance, you must:
- Scan all transactions involving that address
- Identify which outputs remain unspent (UTXOs)
- Sum their values
While Bitcoin Core provides an RPC command called listunspent, it only works if the address has been imported into the node using importaddress, followed by a full blockchain rescan — a process that can take over 20 minutes or even hours.
This makes native RPC impractical for dynamic applications requiring fast balance lookups.
Best Way to Get BTC Balance and UTXO List: Use a Blockchain Explorer API
For real-time access to Bitcoin balances and UTXO lists, developers typically rely on third-party blockchain explorer APIs.
One widely used open-source solution is Insight API by BitPay:
- GitHub: https://github.com/bitpay/insight-api
Offers RESTful endpoints for:
- Address balance
- UTXO list
- Transaction history
- Broadcast raw transactions
Example: Get BTC Balance and UTXOs via Insight API
Get Balance
GET https://blockchain.info/rawaddr/1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNaResponse includes:
{
"address": "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa",
"final_balance": 12345678,
"n_tx": 45,
"total_received": 87654321
}final_balance is in satoshis (divide by 10⁸ to get BTC)Get UTXO List
Use:
GET https://blockchain.info/unspent?active=1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNaReturns a JSON array of unspent outputs with:
tx_hashtx_posvalue(in satoshis)- Confirmations
This approach avoids running a full rescan and enables instant balance verification — ideal for wallets, payment processors, and exchanges.
Understanding and Retrieving Ethereum Nonce
In Ethereum, a nonce is a crucial field in every transaction. It serves two main purposes:
- Prevent replay attacks
- Ensure transaction order from a given address
Each externally owned account starts with a nonce of 0. Every time a transaction is sent, the nonce increments by one. Transactions are processed strictly in nonce order.
Common Nonce Errors
- Nonce too low: Transaction rejected (already used)
- Nonce too high: Transaction stuck in mempool until missing nonces are filled
To avoid failures, always fetch the current nonce before broadcasting.
How to Get Ethereum Nonce via RPC
Use the JSON-RPC method:
👉 eth_getTransactionCount
Parameters
- Address: Wallet address to query
State tag:
"latest"– number of confirmed transactions"pending"– includes pending transactions (recommended for sending new TXs)
Using "pending" ensures your app accounts for transactions that are queued but not yet mined.
Example Request
curl -X POST --data '{
"jsonrpc":"2.0",
"method":"eth_getTransactionCount",
"params":["0xc94770007dda54cF92009BFF0dE90c06F603a09f", "pending"],
"id":1
}' https://your-ethereum-node.comExample Response
{
"id": 1,
"jsonrpc": "2.0",
"result": "0x1"
}This means the account has sent 1 transaction so far (nonce = 1). The next transaction should use nonce = 1.👉 Access reliable node services and tools to streamline your blockchain development workflow.
Frequently Asked Questions (FAQ)
Q: Can I get BTC balance directly from a Bitcoin node?
A: Technically yes, but only after importing the address and rescanning the blockchain using importaddress and rescanblockchain. This is slow and resource-heavy, making it unsuitable for real-time applications.
Q: What’s the difference between UTXO and account-based models?
A: Bitcoin uses UTXO — each transaction spends specific outputs. Ethereum uses an account model — like a bank account, each address has a balance and nonce tracked globally.
Q: Why should I use “pending” instead of “latest” when getting nonce?
A: Because “latest” only counts confirmed transactions. If you have pending ones, using “latest” will return a lower nonce, leading to duplicate transactions or rejections.
Q: Are there alternatives to Insight API for BTC data?
A: Yes. Popular options include BlockCypher, Blockchain.com API, and custom-indexed databases using tools like ElectrumX or NBXplorer. Some offer higher rate limits or enhanced security features.
Q: How do I convert wei to ETH?
A: Divide the wei amount by 10¹⁸. For example: 1,000,000,000,000,000,000 wei = 1 ETH
Many web3 libraries (like Web3.js or Ethers.js) provide built-in utilities like ethers.utils.formatEther().
Q: Is it safe to expose my node’s RPC endpoint publicly?
A: No. Exposing RPC ports without authentication can lead to data leaks or denial-of-service attacks. Always secure your node behind firewalls, use API keys, or route requests through proxy layers.
Core Keywords for SEO
- Ethereum balance check
- Bitcoin UTXO list
- Get ETH nonce
- Blockchain node RPC
- eth_getBalance
- eth_getTransactionCount
- BTC balance API
- Inspect API Bitcoin
These terms reflect common search intents among blockchain developers looking for practical implementation guidance.
By leveraging proper RPC methods and external APIs, you can efficiently retrieve critical blockchain data needed for dApps, wallets, and trading platforms. Always choose scalable solutions — avoid full rescans for BTC and use "pending" state for Ethereum nonces to ensure reliability.
Whether you're verifying user deposits or constructing raw transactions, mastering these fundamentals is key to robust blockchain integration.
👉 Explore developer tools and secure infrastructure to power your next blockchain project.