mirror of
https://github.com/leporello-js/leporello-js
synced 2026-01-13 13:04:30 -08:00
async/await example
This commit is contained in:
14
docs/examples/ethers/index.js
Normal file
14
docs/examples/ethers/index.js
Normal file
@@ -0,0 +1,14 @@
|
||||
import {ethers} from 'https://unpkg.com/ethers/dist/ethers.esm.js'
|
||||
|
||||
const URL = 'https://ethereum-goerli-rpc.allthatnode.com'
|
||||
|
||||
const p = ethers.getDefaultProvider(URL)
|
||||
|
||||
const latest = await p.getBlock()
|
||||
|
||||
const txs = await Promise.all(latest.transactions.map(t =>
|
||||
p.getTransactionReceipt(t)
|
||||
))
|
||||
|
||||
const totalGas = txs.reduce((gas,tx) =>
|
||||
gas.add(tx.gasUsed), ethers.BigNumber.from(0))
|
||||
Reference in New Issue
Block a user