跳转到内容

eth_getTransactionCount

返回某地址已发送的交易数量。

  1. DATA(20 字节)— 地址。
  2. QUANTITY|TAG — 区块号,或 "latest""earliest""pending"

QUANTITY — 该地址已发送交易数。

Terminal window
curl -X POST https://eth-mainnet.blockreq.com/v1/rpc/public \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_getTransactionCount",
"params": ["0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045", "latest"],
"id": 1
}'
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x29d"
}
import { JsonRpcProvider } from "ethers";
const provider = new JsonRpcProvider("https://eth-mainnet.blockreq.com/v1/rpc/YOUR_API_KEY");
const nonce = await provider.getTransactionCount("0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045");
console.log("Nonce:", nonce);
from web3 import Web3
w3 = Web3(Web3.HTTPProvider("https://eth-mainnet.blockreq.com/v1/rpc/YOUR_API_KEY"))
nonce = w3.eth.get_transaction_count("0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045")
print(f"Nonce: {nonce}")
MethodCost
eth_getTransactionCount10 RU