Guides3 min read

Understanding gas, fees & nonce: the transaction-meta endpoint

One GET call returns gas, fees, chainId and nonce — everything you need to build and sign a transaction.

cryptoapi team
Guides
On this page

Before you can broadcast a transaction, you need a fistful of numbers: the current fees, how much gas the operation will burn, the chain you're on, and where this transaction sits in your account's ordering. Getting any one of them wrong means a rejected or stuck transaction. CryptoAPI's transaction-meta endpoint hands you all of them in a single call.

One call, everything you need to build a tx

bash
curl "https://api.cryptoapi.so/api/blockchain/transaction-meta?network=ethereum&address=0xYourAddress" \
  -H "key: YOUR_API_KEY"

This is a GET request, and like every /api/* endpoint it requires authentication. The network parameter accepts ethereum, bnb, or tron. The address is optional, but you'll almost always pass it — that's what makes the nonce and balance fields meaningful for your sender.

A realistic response:

json
{
  "success": true,
  "data": {
    "feeData": {
      "maxFeePerGas": "32000000000",
      "maxPriorityFeePerGas": "1500000000",
      "gasPrice": "30000000000"
    },
    "gasLimit": {
      "transfer": "21000",
      "erc20Transfer": "65000",
      "contractCall": "120000"
    },
    "chainId": "1",
    "nonce": 42,
    "balance": "1840000000000000000"
  }
}

What each field is for

  • **feeData** — the price side of the equation. On EIP-1559 chains (Ethereum, BNB) you build with maxFeePerGas (the ceiling you'll pay per unit of gas) and maxPriorityFeePerGas (the tip to the validator). gasPrice is the legacy single-value field, handy for non-1559 transactions or as a fallback. Values are returned in wei as strings, so you never lose precision.
  • **gasLimit** — the quantity side. A plain native transfer is transfer (21000 on EVM chains), an ERC-20/BEP-20 token move is erc20Transfer, and anything touching contract logic is contractCall. Pick the one that matches what you're sending.
  • **chainId** — replay protection. Signing with the right chain ID (1 for Ethereum mainnet, 56 for BNB Smart Chain) ensures a transaction valid on one network can't be replayed on another.
  • **nonce** — ordering. Every account has a strictly incrementing counter; this is the next value to use. Skip it or reuse it and the network drops or stalls your transaction.
  • **balance** — the sender's native balance in the smallest unit (wei for ETH/BNB, sun for TRX). Use it to sanity-check that value plus fees won't overdraw the account before you sign.

How it feeds the send flow

CryptoAPI is non-custodial: it never holds or sees your private key, and it does not sign for you. The canonical flow is three steps:

  1. Call transaction-meta to fetch fees, gas, chainId and nonce.
  2. Build and sign the transaction client-side using those values.
  3. Broadcast the already-signed raw transaction with POST /api/wallet/send:
bash
curl -X POST "https://api.cryptoapi.so/api/wallet/send" \
  -H "key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"rawTx": "0x02f86b0182...", "network": "ethereum"}'
json
{
  "success": true,
  "data": {
    "txid": "0x9f3c...e21a"
  }
}

Because the meta values come from the live chain, fetch them fresh right before signing — fees and nonces move fast.

Get started

Every /api/* call needs an API key (pass it as a key header) or an Authorization: Bearer <JWT>. Grab a key from your dashboard and explore the full reference at https://api.cryptoapi.so/api/doc. The payload is chain-specific. Bitcoin includes fee rates and, for an address, UTXOs.

Read it, then ship it

Copy the code above and run it today.

Every snippet in this guide works on the free plan. Grab a key and make your first call in a minute.