2025-05-30 19:59:02 +00:00
|
|
|
import { ethers } from "ethers"
|
2023-01-18 10:26:35 +08:00
|
|
|
|
2025-05-30 19:59:02 +00:00
|
|
|
const URL = "https://eth-mainnet.public.blastapi.io"
|
2023-01-18 10:26:35 +08:00
|
|
|
|
|
|
|
|
const p = ethers.getDefaultProvider(URL)
|
2023-02-13 17:39:34 +08:00
|
|
|
|
2023-01-18 10:26:35 +08:00
|
|
|
const latest = await p.getBlock()
|
|
|
|
|
|
2025-05-30 19:59:02 +00:00
|
|
|
const txs = await Promise.all(
|
|
|
|
|
latest.transactions.map(t => p.getTransactionReceipt(t)),
|
|
|
|
|
)
|
2023-01-18 10:26:35 +08:00
|
|
|
|
2023-05-18 23:15:10 +03:00
|
|
|
const totalGas = txs
|
|
|
|
|
.filter(tx => tx != null)
|
2025-05-30 19:59:02 +00:00
|
|
|
.reduce((gas, tx) => gas.add(tx.gasUsed), ethers.BigNumber.from(0))
|