Querying Blocks

By calling BlockByNumber, you can get all the information of a block, including block height, timestamp, block hash, transaction list, etc.

blockNumber := big.NewInt(21879393)
block, err := client.BlockByNumber(context.Background(), blockNumber)
if err != nil {
    log.Fatal(err)
}
fmt.Println(block.Hash())
fmt.Println(block.Time())
fmt.Println(len(block.Transactions()))

Last updated