MCPcopy Create free account
hub / github.com/Bot80926/ethers-scripts / getBlock

Method getBlock

utils/provider.js:20–39  ·  view source on GitHub ↗
(blockNumber)

Source from the content-addressed store, hash-verified

18 }
19
20 async getBlock(blockNumber) {
21 // const block = await this.provider.getBlock(blockNumber);
22 const block = await this.provider.send("eth_getBlockByNumber", [Decimal.toHex(blockNumber), false]);
23
24 return {
25 hash: block.hash,
26 parentHash: block.parentHash,
27 number: lodash.toInteger(Decimal.fromHex(block.number)),
28 timestamp: lodash.toInteger(Decimal.fromHex(block.timestamp)),
29 nonce: block.nonce,
30 difficulty: lodash.toInteger(Decimal.fromHex(block.difficulty)),
31 gasLimit: Decimal.fromHex(block.gasLimit), //
32 gasUsed: Decimal.fromHex(block.gasUsed), //
33 miner: block.miner,
34 extraData: block.extraData,
35 transactions: block.transactions,
36 logsBloom: block.logsBloom,
37 baseFeePerGas: lodash.isUndefined(block.baseFeePerGas) ? null : Decimal.fromHex(block.baseFeePerGas), //
38 };
39 }
40
41 async getChainBalance(address, blockTag = "latest") {
42 return await this.provider.getBalance(address, blockTag);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected