curl --request POST \
--url https://nd-363-550-219.p2pify.com/942aad90bb6a082676497030b81e40ba \
--header 'Content-Type: application/json' \
--data '
{
"id": 1,
"jsonrpc": "2.0",
"method": "eth_getTransactionCount",
"params": [
"0x7BF729D443da412C001862a577fdC5B6EB6a4127",
"latest"
]
}
'{
"jsonrpc": "<string>",
"id": 123,
"result": {}
}curl --request POST \
--url https://nd-363-550-219.p2pify.com/942aad90bb6a082676497030b81e40ba \
--header 'Content-Type: application/json' \
--data '
{
"id": 1,
"jsonrpc": "2.0",
"method": "eth_getTransactionCount",
"params": [
"0x7BF729D443da412C001862a577fdC5B6EB6a4127",
"latest"
]
}
'{
"jsonrpc": "<string>",
"id": 123,
"result": {}
}nonce; it is an important piece of information, especially to ensure that a transaction is not sent twice.
address— the address to retrieve the transaction count.
quantity or tag — the integer of a block encoded as hexadecimal or the string with:
latest — the most recent block in the blockchain and the current state of the blockchain at the most recent block. A chain reorganization is to be expected.safe — the block that received justification from the beacon chain. Although this block could be involved in a chain reorganization, it would necessitate either a coordinated attack by the majority of validators or an instance of severe propagation latency.finalized — the block accepted as canonical by more than 2/3 of the validators. A chain reorganization is extremely unlikely, and it would require at least 1/3 of the staked ETH to be burned.earliest — the earliest available or genesis blockpending — the pending state and transactions block. The current state of transactions that have been broadcast to the network but have not yet been included in a block.quantity — an integer value identifying the number of transactions sent from an address at the specified block.eth_getTransactionCount code examplesconst { Web3 } = require("web3");
const NODE_URL = "CHAINSTACK_NODE_URL";
const web3 = new Web3(NODE_URL);
async function getTransactionsCount(address, blockId) {
const count = await web3.eth.getTransactionCount(address, blockId)
console.log(count);
}
getTransactionsCount("0x67063E37BF7192745490D7d75c9ffdECC2846100", 'latest')
eth_getTransactionCountis to create the transaction object built in a script designed to send a transaction. The nonce field is required, and it is retrieved using the eth_getTransactionCount method.Was this page helpful?