View Source Signet.Receipt (Signet v0.2.0-alpha5)

Represents an Ethereum transaction receipt, which contains information about the success or failure of an Ethereum transaction after it has been included in a mined Ethereum block.

See Signet.RPC.get_transaction_receipt for getting receipts from an Ethereum JSON-RPC host.

Summary

Functions

Deserializes a transaction receipt as serialized by an Ethereum JSON-RPC response.

Types

@type t() :: %Signet.Receipt{
  block_hash: <<_::256>>,
  block_number: integer(),
  contract_address: <<_::160>> | nil,
  cumulative_gas_used: integer(),
  effective_gas_price: integer(),
  from: <<_::160>>,
  gas_used: integer(),
  logs: [Signet.Receipt.Log.t()],
  logs_bloom: <<_::256>>,
  status: integer(),
  to: <<_::160>>,
  transaction_hash: <<_::256>>,
  transaction_index: integer(),
  type: integer()
}

Functions

@spec deserialize(map()) :: t() | no_return()

Deserializes a transaction receipt as serialized by an Ethereum JSON-RPC response.

See also https://ethereum.org/en/developers/docs/apis/json-rpc#eth_gettransactionreceipt

Examples

iex> %{
...>   "blockHash" => "0xa957d47df264a31badc3ae823e10ac1d444b098d9b73d204c40426e57f47e8c3",
...>   "blockNumber" => "0xeff35f",
...>   "contractAddress" => nil,
...>   "cumulativeGasUsed" => "0xa12515",
...>   "effectiveGasPrice" => "0x5a9c688d4",
...>   "from" => "0x6221a9c005f6e47eb398fd867784cacfdcfff4e7",
...>   "gasUsed" => "0xb4c8",
...>   "logs" => [%{
...>     "logIndex" => "0x1",
...>     "blockNumber" => "0x1b4",
...>     "blockHash" => "0xaa8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcfdf829c5a142f1fccd7d",
...>     "transactionHash" =>  "0xaadf829c5a142f1fccd7d8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcf",
...>     "transactionIndex" => "0x0",
...>     "address" => "0x16c5785ac562ff41e2dcfdf829c5a142f1fccd7d",
...>     "data" => "0x0000000000000000000000000000000000000000000000000000000000000000",
...>     "topics" => [
...>       "0x59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a5"
...>     ]
...>   }],
...>   "logsBloom" => "0x0000000000000000000000000000000000000000000000000000000000000001",
...>   "status" => "0x1",
...>   "to" => "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
...>   "transactionHash" =>
...>     "0x85d995eba9763907fdf35cd2034144dd9d53ce32cbec21349d4b12823c6860c5",
...>   "transactionIndex" => "0x66",
...>   "type" => "0x2"
...> }
...> |> Signet.Receipt.deserialize()
%Signet.Receipt{
  transaction_hash: Signet.Util.decode_hex!("0x85d995eba9763907fdf35cd2034144dd9d53ce32cbec21349d4b12823c6860c5"),
  transaction_index: 0x66,
  block_hash: Signet.Util.decode_hex!("0xa957d47df264a31badc3ae823e10ac1d444b098d9b73d204c40426e57f47e8c3"),
  block_number: 0xeff35f,
  from: Signet.Util.decode_hex!("0x6221a9c005f6e47eb398fd867784cacfdcfff4e7"),
  to: Signet.Util.decode_hex!("0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"),
  cumulative_gas_used: 0xa12515,
  effective_gas_price: 0x5a9c688d4,
  gas_used: 0xb4c8,
  contract_address: nil,
  logs: [
    %Signet.Receipt.Log{
      log_index: 1,
      block_number: 0x01b4,
      block_hash: Signet.Util.decode_hex!("0xaa8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcfdf829c5a142f1fccd7d"),
      transaction_hash: Signet.Util.decode_hex!("0xaadf829c5a142f1fccd7d8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcf"),
      transaction_index: 0,
      address: Signet.Util.decode_hex!("0x16c5785ac562ff41e2dcfdf829c5a142f1fccd7d"),
      data: Signet.Util.decode_hex!("0x0000000000000000000000000000000000000000000000000000000000000000"),
      topics: [
        Signet.Util.decode_hex!("0x59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a5")
      ]
    }
  ],
  logs_bloom: Signet.Util.decode_hex!("0x0000000000000000000000000000000000000000000000000000000000000001"),
  type: 0x02,
  status: 0x01,
}