func GetBlockWithTxReceipts(client *ethclient.Client, height int64) (res *BlockWithTxReceipts, err error) {
	res = &BlockWithTxReceipts{}
	res.TxReceipts = make(map[common.Hash]*types.Receipt)

	// Get the block
	res.Block, err = client.BlockByNumber(context.Background(), big.NewInt(height))
	if err != nil {
		return res, err
	}

	// Get receipts for all transactions
	for _, tx := range res.Block.Transactions() {
		receipt, err := client.TransactionReceipt(context.Background(), tx.Hash())
		if err != nil {
			if errors.Is(err, ethereum.NotFound) {
				// can apparently happen if 0 tx: https://etherscan.io/block/10102170
				continue
			}
			return res, err

		}
		res.TxReceipts[tx.Hash()] = receipt
	}

	return res, nil
}
// GetBlockWithTxReceipts returns a single block with receipts for all transactions
GetBlockWithTxReceipts returns a single block with receipts for all transactions
// GetBlockWithTxReceipts returns a single block with receipts for all transactions
func GetBlockWithTxReceipts(client *ethclient.Client, height int64) (res *BlockWithTxReceipts, err error) {
	res = &BlockWithTxReceipts{}
	res.TxReceipts = make(map[common.Hash]*types.Receipt)
	res.Block, err = client.BlockByNumber(context.Background(), big.NewInt(height))
	if err != nil {
		return res, err
	}
	for _, tx := range res.Block.Transactions() {
		receipt, err := client.TransactionReceipt(context.Background(), tx.Hash())
		if err != nil {
			if errors.Is(err, ethereum.NotFound) {
				continue
			}
			return res, err
		}
		res.TxReceipts[tx.Hash()] = receipt
	}
	return res, nil
}
func GetBlockWithTxReceipts ( client * ethclient . Client , height int64 ) ( res * BlockWithTxReceipts , err error ) { res = & BlockWithTxReceipts { } res . TxReceipts = make ( map [ common . Hash ] * types . Receipt ) res . Block , err = client . BlockByNumber ( context . Background ( ) , big . NewInt ( height ) ) if err != nil { return res , err } for _ , tx := range res . Block . Transactions ( ) { receipt , err := client . TransactionReceipt ( context . Background ( ) , tx . Hash ( ) ) if err != nil { if errors . Is ( err , ethereum . NotFound ) { continue } return res , err } res . TxReceipts [ tx . Hash ( ) ] = receipt } return res , nil }
GetBlockWithTxReceipts returns a single block with receipts for all transactions
GetBlockWithTxReceipts returns a single block with receipts for all transactions
// Get the block // Get receipts for all transactions // can apparently happen if 0 tx: https://etherscan.io/block/10102170