module Eth::Tx
def decode(hex)
-
(TransactionTypeError)
- if the transaction type is unknown.
Returns:
-
(Eth::Tx)
- transaction payload.
Parameters:
-
hex
(String
) -- the raw transaction hex-string.
def decode(hex) hex = Util.remove_hex_prefix hex type = hex[0, 2].to_i(16) case type when TYPE_1559 # EIP-1559 transaction (type 2) return Tx::Eip1559.decode hex when TYPE_2930 # EIP-2930 transaction (type 1) return Tx::Eip2930.decode hex else # Legacy transaction if first byte is RLP (>= 192) if type >= 0xc0 return Tx::Legacy.decode hex else raise TransactionTypeError, "Cannot decode unknown transaction type #{type}!" end end end