@@ -840,6 +840,56 @@ func (s *PublicBlockChainAPI) GetStorageAt(ctx context.Context, address common.A
840840 return res [:], state .Error ()
841841}
842842
843+ // gets all receipts in block
844+ // Note, this method doesnt return the entire transaction receipt to save resources
845+ func (s * PublicBlockChainAPI ) GetBlockReceipts (ctx context.Context , hash common.Hash ) (map [string ]interface {}, error ) {
846+ receipts , err := s .b .GetReceipts (ctx , hash )
847+ if err != nil {
848+ return nil , err
849+ }
850+ resultFields := map [string ]interface {}{
851+ "blockHash" : hash ,
852+ "receipts" : []map [string ]interface {}{},
853+ }
854+
855+ // add all receipts to the result
856+ for _ , receipt := range receipts {
857+ fields := map [string ]interface {}{
858+ "transactionHash" : receipt .TxHash ,
859+ "transactionIndex" : receipt .TransactionIndex ,
860+ "gasUsed" : hexutil .Uint64 (receipt .GasUsed ),
861+ "cumulativeGasUsed" : hexutil .Uint64 (receipt .CumulativeGasUsed ),
862+ "contractAddress" : nil ,
863+ "logs" : receipt .Logs ,
864+ "type" : hexutil .Uint (receipt .Type ),
865+ }
866+ // we dont need to return gas price atm
867+ // // Assign the effective gas price paid
868+ // if isLondon {
869+ // fields["effectiveGasPrice"] = hexutil.Uint64(tx.GasPrice().Uint64())
870+ // } else {
871+ // gasPrice := new(big.Int).Add(header.BaseFee, tx.EffectiveGasTipValue(header.BaseFee))
872+ // fields["effectiveGasPrice"] = hexutil.Uint64(gasPrice.Uint64())
873+ // }
874+ // Assign receipt status or post state.
875+ if len (receipt .PostState ) > 0 {
876+ fields ["root" ] = hexutil .Bytes (receipt .PostState )
877+ } else {
878+ fields ["status" ] = hexutil .Uint (receipt .Status )
879+ }
880+ if receipt .Logs == nil {
881+ fields ["logs" ] = []* types.Log {}
882+ }
883+ // If the ContractAddress is 20 0x0 bytes, assume it is not a contract creation
884+ if receipt .ContractAddress != (common.Address {}) {
885+ fields ["contractAddress" ] = receipt .ContractAddress
886+ }
887+ resultFields ["receipts" ] = append (resultFields ["receipts" ].([]map [string ]interface {}), fields )
888+ }
889+
890+ return resultFields , nil
891+ }
892+
843893// OverrideAccount indicates the overriding fields of account during the execution
844894// of a message call.
845895// Note, state and stateDiff can't be specified at the same time. If state is
0 commit comments