You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

38 lines
1.4 KiB

import { ethers } from 'ethers';
// 使用 ethers.js 的 Provider
const rpcUrl = 'https://testnet-rpc.monad.xyz';
const provider = new ethers.JsonRpcProvider(rpcUrl);
const addresses = [
'0xe50B77Cd771243b8Ae1d6ce33b4E13ECC5Fa28a6',
'0x9ea2ECAD4090E32916e03b77d7C75CbF6C8E0A55',
'0xE8A4b0C04300154DC9B1D0e565Ba70F996614690',
'0x1b623c5d70c93b437d93c305bf2cfa389095f636',
'0x06D25c3e0E1F753ac0486a3f8aaD7259149656cB',
'0x15cFEE34Ca4541CAc9a1c4B6F6aB47A65877E240',
'0x7aBF0dA8Ac07B6dE7206e467988455E1AD0b60B5',
'0xF736f45d4663a8D8DfF7EFA55b1Cf6Fe38D026c8',
'0x83173eECf3a6d9ABB79682568e16c2eAd361620e',
'0xa401b85B4849Fc7610Bd180cc937859C78528F47'
];
async function getNonces() {
try {
let countNum = 1;
for (const address of addresses) {
// 获取最新的 nonce
const nonceLatest = await provider.getTransactionCount(address, 'latest');
const noncePending = await provider.getTransactionCount(address, 'pending');
const countNumStr = String(countNum).padStart(2, '0');
console.log(`${countNumStr} address: ${address}`);
console.log(`pending nonce: ${noncePending} ; latest nonce: ${nonceLatest}`);
console.log('-----------------------------');
countNum++;
}
} catch (error) {
console.error('获取 nonce 时发生错误:', error.message);
}
}
getNonces();