POST
/
evm
eth_getTransactionCount
curl --request POST \
  --url https://hyperliquid-mainnet.core.chainstack.com/4f8d8f4040bdacd1577bff8058438274/evm \
  --header 'Content-Type: application/json' \
  --data '{
  "jsonrpc": "2.0",
  "method": "eth_getTransactionCount",
  "params": [
    "0xFC1286EeddF81d6955eDAd5C8D99B8Aa32F3D2AA",
    "latest"
  ],
  "id": 1
}'
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "0x1a"
}
Returns the number of transactions sent from an address (the nonce). This is essential for creating new transactions with the correct nonce value.
Get your own node endpoint todayStart for free and get your app to production levels immediately. No credit card required.You can sign up with your GitHub, X, Google, or Microsoft account.

Parameters

  • address (string, required) — The 20-byte account address
  • block (string, required) — Block identifier: "latest", "earliest", "pending", or block number in hex

Returns

Returns the transaction count (nonce) as a hexadecimal string.
Use "pending" to include pending transactions for accurate nonce management when creating new transactions.

JavaScript example

const getTransactionCount = async (address, block = 'latest') => {
  const response = await fetch('https://hyperliquid-mainnet.core.chainstack.com/YOUR_API_KEY/evm', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      jsonrpc: '2.0',
      method: 'eth_getTransactionCount',
      params: [address, block],
      id: 1
    })
  });
  
  const data = await response.json();
  return data.result;
};

// Get current nonce for new transaction
const getCurrentNonce = async (address) => {
  const nonce = await getTransactionCount(address, 'pending');
  return parseInt(nonce, 16);
};

// Usage
const address = '0xFC1286EeddF81d6955eDAd5C8D99B8Aa32F3D2AA';
const nonce = await getCurrentNonce(address);
console.log('Next transaction nonce:', nonce);

Transaction creation with nonce

const createTransaction = async (from, to, value) => {
  const nonce = await getCurrentNonce(from);
  
  return {
    from: from,
    to: to,
    value: `0x${value.toString(16)}`,
    nonce: `0x${nonce.toString(16)}`,
    gas: '0x5208',
    gasPrice: '0x3b9aca00'
  };
};

// Create multiple transactions with sequential nonces
const createBatchTransactions = async (from, transactions) => {
  let nonce = await getCurrentNonce(from);
  
  return transactions.map(tx => ({
    ...tx,
    from: from,
    nonce: `0x${(nonce++).toString(16)}`
  }));
};

Account activity tracking

const getAccountActivity = async (address) => {
  const confirmedNonce = await getTransactionCount(address, 'latest');
  const pendingNonce = await getTransactionCount(address, 'pending');
  
  const confirmed = parseInt(confirmedNonce, 16);
  const pending = parseInt(pendingNonce, 16);
  
  return {
    confirmedTransactions: confirmed,
    pendingTransactions: pending - confirmed,
    nextNonce: pending,
    totalActivity: pending
  };
};

// Usage
const activity = await getAccountActivity('0xFC1286EeddF81d6955eDAd5C8D99B8Aa32F3D2AA');
console.log('Account activity:', activity);

Use cases

  • Transaction creation — Get the correct nonce for new transactions
  • Wallet applications — Manage transaction ordering and nonce assignment
  • Account monitoring — Track account activity and transaction frequency
  • Batch operations — Create multiple transactions with sequential nonces
  • Transaction replacement — Replace stuck transactions using the same nonce
  • Smart contract deployment — Calculate contract addresses using deployer nonce

Body

application/json

Response

200 - application/json

Successful response with the transaction count

The response is of type object.