Last active
August 10, 2023 16:16
-
-
Save samsonajulor/3dd9dfe864295f937ce13a407ab3f458 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ethers } from 'ethers'; | |
(async () => { | |
const address = '0x67147840C8eca35C819C7523861E6A1D75D93200'; | |
try { | |
// get transaction count | |
const mainnetTransactionCount = await ethers.getDefaultProvider('mainnet').getTransactionCount(address); | |
const goerliTransactionCount = await ethers.getDefaultProvider('goerli').getTransactionCount(address); | |
const sepoliaTransactionCount = await ethers.getDefaultProvider('sepolia').getTransactionCount(address); | |
console.log(`Mainnet Transaction Count: ${mainnetTransactionCount}`); | |
console.log(`Goerli Transaction Count: ${goerliTransactionCount}`); | |
console.log(`sepolia Transaction Count: ${sepoliaTransactionCount}`); | |
// get balance | |
const mainnetBalance = await ethers.getDefaultProvider('mainnet').getBalance(address); | |
const goerliBalance = await ethers.getDefaultProvider('goerli').getBalance(address); | |
const sepoliaBalance = await ethers.getDefaultProvider('sepolia').getBalance(address); | |
console.log(`Mainnet Balance: ${mainnetBalance}`); | |
console.log(`Goerli Balance: ${goerliBalance}`); | |
console.log(`sepolia Balance: ${sepoliaBalance}`); | |
// get the current block number | |
const mainnetBlockNumber = await ethers.getDefaultProvider('mainnet').getBlockNumber(); | |
const goerliBlockNumber = await ethers.getDefaultProvider('goerli').getBlockNumber(); | |
const sepoliaBlockNumber = await ethers.getDefaultProvider('sepolia').getBlockNumber(); | |
console.log(`Mainnet Block Number: ${mainnetBlockNumber}`); | |
console.log(`Goerli Block Number: ${goerliBlockNumber}`); | |
console.log(`sepolia Block Number: ${sepoliaBlockNumber}`); | |
// return as an object | |
return { | |
mainnetTransactionCount, | |
goerliTransactionCount, | |
sepoliaTransactionCount, | |
mainnetBalance, | |
goerliBalance, | |
sepoliaBalance, | |
mainnetBlockNumber, | |
goerliBlockNumber, | |
sepoliaBlockNumber, | |
} | |
} catch (error) { | |
console.error('Error:', error); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment