class Eth::Tx::Eip1559

def encoded

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

Returns:
  • (String) - a raw, RLP-encoded EIP-1559 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 @max_priority_fee_per_gas
  tx_data.push Util.serialize_int_to_big_endian @max_fee_per_gas
  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 Rlp::Sedes.binary.serialize @payload
  tx_data.push Rlp::Sedes.infer(@access_list).serialize @access_list
  tx_data.push Util.serialize_int_to_big_endian @signature_y_parity
  tx_data.push Util.serialize_int_to_big_endian @signature_r
  tx_data.push Util.serialize_int_to_big_endian @signature_s
  tx_encoded = Rlp.encode tx_data
  # create an EIP-2718 envelope with EIP-1559 type payload
  tx_type = Util.serialize_int_to_big_endian @type
  return "#{tx_type}#{tx_encoded}"
end