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

# 03 messages

# Messages

In this section we describe the processing of the `erc20` module messages and the corresponding updates to the state.

### Create Token Pair: `MsgCreateTokenPair`

Creates an association between existing bank denom and new or existing ERC20 smart contract.
If ERC20 address is empty, new ERC20 smart contract will be instantiated. Not all bank denoms are supported.

Validation rules:

* for tokenfactory denoms, only the denom admin or the governance authority can create a token pair
* for peggy and IBC denoms, anyone can create a token pair, and the ERC20 address must be empty

```go theme={null}
type MsgCreateTokenPair struct {
	Sender    string   
	TokenPair TokenPair
}

type TokenPair struct {
	BankDenom    string
	Erc20Address string
}
```

**State Modifications:**

* Validation checks:
  * No token pair already exists for the bank denom or for the ERC20 address
  * Provided bank denom exists and has nonzero supply, otherwise `ErrUnknownBankDenom`
  * Sender has permission to create a token pair for this denom (for a tokenfactory denom, the denom admin or the governance authority)
  * If an ERC20 address is provided:
    * check that the account exists and holds contract code
    * check that the derived `erc20:0x...` denom has neither circulating supply nor bank metadata, otherwise `ErrExistingERC20DenomSupply`
    * check that the contract is an ERC20 by invoking its `symbol()` method under a 300,000 gas cap
* Create the association depending on the bank denom type:
  * tokenfactory denom:
    * read the permissions namespace, if one exists, and check whether the MINT, BURN or SUPER\_BURN policy is disabled
    * if any of the three is disabled, instantiate a new `FixedSupplyBankERC20` and reject any provided ERC20 address
    * otherwise, if no ERC20 address is provided, instantiate a new `MintBurnBankERC20` owned by the message sender, or use the provided address
    * store the association
  * IBC and peggy denoms:
    * instantiate new `FixedSupplyBankERC20` smart contract
    * store the association

> [!NOTE]
>
> The `ErrExistingERC20DenomSupply` check covers **supply or metadata**, despite what the error name suggests. A custom contract whose constructor called `setMetadata` has already written `erc20:0x...` metadata and will be rejected even with zero supply. See
> [ERC20 Module](https://docs.injective.network/developers-evm/erc20-module.md) for the full set of requirements on custom contracts.

### Delete Token Pair: `MsgDeleteTokenPair`

Only authority can remove token pairs for now, by providing bank denom of the pair.

```go theme={null}
type MsgDeleteTokenPair struct {
	Sender    string
	BankDenom string
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.