Ethereum
准备好在生产环境中调用了吗?
免费套餐涵盖个人项目。按量付费,无需绑卡即可扩展。
Ethereum
免费套餐涵盖个人项目。按量付费,无需绑卡即可扩展。
eth_getTransactionCount returns how many transactions an address has sent on Ethereum mainnet (chain ID 1, the network whose gas is paid in ETH) up to a given block — which is exactly the account's nonce. Every transaction from an account carries a nonce that must increase by one each time, and Ethereum uses it to order an account's transactions and to block replays. So the count this returns is also the next nonce you'll sign with. The block argument matters: at latest you get the nonce from confirmed transactions, while pending folds in what's already sitting in the mempool. Send the request to https://ethereum.therpc.io/YOUR_API_KEY.
pending, use that value, and your transaction slots in right after whatever's already queued.pending sits above latest, something you sent hasn't been mined and is holding up everything behind it.| # | 名称 | 类型 | 必填 | 描述 |
|---|---|---|---|---|
| 1 | address | string (hex) | 是 | The account whose nonce to query. |
| 2 | blockTag | string | 否 | Use "pending" to include mempool transactions when chaining multiple sends.默认值: latest |
| 类型 | 描述 |
|---|---|
| string (hex) | Hex-encoded nonce (number of confirmed transactions sent from the address at that block). |
Try it live in the Ethereum playground.
| 错误码 | 错误信息 | 原因 |
|---|---|---|
-32602 | Invalid params | Address is malformed or block tag is unrecognised. |
-32000 | Missing trie node | Historical block pruned on a non-archive node. |
pending, not latest. latest only counts confirmed transactions, so it hands the same nonce to every send in the burst and they collide.CREATE/CREATE2 deployments it makes, not ordinary calls into it. So a contract that never deploys another contract keeps a nonce of zero no matter how often it's invoked.参数
0x-prefixed 20-byte address
hex block number or "latest"/"earliest"/"pending"/"safe"/"finalized"