Ethers.Transaction.Unknown (Ethers v1.0.0)

Copy Markdown View Source

Transaction of a type that is not registered, kept undecoded.

Without the type's layout only the type id is known, so this struct keeps the transaction as it was read for the type specific code to use. It is returned for a transaction type without a registered module, like the chain specific types of L2s (for example OP-stack deposit transactions, type 0x7e):

{:ok, %Ethers.Transaction.Unknown{type_id: 0x7E, rpc_map: rpc_map}} =
  Ethers.get_transaction(tx_hash)

rpc_map["from"]
#=> "0xdeaddeaddeaddeaddeaddeaddeaddeaddead0001"

rpc_map["sourceHash"]
#=> "0x817dce692d94a9f2a738f9856f0faf3a942260a5d51684a5ac3823f5f1542f44"

A transaction decoded from bytes encodes back to the same bytes with Ethers.Transaction.encode/1, and Ethers.Transaction.transaction_hash/2 returns the keccak hash of them. One read from an RPC map cannot be encoded or hashed (the hash reported by the node is in rpc_map["hash"]), and neither can be signed or converted with Ethers.Transaction.to_rpc_map/1: these raise ArgumentError.

Types listed in the compile-time :transaction_types config of :ethers are decoded by their module instead.

Summary

Types

t()

A transaction of an unregistered type with the following fields

Types

t()

@type t() :: %Ethers.Transaction.Unknown{
  metadata: Ethers.Transaction.Metadata.t() | nil,
  raw_payload: binary() | nil,
  rpc_map: map() | nil,
  type_id: non_neg_integer()
}

A transaction of an unregistered type with the following fields:

  • type_id - the transaction type (e.g. 0x7E)
  • rpc_map - the JSON-RPC transaction object, unchanged (addresses keep the node's casing), when read with Ethers.Transaction.from_rpc_map/1
  • raw_payload - the EIP-2718 TransactionPayload, undecoded, when read with Ethers.Transaction.decode/1
  • metadata - block metadata (block hash, block number and transaction index) from the RPC map, like Ethers.Transaction.Signed carries for registered types. A value that is missing or not valid for its field is nil (it is still in rpc_map)