# Write ERC-20 Contract

It is possible to proceed an ERC-20 contract deployment test using Remix.

{% hint style="danger" %}
Caution

Once deployed contracts cannot be modified or deleted. \
Please write and deploy the necessary information in the code.
{% endhint %}

Let's proceed with the contract deployment process in the order below.

* Step 1 : Access the Remix and Create a file
* Step 2 : Write ERC-20 Contract
* Step 3 : Move to SOLIDITY COMPILER tap, Set the version, and Compile
* Step 4 : Set DEPLOY & RUN TRANSACTIONS
* Step 5 : Set Gas fee and Sign at MetaMask&#x20;

{% hint style="info" %}
All examples are based on WEMIX3.0 Testnet.
{% endhint %}

### Step 1 : Access the Remix and Create a file

Go to <https://remix.ethereum.org>.&#x20;

<figure><img src="/files/OQm7W5YTaanwlaMAettJ" alt=""><figcaption><p>Remix Initial View</p></figcaption></figure>

Storage.sol, Owner.sol, and Ballot.sol are shown in the contracts directory. To create a new smart contract, select them to erase it and create a new file.

The figure below shows an example of creating `WEMIX_ERC20.sol` file in the contracts directory.

<figure><img src="/files/2gto5WoU0okQQvJ69Nxc" alt=""><figcaption><p>Create a File</p></figcaption></figure>

### Step 2 : Write ERC-20 Contract&#x20;

You can create the following ERC-20 contracts:

```null
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol";

contract MyToken is ERC20 {
    constructor(string memory name, string memory symbol) ERC20(name, symbol) {
        // Mint 100 tokens to msg.sender
        // Similar to how
        // 1 dollar = 100 cents
        // 1 token = 1 * (10 ** decimals)
        _mint(msg.sender, 99999999 * 10**uint(decimals()));
    }
}
```

The figure below is an example of the above code in the `WEMIX_ERC20.sol.`

<figure><img src="/files/9KVvxuhHiUDaZnaEQNWR" alt=""><figcaption><p>Example Code</p></figcaption></figure>

### Step 3 : Move to SOLIDITY COMPILER tap, Set Version, and Compile

Once the code is written, compile after selecting the correct compiler version on the Solidity Compiler screen.

The compiler version of the example code provided is 0.8.19.

<figure><img src="/files/EMN4l3chG7oFSksY5nzY" alt=""><figcaption><p>Compile Example Code</p></figcaption></figure>

### Step 4 : Set DEPLOY & RUN TRANSACTIONS

On the Deploy & Run Transactions screen, select the environment to deploy smart contracts to test.&#x20;

The figure below shows an example of deploying to WEMIX3.0 Testnet using the 'Injected Provider - Metamask' provided by Remix.

<figure><img src="/files/6R1Tt0FbneGjJA5CfcNE" alt=""><figcaption><p>Setting Delpoying Envrionment</p></figcaption></figure>

If ENVIRONEMNT is selected as 'Injected Provider - MetaMask', it is connected to MetaMask, which requires the network to be 'WEMIX\_Testnet' connection.\
\
For more information about MetaMask connection, see[ Use MetaMask](/en/quick-start/account/use-metamask.md).

<figure><img src="/files/c9ceYTPf4dDZdecvBBYb" alt=""><figcaption><p>Connect MetaMask &#x26; WEMIX_Testnet</p></figcaption></figure>

In CONTRACT, find MyToken and type the name and symbol you want in 'string name' and 'string symbol' in the input field next to Deploy.

The figure below is an example of designating 'WTOKEN', 'WT'.

<figure><img src="/files/7ZH7zMfDEqddDnsKHclf" alt=""><figcaption><p>Setting Tokne Name &#x26; Symbol</p></figcaption></figure>

### **Step 5 : Set Gas Fee and Sign at MetaMask**

After setting on the Deploy & Run Transactions, if you select 'deploy' button, the MetaMask pop-up appears. The screen showing 'Gas Fee' based on Ethereum will be displayed as shown below.

WEMIX has a different fee policy than Ethereum, so press the 'Site suggested' button to change t the Gas Fee.

<figure><img src="/files/OqTtFUTDXgmt2LS1jKZ8" alt=""><figcaption><p>MetaMask, default 'Gas fee'</p></figcaption></figure>

Selecting 'Advanced' on the screen below allows the user to set 'Max priority fee (GWEI)' and 'Max fee (GWEI)' manually.

<figure><img src="/files/4w5Cd3eGvSqd5LK3nWHY" alt=""><figcaption><p>MetaMask default 'Gas Fee' setting entry screen</p></figcaption></figure>

<figure><img src="/files/YTbgUBxb0JAdb6rtzzFJ" alt=""><figcaption><p>'Gas Fee' setting</p></figcaption></figure>

Currently, WEMIX is using a fixed 'Max priority fee (GWEI)' and the value is 100.&#x20;

Max fee is a user-defined value and the minimum value is MaxPriorityFee+BASE\_FEE.&#x20;

BASE\_FEE in WEMIX is variable according to EIP-1559. Therefore, for a transaction to be successfully created, it is recommended to set it as follows.

1. Max base fee (GWEI) = 101
2. Max priority fee (GWEI) = 100&#x20;

Complete the Fee setup in the figure above and select 'Save' to be ready for deployment as shown below.

<figure><img src="/files/U8faZvDhEOAt1aWjTkyw" alt=""><figcaption><p>Confirm Example ERC-20 Deployment</p></figcaption></figure>

Select 'Confirm' in the figure above to proceed with the contract deployment.&#x20;

If a green check mark appears at the bottom of the Remix screen as shown below, the deployment is completed normally.

<figure><img src="/files/N93ONfP0uEec41xwYfZ4" alt=""><figcaption><p>Complete Example ERC-20 Deployment</p></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wemix.com/en/tutorial/erc-20-token/write-erc-20-contract.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
