File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed
step29_web3_inspect_blocks Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -12,21 +12,21 @@ const DAI_ADDRESS = "0x6B175474E89094C44Da98b954EedeAC495271d0F";
1212 const fromBlock = 13134800 ;
1313 const toBlock = 13134820 ;
1414
15- // All Events
15+ // #1 All Events
1616 const allEvents = await contract . getEvents ( {
1717 fromBlock,
1818 toBlock,
1919 } ) ;
2020 console . log ( "All Events Count:" , allEvents . length ) ;
2121
22- // Transfer Events Only
22+ // #2 Transfer Events Only
2323 const transferEvents = await contract . getEvents ( {
2424 fromBlock,
2525 toBlock,
2626 eventType : "Transfer" ,
2727 } ) ;
2828 console . log ( "Transfer Events Count:" , transferEvents . length ) ;
2929
30- // Latest Event generated by DAI's contract.
30+ // #3 Latest Event generated by DAI's contract.
3131 console . log ( "Latest Event:" , allEvents . pop ( ) ) ;
3232} ) ( ) ;
Original file line number Diff line number Diff line change @@ -3,24 +3,29 @@ import { EthNetwork } from "./EthNetwork";
33( async ( ) => {
44 const network = new EthNetwork ( ) ;
55
6+ // #1
67 console . log ( "Latest Block Number:" , await network . getLatestBlockNumber ( ) ) ;
78
9+ // #2
810 const blockNumber = 13101095 ;
911 const block = await network . getBlock ( blockNumber ) ;
1012 // I am only logging the block hash here.
1113 // Feel free to log other info about the block
1214 console . log ( `Block Hash of Block #${ blockNumber } :` , block . hash ) ;
1315
16+ // #3
1417 console . log (
1518 `Number of Txns in Block #${ blockNumber } :` ,
1619 await network . getBlockTransactionCount ( blockNumber )
1720 ) ;
1821
22+ // #4
1923 console . log (
2024 `First Transaction in Block #${ blockNumber } :` ,
2125 ( await network . getTransactionFromBlock ( 0 , blockNumber ) ) . hash
2226 ) ;
2327
28+ // #5
2429 console . log ( "Number of Transactions in 10 Latest Blocks:" ) ;
2530 ( await network . getLatestXBlocks ( ) ) . forEach ( block => {
2631 console . log ( `Block Number ${ block . number } ==>` , block . transactions . length ) ;
You can’t perform that action at this time.
0 commit comments