2023-02-13 17:39:34 +08:00
|
|
|
//import {ethers} from 'https://unpkg.com/ethers/dist/ethers.js'
|
|
|
|
|
import {ethers} from 'https://unpkg.com/ethers@5.7.2/dist/ethers.esm.js'
|
2023-01-18 10:26:35 +08:00
|
|
|
|
|
|
|
|
const URL = 'https://ethereum-goerli-rpc.allthatnode.com'
|
|
|
|
|
|
|
|
|
|
const p = ethers.getDefaultProvider(URL)
|
2023-02-06 01:53:34 +08:00
|
|
|
await p._networkPromise
|
2023-01-18 10:26:35 +08:00
|
|
|
|
2023-02-13 17:39:34 +08:00
|
|
|
|
2023-01-18 10:26:35 +08:00
|
|
|
const latest = await p.getBlock()
|
2023-02-06 01:53:34 +08:00
|
|
|
latest
|
|
|
|
|
|
2023-01-18 10:26:35 +08:00
|
|
|
|
2023-05-13 11:13:29 +03:00
|
|
|
const txs = await Promise.all(latest.transactions.map(t =>
|
2023-01-18 10:26:35 +08:00
|
|
|
p.getTransactionReceipt(t)
|
|
|
|
|
))
|
|
|
|
|
|
2023-02-06 01:53:34 +08:00
|
|
|
|
2023-01-18 10:26:35 +08:00
|
|
|
const totalGas = txs.reduce((gas,tx) =>
|
|
|
|
|
gas.add(tx.gasUsed), ethers.BigNumber.from(0))
|
2023-02-06 01:53:34 +08:00
|
|
|
|
2023-02-13 17:39:34 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-05-13 11:13:29 +03:00
|
|
|
totalGas.add(21)
|
2023-02-06 01:53:34 +08:00
|
|
|
|
|
|
|
|
|
2023-02-13 17:39:34 +08:00
|
|
|
/*
|
|
|
|
|
const totalGas = txs.reduce((gas,tx) =>
|
|
|
|
|
gas + tx.gasUsed, BigInt(0))
|
|
|
|
|
|
|
|
|
|
totalGas + 1
|
|
|
|
|
*/
|
2023-02-06 01:53:34 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-02-13 17:39:34 +08:00
|
|
|
|