Method: Klay::Tx#decode
- Defined in:
- lib/klay/tx.rb
#decode(hex) ⇒ Klay::Tx
Decodes a transaction hex of any known type (2, 1, or legacy).
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/klay/tx.rb', line 106 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 |