A transaction refers to an action initiated by an account which changes the state of the blockchain. To effectively perform the state change, every transaction is broadcasted to the whole network. Any node can broadcast a request for a transaction to be executed on the blockchain state machine; after this happens, a validator will validate, execute the transaction and propagate the resulting state change to the rest of the network.
sdk.Msg
contained in an auth.StdTx
. All relevant Ethereum transaction information is contained in this message. This includes the signature, gas, payload, etc.
Find more information about these two types on the following sections.
sdk.Msg
s that trigger state changes within a module through the module’s Protobuf Msg service.
When users want to interact with an application and make state changes (e.g. sending coins), they create transactions. Cosmos transactions can have multiple sdk.Msg
s. Each of these must be signed using the private key associated with the appropriate account(s), before the transaction is broadcasted to the network.
A Cosmos transaction includes the following information:
Msgs
: an array of msgs (sdk.Msg
)GasLimit
: option chosen by the users for how to calculate how much gas they will need to payFeeAmount
: max amount user is willing to pay in feesTimeoutHeight
: block height until which the transaction is validSignatures
: array of signatures from all signers of the txMemo
: a note or comment to send with the transactiongas
. (EIP-1559) introduced the idea of a base fee, along with a priority fee which serves as an incentive for miners to include specific transactions in blocks.
There are several categories of Ethereum transactions:
to
address, where the contract code is sent in the data
fieldto
address is the smart contract addressrecipient
: receiving addresssignature
: sender’s signaturenonce
: counter of tx number from accountvalue
: amount of ETH to transfer (in wei)data
: include arbitrary data. Used when deploying a smart contract or making a smart contract method callgasLimit
: max amount of gas to be consumedmaxPriorityFeePerGas
: mas gas to be included as tip to validatorsmaxFeePerGas
: max amount of gas to be paid for txsdk.Msg
. It achieves this by using the MsgEthereumTx
. This message encapsulates an Ethereum transaction as an SDK message and contains the necessary transaction data fields.
One remark about the MsgEthereumTx
is that it implements both the sdk.Msg
and sdk.Tx
interfaces (generally SDK messages only implement the former, while the latter is a group of messages bundled together). The reason of this, is because the MsgEthereumTx
must not be included in a auth.StdTx
(SDK’s standard transaction type) as it performs gas and fee checks using the Ethereum logic from Geth instead of the Cosmos SDK checks done on the auth module AnteHandler
.
transactionHash
: hash of the transaction.transactionIndex
: integer of the transactions index position in the block.blockHash
: hash of the block where this transaction was in.blockNumber
: block number where this transaction was in.from
: address of the sender.to
: address of the receiver. null when its a contract creation transaction.cumulativeGasUsed
: The total amount of gas used when this transaction was executed in the block.effectiveGasPrice
: The sum of the base fee and tip paid per unit of gas.gasUsed
: The amount of gas used by this specific transaction alone.contractAddress
: The contract address created, if the transaction was a contract creation, otherwise null.logs
: Array of log objects, which this transaction generated.logsBloom
: Bloom filter for light clients to quickly retrieve related logs.type
: integer of the transaction type, 0x00 for legacy transactions, 0x01 for access list types, 0x02 for dynamic fees. It also returns either.root
: transaction stateroot (pre Byzantium)status
: either 1 (success) or 0 (failure)