class Eth::Tx::Eip2930

def encoded

Raises:
  • (SignatureError) - if the transaction is not yet signed.

Returns:
  • (String) - a raw, RLP-encoded EIP-2930 type transaction object.
def encoded
  unless Tx.is_signed? self
    raise Signature::SignatureError, "Transaction is not signed!"
  end
  tx_data = []
  tx_data.push Util.serialize_int_to_big_endian @chain_id
  tx_data.push Util.serialize_int_to_big_endian @signer_nonce
  tx_data.push Util.serialize_int_to_big_endian @gas_price
  tx_data.push Util.serialize_int_to_big_endian @gas_limit
  tx_data.push Util.hex_to_bin @destination
  tx_data.push Util.serialize_int_to_big_endian @amount
  tx_data.push @payload
  tx_data.push @access_list
  tx_data.push Util.serialize_int_to_big_endian @signature_y_parity
  tx_data.push Util.hex_to_bin @signature_r
  tx_data.push Util.hex_to_bin @signature_s
  tx_encoded = RLP.encode tx_data
  # create an EIP-2718 envelope with EIP-2930 type payload
  tx_type = Util.serialize_int_to_big_endian @type
  return "#{tx_type}#{tx_encoded}"
end