EVM <> Wasm Interoperability
Pointer Contracts

Pointer Contracts

Pointer Contracts enable tokens to be used interoperably in both EVM and CosmWasm environments.

Why Pointer Contracts

Without Pointer Contracts

A world without pointer contracts

Wallets and clients typically only support a single execution environment. For example, EVM Wallets allow users to transfer and see balances of ERC-20 coins and ERC-721 NFTs. However, they are unable to directly interact with CW based contracts since these contracts:

  • Live within the CosmWasm Boundary
  • Do not implement the ERC-20 or ERC-721 token standard. (They implement CW-20 and CW-721 instead)

Likewise, CosmWasm based clients cannot directly recognize or interact with EVM based tokens and NFTs.

To solve this problem, Pointer Contracts will allow tokens deployed in one environment to be used and traded by wallets and dapps on the other environment.

With Pointer Contracts

With pointer contracts, all tokens can be accessed by wallets of either environment

For each token contract, a corresponding pointer contract can be deployed. This enables CW-20/CW-721 tokens to be treated as ERC-20/ERC-721 tokens by the EVM, and vice versa, enabling interoperability between both execution environments.

How it Works

A pointer contract serves as a wrapper around it's corresponding contract in the other environment Take the example below:

How it works

EVM Pointer contracts for CW-20 tokens and Native tokens

To represent both CW-20 and Native tokens, an ERC-20 Pointer contract can be deployed. While these contracts both point to different types of underlying tokens, they both implement the ERC-20 standard and can be treated as an ERC-20 token in the EVM environment. This allows EVM based wallets to interact with them.

Pointer contracts simply forward messages to their underlying contract. They do not store their own state or create any token. The destination contract or bank module remains the sole source of truth for token data.

In these examples, when the EVM pointer contract is called, the pointer contracts:

  • Translate the message sent to it to it's an equivalent message understood by the underlying CosmWasm contract/module.
  • Forwards the message to the correct destination.

Deploying a Pointer Contract

This section guides you through the process of deploying a Pointer Contract for various Sei token standards using the Seid CLI.

For an in-depth understanding of Sei token standards, click here.

Prerequisites

To deploy a Pointer Contract on devnet, you'll need the following setup:

  • Ensure you have the Sei CLI installed on your machine. If not, you can install it by following the installation guide.
  • Have your CW20 or ERC20 token details handy, as you'll need them to create the corresponding pointer token.

Deploying an EVM Pointer Contract

For Native Tokens

To deploy an ERC20 Pointer Contract that links to a tokenfactory or IBC token, you can use the following command:

seid tx evm deploy-erc20 $DENOM $NAME $SYMBOL $DECIMAL --from=$SENDER --evm-rpc=https://evm-rpc.arctic-1.seinetwork.io/

Parameters

  • DENOM: The denom of the token you want to create an ERC20 pointer for.
  • NAME: The name you want to assign to your ERC20 pointer token. This should match the name of the native token denom.
  • SYMBOL: The symbol for your ERC20 pointer token. This should match the symbol of the native token denom.
  • DECIMAL: The number of decimals for your ERC20 pointer token. This should match the decimals of the native token denom (usually 6).

Flags

  • --from: The Sei address from which the deployment transaction is sent. This address must have enough balance to cover transaction fees.
  • --evm-rpc: The endpoint URL for the EVM RPC interface of the Sei blockchain. This URL is used by the seid command to interact with the Sei EVM.

To learn more about the various command line arguments and flags, use the --help flag for any CLI commands. For example:

seid tx evm --help

For CW20 Tokens

To deploy an ERC20 Pointer Contract that links to a CW20 token, you can use the following command:

seid tx evm deploy-erccw20 $CW20_TOKEN_ADDRESS $NAME $SYMBOL --from=$SENDER --evm-rpc=https://evm-rpc.arctic-1.seinetwork.io/

Parameters

  • CW20_TOKEN_ADDRESS: The contract address of the CW20 token you want to create an ERC20 pointer for.
  • NAME: The alias to assign to your token. This should match the name of the underlying CW20 token.
  • SYMBOL: The symbol for your token. This should match the symbol of the underlying CW20 token.

Flags

  • --from: The Sei address from which the deployment transaction is sent. This address must have enough balance to cover transaction fees.
  • --evm-rpc: The endpoint URL for the EVM RPC interface of the Sei blockchain. This URL is used by the seid command to interact with the Sei EVM.

For CW721 Tokens

To deploy an ERC721 Pointer Contract that links to a CW721 NFT contract, you can use the following command:

seid tx evm deploy-erccw721 $CW721_TOKEN_ADDRESS $NAME $SYMBOL --from=$SENDER --evm-rpc=https://evm-rpc.arctic-1.seinetwork.io/

Parameters

  • CW721_TOKEN_ADDRESS: The contract address of the CW721 NFT you want to create an ERC721 pointer for.
  • NAME: The alias to assign to your token. This should match the name of the underlying CW721 NFT.
  • SYMBOL: The symbol for your token. This should match the symbol of the underlying CW721 NFT.

Flags

  • --from: The Sei address from which the deployment transaction is sent. This address must have enough balance to cover transaction fees.
  • --evm-rpc: The endpoint URL for the EVM RPC interface of the Sei blockchain. This URL is used by the seid command to interact with the Sei EVM.

Deploying a CW Pointer Contract

For ERC20 Tokens

To deploy an CW20 Pointer Contract that links to a ERC20 token, you can use the following command:

seid tx wasm instantiate 7 '{"erc20_address": "$ERC20_TOKEN_ADDRESS"}' --from=$SENDER --label=$LABEL --chain-id=arctic-1 --broadcast-mode=block --gas=250000 --fees=25000usei --node=https://rpc-arctic-1.sei-apis.com/ --no-admin

Parameters

  • ERC20_TOKEN_ADDRESS: The contract address of the ERC20 token you want to create an CW20 pointer for.

Flags

  • --from: The Sei address from which the deployment transaction is sent. This address must have enough balance to cover transaction fees.
  • --label: A name for the contract instance used to identify the contract.
  • --chain-id: Identifies the specific chain of the Sei network you're interacting with. arctic-1 refers to the Sei devnet.
  • --broadcast-mode: Determines how the transaction is broadcasted. Setting this to block means the transaction will wait to be included in a block before returning a response.
  • --gas: Specifies the maximum amount of gas that can be consumed by the transaction.
  • --fees: Indicates the transaction fee.
  • --node: Points to the specific Sei node RPC URL you're connecting to for transaction submission.
  • --no-admin: Specifies that the contract should not have an admin. This flag is used to indicate that the contract, once deployed, cannot be upgraded or migrated.

The CW20 Pointer Contract has a code ID of 7 on devnet, and it's pre-stored for easy use. To store this contract yourself or to check out the source code, please visit our GitHub page (opens in a new tab).

For ERC721 Tokens

To deploy an CW721 Pointer Contract that links to a ERC721 token, you can use the following command:

seid tx wasm instantiate 8 '{"erc721_address": "$ERC721_TOKEN_ADDRESS"}' --from=$SENDER --label=$LABEL --chain-id=arctic-1 --broadcast-mode=block --gas=250000 --fees=25000usei --node=https://rpc-arctic-1.sei-apis.com/ --no-admin

Parameters

  • ERC721_TOKEN_ADDRESS: The contract address of the ERC721 token you want to create an CW721 pointer for.

Flags

  • --from: The Sei address from which the deployment transaction is sent. This address must have enough balance to cover transaction fees.
  • --label: A name for the contract instance used to identify the contract.
  • --chain-id: Identifies the specific chain of the Sei network you're interacting with. arctic-1 refers to the Sei devnet.
  • --broadcast-mode: Determines how the transaction is broadcasted. Setting this to block means the transaction will wait to be included in a block before returning a response.
  • --gas: Specifies the maximum amount of gas that can be consumed by the transaction.
  • --fees: Indicates the transaction fee.
  • --node: Points to the specific Sei node RPC URL you're connecting to for transaction submission.
  • --no-admin: Specifies that the contract should not have an admin. This flag is used to indicate that the contract, once deployed, cannot be upgraded or migrated.

The CW721 Pointer Contract has a code ID of 8 on devnet, and it's pre-stored for easy use. To store this contract yourself or to check out the source code, please visit our GitHub page (opens in a new tab).