24 lines
822 B
TypeScript
24 lines
822 B
TypeScript
|
|
import { createPublicClient, http, formatEther } from 'viem'
|
|||
|
|
import { arbitrumSepolia } from 'viem/chains'
|
|||
|
|
|
|||
|
|
const client = createPublicClient({
|
|||
|
|
chain: arbitrumSepolia,
|
|||
|
|
transport: http('https://sepolia-rollup.arbitrum.io/rpc'),
|
|||
|
|
})
|
|||
|
|
|
|||
|
|
async function main() {
|
|||
|
|
const balance = await client.getBalance({ address: '0xa013422A5918CD099C63c8CC35283EACa99a705d' })
|
|||
|
|
console.log('主账户 ETH 余额:', formatEther(balance), 'ETH')
|
|||
|
|
|
|||
|
|
// 检查是否足够 (10 个账户 × 0.01 ETH = 0.1 ETH)
|
|||
|
|
const needed = 0.1
|
|||
|
|
if (parseFloat(formatEther(balance)) < needed) {
|
|||
|
|
console.log(`\n⚠️ ETH 不足! 需要至少 ${needed} ETH 来分发 gas 费`)
|
|||
|
|
console.log('请先获取测试网 ETH: https://www.alchemy.com/faucets/arbitrum-sepolia')
|
|||
|
|
} else {
|
|||
|
|
console.log('\n✅ ETH 足够运行模拟脚本')
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
main()
|