Phoenix Chain SDK Doc
  • Introduction
  • Client
    • Initializing a Client
  • Accounts
    • Querying Balances
  • Blocks and Transactions
    • Querying Blocks
    • Querying Transactions
  • Smart Contracts
    • Installing Dev Tools
    • Generating Go Contracts File
    • Deploying Contracts
    • Querying Contracts
    • Writing to Contracts
  • Event logs
    • Filtering Event logs
    • Subscribing to Event Logs
Powered by GitBook
On this page
  1. Blocks and Transactions

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()))
PreviousBlocks and TransactionsNextQuerying Transactions

Last updated 2 years ago