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.

Before deploying a pointer, you should first check if a pointer for the token/contract you wish to deploy already exists by running the following query:

seid q evm pointer $TYPE $POINTEE --evm-rpc=https://evm-rpc.arctic-1.seinetwork.io/

Parameters

  • TYPE: One of "ERC20", "ERC721", "NATIVE", "CW20", and "CW721". Note that type refers to the underlying token type, so a type of "ERC20" refers to a CosmWasm pointer pointing to an ERC-20 token.
  • POINTEE: the underlying token denom literal in the case of "NATIVE" type, or the underlying token contract address for all other types

Flags

  • --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 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 call-precompile pointer addNativePointer $DENOM --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.

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 call-precompile pointer addCW20Pointer $CW20_TOKEN_ADDRESS --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.

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 call-precompile pointer addCW721Pointer $CW721_TOKEN_ADDRESS --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.

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 evm register-pointer ERC20 $ERC20_TOKEN_ADDRESS --from=$SENDER --chain-id=arctic-1 --broadcast-mode=block --gas=250000 --fees=25000usei --node=https://rpc-arctic-1.sei-apis.com/

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.
  • --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.

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 evm register-pointer ERC20 $ERC721_TOKEN_ADDRESS --from=$SENDER --chain-id=arctic-1 --broadcast-mode=block --gas=250000 --fees=25000usei --node=https://rpc-arctic-1.sei-apis.com/

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.
  • --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.

To check out the source code, please visit our GitHub page (opens in a new tab).