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):
Ethers.Transaction.from_rpc_map/1, and soEthers.get_transaction/2, keep the JSON-RPC transaction object inrpc_mapand its block metadata inmetadata.Ethers.Transaction.decode/1keeps the EIP-2718TransactionPayload(the bytes after the type byte) inraw_payload.
{: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
@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 withEthers.Transaction.from_rpc_map/1raw_payload- the EIP-2718TransactionPayload, undecoded, when read withEthers.Transaction.decode/1metadata- block metadata (block hash, block number and transaction index) from the RPC map, likeEthers.Transaction.Signedcarries for registered types. A value that is missing or not valid for its field is nil (it is still inrpc_map)