Transactions

Transactions

Transactions are fundamental operations on the Sei blockchain and are required for any state updates on chain such as token transfers, account creation, and smart contract execution. Transactions are cryptographically signed by the sender’s private key to ensure authenticity and ownership. For more information on private keys, refer to the advanced section on HD Paths and Coin Types

Transaction Types

Since Sei supports both EVM and Cosmos SDK transactions, there are different transaction types based on the execution environment. The following sections provide an overview of Cosmos and EVM transactions on Sei.

Cosmos Transactions

Cosmos transactions are used for interacting with Cosmos based RPC's and tooling. They consist of the body, auth info, and signatures.

1
2{
3      "body": {
4        "messages": [
5          {
6            "@type": "/cosmos.bank.v1beta1.MsgSend",
7            "from_address": "sei1tgaen946qle7lttgjjfwea9qq02y6f8j7nkxry",
8            "to_address": "SENDER_ADDRESS",
9            "amount": [
10              {
11                "denom": "usei",
12                "amount": "1000"
13              }
14            ]
15          }
16        ],
17        "memo": "",
18        "timeout_height": "0",
19        "extension_options": [],
20        "non_critical_extension_options": []
21      },
22      "auth_info": {
23        "signer_infos": [
24          {
25            "public_key": {
26              "@type": "/cosmos.crypto.secp256k1.PubKey",
27              "key": "A807McXECLx88ANdcwysZSVeelx0gNpYChBJZe8kya9X"
28            },
29            "mode_info": {
30              "single": {
31                "mode": "SIGN_MODE_DIRECT"
32              }
33            },
34            "sequence": "0"
35          }
36        ],
37        "fee": {
38          "amount": [],
39          "gas_limit": "200000",
40          "payer": "",
41          "granter": ""
42        }
43      },
44      "signatures": ["SIGNER_SIGNATURE_VALUE"]
45    }
46				

Signing Cosmos Transactions

Cosmos transactions on the Sei blockchain follow the standard Cosmos SDK format. They include various types of messages that can be included in the transaction body.

Using the seid CLI, you can use the --generate-only flag to generate an unsigned transaction in JSON format. The transaction can then be signed and broadcasted to the network.

Assuming you have an unsigned JSON transaction file, you can sign it using the seid tx sign command. The signed transaction will be in JSON format and can be broadcasted to the network.

seid tx sign unsigned_tx.json --chain-id my-test-chain --keyring-backend test --from $SIGNER_ADDRESS

EVM Transactions

The Sei blockchain supports Ethereum Virtual Machine (EVM) transactions, allowing compatibility with Ethereum-based tools and contracts. EVM transactions follow a different structure compared to Cosmos transactions.

1
2					{
3	id: 2,
4	jsonrpc: '2.0',
5	method: 'account_signTransaction',
6	params: [
7{
8	from: '0x1923f626bb8dc025849e00f99c25fe2b2f7fb0db',
9	gas: '0x55555',
10	maxFeePerGas: '0x1234',
11	maxPriorityFeePerGas: '0x1234',
12	input: '0xabcd',
13	nonce: '0x0',
14	to: '0x07a565b7ed7d7a678680a4c162885bedbb695fe0',
15	value: '0x1234'
16}
17	]
18}
19