How to Get BTC and ETH Balances, BTC UTXO List, and ETH Nonce in Blockchain Development

·

Blockchain development requires a solid understanding of how to interact with different networks at the protocol level. Whether you're building a wallet, exchange, or decentralized application (dApp), retrieving essential data such as balances, UTXO lists, and transaction counts (nonce) is fundamental. This guide walks you through the technical details of fetching Bitcoin (BTC) and Ethereum (ETH) balances, obtaining the BTC UTXO list, and checking the ETH nonce—all critical operations in blockchain programming.

We’ll cover each process with clarity, using proper Markdown formatting for readability and SEO optimization, ensuring developers get accurate, actionable insights.


Getting Ethereum (ETH) Balance via RPC

Retrieving an Ethereum account's balance is straightforward thanks to Ethereum’s JSON-RPC interface. The key method used is eth_getBalance.

This RPC call returns the account balance in wei, the smallest denomination of ether (1 ETH = 10¹⁸ wei). You can convert this value easily on the client side.

Parameters

The eth_getBalance method accepts two parameters:

  1. Address: The Ethereum address to query (e.g., 0xc94770007dda54cF92009BFF0dE90c06F603a09f)
  2. Block State: Specifies which state to query:

    • "latest" – Confirmed balance after the most recent block
    • "earliest" – Balance at the genesis block
    • "pending" – Includes pending transactions not yet confirmed (useful for real-time apps)

👉 Learn how blockchain APIs power real-time balance tracking

Example Request & Response

# Request
curl -X POST --data '{
  "jsonrpc":"2.0",
  "method":"eth_getBalance",
  "params":["0xc94770007dda54cF92009BFF0dE90c06F603a09f", "latest"],
  "id":1
}' https://mainnet.infura.io/v3/YOUR_PROJECT_ID
// Result
{
  "id": 1,
  "jsonrpc": "2.0",
  "result": "0x0234c8a3397aab58" // Equals ~158,972,490,234,375,000 wei (~0.158 ETH)
}
💡 Tip: Use tools like web3.js or ethers.js to simplify these calls in your application.

Fetching Bitcoin (BTC) Balance and UTXO List

Unlike Ethereum, Bitcoin does not store account balances directly. Instead, it uses a UTXO (Unspent Transaction Output) model, making balance calculation more complex.

You cannot simply query a node with a Bitcoin address and instantly get its balance unless the node has indexed that address’s transaction history—a process known as address indexing.

Why Standard RPC Isn’t Enough

Bitcoin Core’s native RPC (getbalance) only tracks balances for addresses in the local wallet. To monitor arbitrary addresses, you’d need to import them using importaddress, followed by a full blockchain rescan—which can take 20+ minutes or longer.

This delay makes native RPC impractical for dynamic applications like wallets or explorers.

Solution: Use a Blockchain Explorer API

To efficiently retrieve BTC balances and UTXO lists, developers typically deploy or use a blockchain indexing service like Insight API.

While Insight by BitPay is now deprecated, modern alternatives include:

These services provide clean RESTful endpoints such as:

Example: Get UTXO List (via Mempool API)

curl https://mempool.space/api/address/tb1q.../utxo

Returns:

[
  {
    "txid": "a1b2c3...",
    "vout": 1,
    "status": {
      "confirmed": true,
      "block_height": 780000,
      "block_hash": "000000...",
      "block_time": 1678886542
    },
    "value": 50000
  }
]

Each object represents an unspent output that can be used as input in a new transaction.

👉 Discover how UTXO data powers secure wallet transactions


Understanding and Retrieving ETH Nonce

In Ethereum, the term nonce has a specific meaning distinct from its use in cryptography elsewhere.

What Is a Nonce?

An account nonce is a counter that tracks the number of transactions sent from an externally owned account (EOA). It ensures:

For contract accounts, the nonce tracks the number of contracts created by that account.

Nonce Rules You Must Know

ScenarioOutcome
Sent transaction with too low nonceRejected immediately
Sent transaction with too high nonceStuck in mempool until gaps are filled
Gaps filled in orderRemaining transactions proceed normally
Example: If your current nonce is 5, but you send a transaction with nonce 7, it will wait until nonces 5 and 6 are used.

How to Get the Current Nonce

Use the JSON-RPC method: eth_getTransactionCount

Parameters

  1. Address: The sender’s Ethereum address
  2. State Override:

    • "latest" – Count confirmed transactions only
    • "pending" – Includes pending transactions (recommended for live apps)

Example Request

curl -X POST --data '{
  "jsonrpc":"2.0",
  "method":"eth_getTransactionCount",
  "params":["0xc94770007dda54cF92009BFF0dE90c06F603a09f", "pending"],
  "id":1
}' https://mainnet.infura.io/v3/YOUR_PROJECT_ID

Response

{
  "id": 1,
  "jsonrpc": "2.0",
  "result": "0x1" // Hexadecimal for 1 — one transaction sent so far
}

Always use "pending" when preparing to send a new transaction to avoid collisions.


Frequently Asked Questions (FAQ)

Q1: Can I get BTC balance using Bitcoin Core RPC without importing the address?

No. Without importing the address into your node via importaddress and rescanning, Bitcoin Core won't track its UTXOs. This makes real-time queries impractical for third-party addresses.

Q2: What is the difference between ETH nonce in “latest” vs “pending” state?

Q3: How do I calculate BTC balance from UTXO list?

Sum all value fields (in satoshis) from the UTXO array, then convert to BTC:

const balanceBTC = utxos.reduce((sum, utxo) => sum + utxo.value, 0) / 100_000_000;

Q4: Why do I need the UTXO list to send Bitcoin?

Because every Bitcoin transaction must reference previous outputs as inputs. Without knowing your available UTXOs, you can't construct a valid transaction.

Q5: Is there a rate limit when using public blockchain APIs?

Yes. Public endpoints like mempool.space or Infura impose rate limits. For production apps, consider running your own node or using a premium API tier.

Q6: Can two transactions with the same nonce be mined?

No. Only one transaction per nonce per account can be confirmed. If multiple are broadcast, only the first one processed survives; others are dropped.


Core Keywords for SEO

These keywords have been naturally integrated throughout the content to enhance search visibility while maintaining technical accuracy and readability.


By mastering these foundational blockchain queries—checking balances, managing UTXOs, and handling nonces—you lay the groundwork for robust dApps, wallets, and trading platforms. Whether working with Ethereum’s account-based model or Bitcoin’s UTXO system, understanding these mechanisms is essential.

👉 Access advanced blockchain tools and APIs to streamline development