Transactions

This section defines the sdk.Msg concrete types that result in the state transitions defined on the previous section.

MsgEthereumTx

An EVM state transition can be achieved by using the MsgEthereumTx. This message encapsulates an Ethereum transaction data (TxData) as a sdk.Msg.

It contains the necessary transaction data fields. Note, that the MsgEthereumTx implements both the sdk.Msg and sdk.Tx interfaces. Normally, SDK messages only implement the former, while the latter is a group of messages bundled together.

type MsgEthereumTx struct {
 // inner transaction data
 Data *types.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
 // DEPRECATED: encoded storage size of the transaction
 Size_ float64 `protobuf:"fixed64,2,opt,name=size,proto3" json:"-"`
 // transaction hash in hex format
 Hash string `protobuf:"bytes,3,opt,name=hash,proto3" json:"hash,omitempty" rlp:"-"`
 // ethereum signer address in hex format. This address value is checked
 // against the address derived from the signature (V, R, S) using the
 // secp256k1 elliptic curve
 From string `protobuf:"bytes,4,opt,name=from,proto3" json:"from,omitempty"`
}

This message field validation is expected to fail if:

  • From field is defined and the address is invalid

  • TxData stateless validation fails

The transaction execution is expected to fail if:

  • Any of the custom AnteHandler Ethereum decorators checks fail:

    • Minimum gas amount requirements for transaction

    • Tx sender account doesn't exist or hasn't enough balance for fees

    • Account sequence doesn't match the transaction Data.AccountNonce

    • Message signature verification fails

  • EVM contract creation (i.e evm.Create) fails, or evm.Call fails

Conversion

The MsgEthreumTx can be converted to the go-ethereum Transaction and Message types in order to create and call evm contracts.

Signing

In order for the signature verification to be valid, the TxData must contain the v | r | s values from the Signer. Sign calculates a secp256k1 ECDSA signature and signs the transaction. It takes a keyring signer and the chainID to sign an Ethereum transaction according to EIP155 standard.

This method mutates the transaction as it populates the V, R, S fields of the Transaction's Signature. The function will fail if the sender address is not defined for the msg or if the sender is not registered on the keyring.

TxData

The MsgEthereumTx supports the 3 valid Ethereum transaction data types from go-ethereum: LegacyTx, AccessListTx and DynamicFeeTx. These types are defined as protobuf messages and packed into a proto.Any interface type in the MsgEthereumTx field.

  • LegacyTx: EIP-155 transaction type

  • DynamicFeeTx: EIP-1559 transaction type. Enabled by London hard fork block

  • AccessListTx: EIP-2930 transaction type. Enabled by Berlin hard fork block

LegacyTx

The transaction data of regular Ethereum transactions.

This message field validation is expected to fail if:

  • GasPrice is invalid (nil , negaitve or out of int256 bound)

  • Fee (gasprice * gaslimit) is invalid

  • Amount is invalid (negaitve or out of int256 bound)

  • To address is invalid (non valid ethereum hex address)

DynamicFeeTx

The transaction data of EIP-1559 dynamic fee transactions.

This message field validation is expected to fail if:

  • GasTipCap is invalid (nil , negative or overflows int256)

  • GasFeeCap is invalid (nil , negative or overflows int256)

  • GasFeeCap is less than GasTipCap

  • Fee (gas price * gas limit) is invalid (overflows int256)

  • Amount is invalid (negative or overflows int256)

  • To address is invalid (non-valid ethereum hex address)

  • ChainID is nil

AccessListTx

The transaction data of EIP-2930 access list transactions.

This message field validation is expected to fail if:

  • GasPrice is invalid (nil , negative or overflows int256)

  • Fee (gas price * gas limit) is invalid (overflows int256)

  • Amount is invalid (negative or overflows int256)

  • To address is invalid (non-valid ethereum hex address)

  • ChainID is nil

Last updated