Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
---
title: Creating Custom ERC20s
title: Custom ERC20s
---

[Tutorial GitHub Repository](https://github.com/initia-labs/examples/tree/main/evm/initia-custom-erc20)
To create custom ERC20s, you can inherit and extend the
[InitiaERC20](/resources/developer/contract-references/evm/initia-erc20)
contract.

## Prerequisites

Expand All @@ -22,7 +24,7 @@ mkdir initia-erc20
cd initia-erc20
```

Next, we will initialize a new Foundry project side that directory.
Next, we will initialize a new Foundry project inside that directory.

```sh
forge init
Expand All @@ -46,26 +48,27 @@ mv src/Counter.sol src/NewInitiaERC20.sol
```

We then update the contract from the template to be our custom ERC20 contract.
Start by importing the `InitiaCustomERC20` contract from the
`@initia/initia-evm-contracts` package.
Start by importing the `InitiaERC20` contract from the
[initia-evm-contracts](https://github.com/initia-labs/initia-evm-contracts)
package.

```solidity src/NewInitiaERC20.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import "initia-evm-contracts/src/InitiaCustomERC20.sol";
import "initia-evm-contracts/src/InitiaERC20.sol";
```

Next, we need to extend the `InitiaCustomERC20` contract and add the constructor
to initialize the contract with the name, symbol, and decimals of our custom
ERC20. For this tutorial, we will simply customize the base contract by adding a
logic to mint tokens to the contract deployer. during deployment.
Next, we need to extend the `InitiaERC20` contract and add the constructor to
initialize the contract with the name, symbol, and decimals of our custom ERC20.
For this tutorial, we will simply customize the base contract by adding a logic
to mint tokens to the contract deployer during deployment.

```solidity src/NewInitiaERC20.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import "initia-evm-contracts/src/InitiaCustomERC20.sol";
import "initia-evm-contracts/src/InitiaERC20.sol";

/**
* @title NewInitiaERC20
Expand Down Expand Up @@ -98,7 +101,7 @@ mv test/Counter.t.sol test/NewInitiaERC20.t.sol
mv script/Counter.s.sol script/NewInitiaERC20.s.sol
```

We will now replace the contents of the `NewInitiaERC20.t.sol` file with
We will now replace the contents of the `NewInitiaERC20.t.sol` file with the
following placeholder content.

```solidity test/NewInitiaERC20.t.sol
Expand All @@ -113,7 +116,7 @@ contract NewInitiaERC20Test is Test {
}
```

And replace the contents of the `NewInitiaERC20.s.sol` file with following
And replace the contents of the `NewInitiaERC20.s.sol` file with the following
placeholder content.

```solidity script/NewInitiaERC20.s.sol
Expand Down Expand Up @@ -156,7 +159,7 @@ Compiler run successful!
## Deploying the Contract

Now that our contract is compiled and ready, we can deploy it to the MiniEVM. To
accomplish this, we will use Foundry's `forge create` command
accomplish this, we will use Foundry's `forge create` command.

<Warning>
**Security Note:** In this tutorial we export a private key directly in the
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
---
title: Creating Standard ERC20s via ERC20Factory
title: Using ERC20Factory
---

[Tutorial GitHub Repository](https://github.com/initia-labs/examples/tree/main/evm/erc20-factory)

For developers looking to create standard ERC20 tokens on EVM rollups, we
recommend using the
[ERC20Factory](/resources/developer/contract-references/evm/erc20-factory)
contract.
To create standard ERC20s, you can use the
[ERC20Factory](/resources/developer/contract-references/evm/erc20-factory)'s
`createErc20` function. Tokens created via this method are fully compatible with
the chain and Initia's core products by default.

## Project Setup

Expand Down Expand Up @@ -57,15 +55,15 @@ touch .env

This file will store your private environment variables, such as your wallet's
private key and the deployed ERC20Factory contract address. These values are
required for signing transactions and interacting with the MiniEVM.
required for signing transactions and interacting with the chain's EVM module.

The `ERC20Factory` contract is automatically deployed on all MiniEVM rollups as
The `ERC20Factory` contract is automatically deployed on all EVM appchains as
part of the chain’s bootstrapping process.

To retrieve the deployed factory address, query
`{ROLLUP_REST_URL}/minievm/evm/v1/contracts/erc20_factory`.
`{APPCHAIN_REST_URL}/evm/v1/contracts/erc20_factory`.

`{ROLLUP_REST_URL}` refers to the REST endpoint of the rollup you are
`{APPCHAIN_REST_URL}` refers to the REST endpoint of the chain you are
interacting with.

Example:
Expand Down Expand Up @@ -166,7 +164,7 @@ Load the environment variables:
<Note>
You can also find factory addresses on the
[Networks](/resources/developer/initia-l1) page or by calling the
`/minievm/evm/v1/contracts/erc20_factory` endpoint on any MiniEVM rollup.
`/minievm/evm/v1/contracts/erc20_factory` endpoint on any EVM appchain.
</Note>

```js
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
title: InitiaERC20
---

InitiaERC20 is Initia's native token standard for EVM appchains. It extends the
ERC20 standard with additional modifiers and functions required for full
compatibility with the Cosmos SDK and Initia's core products. See the
[InitiaERC20 contract reference](/resources/developer/contract-references/evm/initia-erc20)
for implementation details.

<Warning>
**Do not deploy or use normal ERC20 contracts** on Initia EVM appchains.
Tokens that do not follow the InitiaERC20 standard will not display correctly
in Initia's products and will have limited transfer and bridging
functionalities.
</Warning>

Developers looking to create and deploy ERC20s on EVM appchains have two
options:

1. For creating standard ERC20 tokens, use the
[ERC20Factory](/resources/developer/contract-references/evm/erc20-factory)
contract (which deploys the
[ERC20](/resources/developer/contract-references/evm/erc20) contract).
2. For creating ERC20 tokens with custom functionality, inherit and extend the
[InitiaERC20](/resources/developer/contract-references/evm/initia-erc20)
contract.

<Note>
For Initia's products to correctly display your token's symbol, logo, and
other details, it must still be added to the [Initia
Registry](/developers/developer-guides/integrating-initia-apps/registry/introduction).
</Note>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Update Fee with ERC20 Token
title: Updating the Fee Token
---

## Prerequisites
Expand All @@ -17,7 +17,8 @@ Fee Token as an ERC20 token.
Use validator (admin) account to update the chain parameter.

<Warning>
The deployed ERC20 token must inherit the `InitiaERC20` contract.
The deployed ERC20 token must follow the InitiaERC20 standard—i.e. use the
`ERC20` contract (factory-created) or inherit from `InitiaERC20` (custom).
</Warning>

```ts
Expand Down
6 changes: 3 additions & 3 deletions docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@
"developers/developer-guides/vm-specific-tutorials/evm/cosmos-coin-to-erc20",
{
"group": "Creating ERC20s",
"icon": "file-code",
"pages": [
"developers/developer-guides/vm-specific-tutorials/evm/creating-erc20s/initiaerc20",
"developers/developer-guides/vm-specific-tutorials/evm/creating-erc20s/creating-standard-erc20s",
"developers/developer-guides/vm-specific-tutorials/evm/creating-erc20s/creating-custom-erc20s"
]
Expand Down Expand Up @@ -522,9 +522,9 @@
"resources/developer/contract-references/evm/cosmos",
"resources/developer/contract-references/evm/erc20-acl",
"resources/developer/contract-references/evm/erc20-registry",
"resources/developer/contract-references/evm/erc20",
"resources/developer/contract-references/evm/initia-erc20",
"resources/developer/contract-references/evm/erc20-factory",
"resources/developer/contract-references/evm/initia-custom-erc20"
"resources/developer/contract-references/evm/erc20-factory"
]
}
]
Expand Down
8 changes: 4 additions & 4 deletions resources/developer/contract-references/evm/erc20-factory.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ GitHub:

## Overview

The `ERC20Factory` contract is designed to create new InitiaERC20 tokens and
register them with the MiniEVM's ERC20Registry.
The `ERC20Factory` contract is designed to create new ERC20 tokens and register
them with the MiniEVM's ERC20Registry.

## Imports

- [InitiaERC20.sol](/resources/developer/contract-references/evm/initia-erc20):
Contains the implementation of the ERC20 token.
- [ERC20.sol](/resources/developer/contract-references/evm/erc20): Contains the
implementation of the factory-created ERC20 token.
- [ERC20Registry.sol](/resources/developer/contract-references/evm/erc20-registry):
Contains the implementation of the ERC20 registry.

Expand Down
38 changes: 38 additions & 0 deletions resources/developer/contract-references/evm/erc20.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
title: ERC20
---

GitHub:
[ERC20](https://github.com/initia-labs/initia-evm-contracts/blob/main/src/ERC20.sol)

## Overview

The `ERC20` contract is used by the
[ERC20Factory](/resources/developer/contract-references/evm/erc20-factory) to
create standard tokens. It does not self-register in the constructor—the factory
calls `register_erc20_from_factory` after deployment.

For custom ERC20 tokens with additional logic, use
[InitiaERC20](/resources/developer/contract-references/evm/initia-erc20)
instead.

## Key Features

- **metadataSealed**: Prevents metadata changes after sealing. Set via
`updateMetadata` by authority.
- **updateMetadata**: One-time metadata update by authority (gov).
- **sudoMint / sudoBurn**: Chain signer operations for bridging and module
interactions.

## Constructor

```solidity
constructor(string memory _name, string memory _symbol, uint8 _decimals, bool _metadataSealed)
```

| Name | Type | Description |
| ----------------- | --------------- | ------------------------------------------------- |
| `_name` | `string memory` | The name of the token. |
| `_symbol` | `string memory` | The symbol of the token. |
| `_decimals` | `uint8` | The number of decimals. |
| `_metadataSealed` | `bool` | If true, metadata cannot be updated by authority. |
Loading
Loading