> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sei.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Querying the EVM

> Read EVM state from the seid CLI: address associations, ERC20 reads, ABI-encoded payloads, and transaction details.

The `seid q evm` subcommands let you read EVM state — token data, address associations, and transactions — without sending a transaction or running your own node.

## Prerequisites

If your machine is **not running a Sei node**, append the `--node` flag to every `seid q evm` command, pointing at a Sei Cosmos RPC endpoint (the same kind used by `seid status`):

```bash theme={"dark"}
--node https://<sei-cosmos-rpc-url>
```

The one exception is `seid q evm tx`, which uses `--evm-rpc` to point at an EVM JSON-RPC endpoint (port 8545 by convention). See [Transaction Lookup](#transaction-lookup) below.

<Info>Refer to the [RPC endpoints](/evm/networks) page for a list of available RPC endpoints.</Info>

<Info>
  **Output format.** Most commands print YAML by default. Pass `-o json` for JSON. ERC20 read methods (`name`, `balanceOf`, …) return a bare value with no formatting — the result below is the raw stdout.
</Info>

## Address Mapping

Sei addresses (`sei1…`) and EVM addresses (`0x…`) are linked via an on-chain association set the first time an account signs an EVM transaction or calls the address-association precompile. Until then, the two address spaces are independent.

### Get Sei Address from EVM Address

```bash theme={"dark"}
seid q evm sei-addr [evm address]
```

**Example:**

```bash theme={"dark"}
seid q evm sei-addr 0xDa52B9E673d1f48FcD9916b3F606A136a8eA5e55
```

**Output:**

```yaml theme={"dark"}
associated: true
sei_address: sei13ytysxs88z0fp9cssagg77ekpecrrlrwce9pwl
```

### Get EVM Address from Sei Address

```bash theme={"dark"}
seid q evm evm-addr [sei address]
```

**Example:**

```bash theme={"dark"}
seid q evm evm-addr sei13ytysxs88z0fp9cssagg77ekpecrrlrwce9pwl
```

**Output:**

```yaml theme={"dark"}
associated: true
evm_address: 0xDa52B9E673d1f48FcD9916b3F606A136a8eA5e55
```

<Info>If the account hasn't been associated yet, `associated` is `false` and the other field is empty. This is normal for accounts that have only ever transacted on one side of the chain.</Info>

## ERC20 Contract Queries

Call standard view methods on any ERC20 contract:

```bash theme={"dark"}
seid q evm erc20 [contract address] [method] [arguments...]
```

**Example — query Wrapped Sei (`WSEI`):**

```bash theme={"dark"}
seid q evm erc20 0xE30feDd158A2e3b13e9badaeABaFc5516e95e8C7 symbol
```

**Output:**

```
WSEI
```

**Example — balance:**

```bash theme={"dark"}
seid q evm erc20 0xE30feDd158A2e3b13e9badaeABaFc5516e95e8C7 balanceOf 0xDa52B9E673d1f48FcD9916b3F606A136a8eA5e55
```

**Output (raw integer, in smallest unit):**

```
0
```

<Info>
  **Supported methods:**

  * `name` — token name
  * `symbol` — token symbol
  * `decimals` — token decimals
  * `totalSupply` — total supply
  * `balanceOf [address]` — balance of an address
  * `allowance [owner] [spender]` — current allowance

  For arbitrary methods or non-standard contracts, use [`payload`](#custom-abi) with the contract ABI.
</Info>

## Payload Generation

Generate ABI-encoded call data without sending a transaction. Useful for crafting `seid tx evm call-contract` calls or inspecting expected calldata.

<Tabs>
  <Tab title="ERC20">
    ### ERC20 Payload Generation

    ```bash theme={"dark"}
    seid q evm erc20-payload [method] [arguments...]
    ```

    **Transfer tokens (1 token, 18 decimals):**

    ```bash theme={"dark"}
    seid q evm erc20-payload transfer 0xDa52B9E673d1f48FcD9916b3F606A136a8eA5e55 1000000000000000000
    ```

    **Output:**

    ```
    a9059cbb000000000000000000000000da52b9e673d1f48fcd9916b3f606a136a8ea5e550000000000000000000000000000000000000000000000000de0b6b3a7640000
    ```

    **Approve spender:**

    ```bash theme={"dark"}
    seid q evm erc20-payload approve 0xDa52B9E673d1f48FcD9916b3F606A136a8eA5e55 2000000000000000000
    ```

    **Output:**

    ```
    095ea7b3000000000000000000000000da52b9e673d1f48fcd9916b3f606a136a8ea5e550000000000000000000000000000000000000000000000001bc16d674ec80000
    ```

    **Transfer from (pulls tokens from `from` to `to`, using a prior `approve`):**

    ```bash theme={"dark"}
    seid q evm erc20-payload transferFrom 0xDa52B9E673d1f48FcD9916b3F606A136a8eA5e55 0xdEAD000000000000000042069420694206942069 1500000000000000000
    ```

    **Output:**

    ```
    23b872dd000000000000000000000000da52b9e673d1f48fcd9916b3f606a136a8ea5e55000000000000000000000000dead00000000000000004206942069420694206900000000000000000000000000000000000000000000000014d1120d7b160000
    ```

    <Info>
      **Supported methods:**

      * `transfer [to] [amount]`
      * `approve [spender] [amount]`
      * `transferFrom [from] [to] [amount]`

      Amounts are in the token's smallest unit (e.g., wei for an 18-decimal token; `1000000` for 1 USDC with 6 decimals).
    </Info>
  </Tab>

  <Tab title="ERC721">
    ### ERC721 Payload Generation

    ```bash theme={"dark"}
    seid q evm erc721-payload [method] [arguments...]
    ```

    **Approve a token ID:**

    ```bash theme={"dark"}
    seid q evm erc721-payload approve 0xDa52B9E673d1f48FcD9916b3F606A136a8eA5e55 123
    ```

    **Output:**

    ```
    095ea7b3000000000000000000000000da52b9e673d1f48fcd9916b3f606a136a8ea5e55000000000000000000000000000000000000000000000000000000000000007b
    ```

    **Transfer a token:**

    ```bash theme={"dark"}
    seid q evm erc721-payload transferFrom 0xDa52B9E673d1f48FcD9916b3F606A136a8eA5e55 0xdEAD000000000000000042069420694206942069 123
    ```

    **Output:**

    ```
    23b872dd000000000000000000000000da52b9e673d1f48fcd9916b3f606a136a8ea5e55000000000000000000000000dead000000000000000042069420694206942069000000000000000000000000000000000000000000000000000000000000007b
    ```

    **Set operator approval:**

    ```bash theme={"dark"}
    seid q evm erc721-payload setApprovalForAll 0xdEAD000000000000000042069420694206942069 true
    ```

    **Output:**

    ```
    a22cb465000000000000000000000000dead0000000000000000420694206942069420690000000000000000000000000000000000000000000000000000000000000001
    ```

    <Info>
      **Supported methods:**

      * `approve [spender] [tokenId]`
      * `transferFrom [from] [to] [tokenId]`
      * `setApprovalForAll [operator] [true|false]`
    </Info>
  </Tab>

  <Tab title="ERC1155">
    ### ERC1155 Payload Generation

    ```bash theme={"dark"}
    seid q evm erc1155-payload [method] [arguments...]
    ```

    **Safe transfer:**

    ```bash theme={"dark"}
    seid q evm erc1155-payload safeTransferFrom 0xDa52B9E673d1f48FcD9916b3F606A136a8eA5e55 0xdEAD000000000000000042069420694206942069 123 5 0x
    ```

    **Output:**

    ```
    f242432a000000000000000000000000da52b9e673d1f48fcd9916b3f606a136a8ea5e55000000000000000000000000dead000000000000000042069420694206942069000000000000000000000000000000000000000000000000000000000000007b000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000023078000000000000000000000000000000000000000000000000000000000000
    ```

    **Safe batch transfer:**

    ```bash theme={"dark"}
    seid q evm erc1155-payload safeBatchTransferFrom 0xDa52B9E673d1f48FcD9916b3F606A136a8eA5e55 0xdEAD000000000000000042069420694206942069 "[123,456]" "[5,10]" 0x
    ```

    **Set operator approval:**

    ```bash theme={"dark"}
    seid q evm erc1155-payload setApprovalForAll 0xdEAD000000000000000042069420694206942069 true
    ```

    <Info>
      **Supported methods:**

      * `safeTransferFrom [from] [to] [tokenId] [amount] [data]`
      * `safeBatchTransferFrom [from] [to] [tokenIds] [amounts] [data]`
      * `setApprovalForAll [operator] [true|false]`

      For batch operations, pass arrays as quoted bracketed strings: `"[123,456]"`. The trailing `data` field is a hex string (use `0x` for empty).
    </Info>
  </Tab>

  <Tab title="Custom ABI">
    ### Custom ABI Payload Generation

    Encode a call against any contract by supplying its ABI:

    ```bash theme={"dark"}
    seid q evm payload [abi-filepath] [method] [arguments...]
    ```

    **Example:**

    ```bash theme={"dark"}
    seid q evm payload ./MyContract.json myMethod arg1 arg2
    ```

    <Info>
      The ABI file must be a JSON array of function definitions, in the same shape Hardhat/Foundry emit (the `abi` field of an artifact, not the whole artifact).
    </Info>
  </Tab>
</Tabs>

## Pointer System

Pointers bridge the EVM and CosmWasm sides of Sei: a CW20 can be exposed as an ERC20 (via an EVM pointer at a `0x` address) and an ERC20 can be exposed as a CW20 (via a CW pointer at a `sei1…` address). The same applies to NFTs (CW721/ERC721) and multi-token contracts (CW1155/ERC1155).

## Transaction Lookup

### Query Transaction by Hash

Equivalent to `eth_getTransactionByHash`:

```bash theme={"dark"}
seid q evm tx [hash] --evm-rpc [EVM RPC endpoint]
```

**Example:**

```bash theme={"dark"}
seid q evm tx 0x828c91592453fe7c5bf743204495a35bf02b67b579b8f59ee7eea8af031d7c14 \
  --evm-rpc https://evm-rpc.sei-apis.com
```

**Output:**

```json theme={"dark"}
{
  "blockHash": "0x5620c15afd9a1d0ab19d7560043df6e038d731c6205974dca7a55900071e3864",
  "blockNumber": "0xc5e1386",
  "from": "0xda52b9e673d1f48fcd9916b3f606a136a8ea5e55",
  "gas": "0x493e0",
  "gasPrice": "0xe1614bd00",
  "maxFeePerGas": "0xe1614bd00",
  "maxPriorityFeePerGas": "0xe1614bd00",
  "hash": "0x828c91592453fe7c5bf743204495a35bf02b67b579b8f59ee7eea8af031d7c14",
  "input": "0x9cab5684...",
  "nonce": "0x0",
  "to": "0x7507454444fa193d39f1392076bc784b77a7a8ff",
  "transactionIndex": "0x0",
  "value": "0x0",
  "type": "0x2",
  "accessList": [],
  "chainId": "0x531",
  "v": "0x0",
  "r": "0x468ac709b74e666834bcc740e5156e019fd0ba40cff7f8a59a46f08bff56eb2b",
  "s": "0x3496458ec06b57315721cf5e6be810b9548744a5dafab1739b8fdcff23939939",
  "yParity": "0x0"
}
```

<Info>
  This is the only `seid q evm` command that takes `--evm-rpc` (an **EVM JSON-RPC** endpoint, typically port 8545) instead of `--node` (a Cosmos RPC). The default if you omit the flag is `http://0.0.0.0:8545`, which only works if you're running a local node. See [RPC endpoints](/evm/networks) for hosted EVM RPCs.
</Info>

## Common Use Cases

### Check Token Balance and Info

```bash theme={"dark"}
# Token metadata
seid q evm erc20 0xtoken... symbol
seid q evm erc20 0xtoken... decimals

# Balance (raw integer, in smallest unit)
seid q evm erc20 0xtoken... balanceOf 0xuser...
```

### Prepare and Send a Transaction

```bash theme={"dark"}
# 1. Encode the calldata
PAYLOAD=$(seid q evm erc20-payload transfer 0xrecipient... 1000000000000000000)

# 2. Send via seid
seid tx evm call-contract 0xtoken... $PAYLOAD --from mykey
```
