How to Get BTC and ETH Balances, UTXO List, and Ethereum Nonce via Node RPC

·

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:

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

  1. Address: The Ethereum address to check (e.g., 0xc94770007dda54cF92009BFF0dE90c06F603a09f)
  2. 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.com

Example 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:

  1. Scan all transactions involving that address
  2. Identify which outputs remain unspent (UTXOs)
  3. 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:

Example: Get BTC Balance and UTXOs via Insight API

Get Balance

GET https://blockchain.info/rawaddr/1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa

Response 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=1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa

Returns a JSON array of unspent outputs with:

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:

  1. Prevent replay attacks
  2. 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

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

  1. Address: Wallet address to query
  2. 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.com

Example 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

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.