eth_getTransactionCount
Returns the number of transactions sent from an address on XDC Network (the nonce).
Use Cases#
- Transaction building - Get correct nonce for new transactions
- Account analysis - Count total outgoing transactions
- Nonce management - Handle pending transaction queues
- Wallet operations - Prepare transactions for tokenized trade finance (Letters of Credit, Bills of Lading), cross-border payments, and real-world asset tokenization
Parameters#
| Parameter | Type | Required | Description |
|---|---|---|---|
address | DATA | Yes | 20-byte address |
blockParameter | QUANTITY|TAG | Yes | Block number or tag (pending for next nonce) |
Request#
{
"jsonrpc": "2.0",
"method": "eth_getTransactionCount",
"params": [
"0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
"latest"
],
"id": 1
}
Code Examples#
- cURL
- JavaScript
- Python
curl -X POST https://api-xdc-mainnet.n.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_getTransactionCount",
"params": [
"0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
"latest"
],
"id": 1
}'
import { JsonRpcProvider } from 'ethers';
const provider = new JsonRpcProvider('https://api-xdc-mainnet.n.dwellir.com/YOUR_API_KEY');
const address = '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb';
const nonce = await provider.getTransactionCount(address);
console.log('Nonce:', nonce);
// Get pending nonce for new transaction
const pendingNonce = await provider.getTransactionCount(address, 'pending');
console.log('Next nonce:', pendingNonce);
from web3 import Web3
w3 = Web3(Web3.HTTPProvider('https://api-xdc-mainnet.n.dwellir.com/YOUR_API_KEY'))
address = '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb'
nonce = w3.eth.get_transaction_count(address)
print(f'Nonce: {nonce}')
# Get pending nonce
pending_nonce = w3.eth.get_transaction_count(address, 'pending')
print(f'Next nonce: {pending_nonce}')
Related Methods#
eth_getBalance- Get account balanceeth_sendRawTransaction- Send transaction