import ( "github.com/ethereum/go-ethereum/core/types" ) blockHash := common.HexToHash("0x123456...") block, err := client.BlockByHash(context.Background(), blockHash) if err != nil { // handle error } uncles := block.Uncles() // uncles is a []*types.Header containing the uncles
import ( "github.com/ethereum/go-ethereum/core/types" ) header := &types.Header{ ParentHash: common.HexToHash("0xabcd..."), UncleHash: common.HexToHash("0xef01..."), Time: big.NewInt(123456789), Number: big.NewInt(123), MixDigest: common.HexToHash("0x7890..."), Nonce: types.EncodeNonce(1234), } block := &types.Block{ Header: *header, Transactions: []*types.Transaction{}, Uncles: []*types.Header{}, } uncle := &types.Header{ ParentHash: common.HexToHash("0xabcd..."), UncleHash: common.HexToHash("0x5678..."), Time: big.NewInt(123456789), Number: big.NewInt(122), MixDigest: common.HexToHash("0x1234..."), Nonce: types.EncodeNonce(5678), } block.Uncles = append(block.Uncles, uncle) // block now has a single uncle, namely "uncle"In this example, we create a new `types.Header` object manually to represent a block header, and then create a `types.Block` object containing that header and some other fields. We then create another `types.Header` object to represent an uncle, and append it to the "uncles" slice of the block object using the `append` function. Therefore, such examples utilize the "core/types" package library of the "go-ethereum" package.