blockHash := "00000000000000a99d0ba59704dc7766ff447e4ae8e2b06a8925c7773e71d69b" block, err := dcrutil.GetBlockFromHash(blockHash) if err != nil { fmt.Println(err) return } fmt.Printf("Block Height: %d\n", block.Height())
block, err := dcrutil.NewBlockFromString(blockString) if err != nil { fmt.Println(err) return } fmt.Printf("Block Timestamp: %d\n", block.MsgBlock().Header.Timestamp.Unix())This example shows how to create a block from a raw block string and then print its timestamp. The github.com.decred.dcrutil package library provides a wide range of functions and structures for working with decred blocks, and is particularly valuable for developers building blockchain applications in Go.