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

# Deploying ERC-20 Token

In this guide, you will learn how to deploy an **ERC-20** token smart contract on AGUNG using **Remix**, a browser-based Solidity development environment. This guide uses a boilerplate ERC-20 contract, and you will customize key parameters such as:

* `Token Name`
* `Symbol`
* `Decimals`
* `Total Supply`

By the end, you'll have your very own **ERC-20** token deployed on our AGUNG testnet.

## Prerequisites

* **Basic understanding** of blockchain and ERC-20 tokens.
* **Installed MetaMask** browser extension with AGUNG network set-up already.
* **Familiarity** with Remix IDE ([https://remix.ethereum.org/](https://remix.ethereum.org/)).
* Using the **OpenZeppelin library** for the ERC-20 boilerplate.
* A **wallet** with AGUNG network PEAQ for gas fees.

## Instructions

### 1. Open Remix IDE

* Visit Remix and create a new workspace.
* Click on **"File Explorers"** and select **"Create a New File"**.
* Name the file: `MyERC20Token.sol`.
  <img src="https://mintcdn.com/peaq/bfUMfJGiNN2sOYvn/assets/img/erc-20-1.png?fit=max&auto=format&n=bfUMfJGiNN2sOYvn&q=85&s=07df7e96d250f7dfb31d1b634161f437" alt="erc-20-1" width="2554" height="1381" data-path="assets/img/erc-20-1.png" />

### 2. ERC-20 Code

Copy and paste the following boilerplate ERC-20 smart contract code into your newly created file:

```solidity theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

// Import OpenZeppelin's ERC-20 implementation
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract MyToken is ERC20 { // Here we are declaring the contract & inheriting ERC20
    constructor(uint256 initialSupply) ERC20("MyToken", "MTK") { 
        _mint(msg.sender, initialSupply * (10 ** uint256(decimals())));
    }
}
```

### 3. Modify Token Details

Update the following placeholders in the code:

* **Token Name**: Replace `"MyToken"` with your token's name (e.g., `"ExampleToken"`).
* **Symbol**: Replace `"MTK"` with a short symbol (e.g., `"EXT"`).
* **Total Supply**: The `initialSupply` (input during deployment) defines the number of tokens created.

**Example**: For a 1,000,000 total supply with 18 decimals, input **1,000,000** during contract deployment (Step 5).

<img src="https://mintcdn.com/peaq/bfUMfJGiNN2sOYvn/assets/img/erc-20-2.png?fit=max&auto=format&n=bfUMfJGiNN2sOYvn&q=85&s=72505b08ccb1ee55daf85c420f265a15" alt="erc-20-2" width="2554" height="1372" data-path="assets/img/erc-20-2.png" />

### 4. Compile the Contract

In the **Solidity Compile** tab:

* Select the Solidity version (e.g., `0.8.20+commit.a1b79de6`).
* Click **Compile MyERC20Token.sol**.
* Ensure there are no errors.
  <img src="https://mintcdn.com/peaq/bfUMfJGiNN2sOYvn/assets/img/erc-20-3.png?fit=max&auto=format&n=bfUMfJGiNN2sOYvn&q=85&s=35461693d922d910c566fb47cfb2df66" alt="erc-20-3" width="535" height="1341" data-path="assets/img/erc-20-3.png" />

### 5. Deploy the Contract

* Go to the **Deploy & Run Transactions** tab in Remix.
* Select **Injected Web3** as the environment to connect MetaMask.
* Choose your **testnet wallet account** in MetaMask.
* In the constructor field, enter your desired **Total Supply** (e.g., `1000000` for 1 Million).
* Click **Transact** under **Deploy** and confirm the transaction in MetaMask.
  <img src="https://mintcdn.com/peaq/bfUMfJGiNN2sOYvn/assets/img/erc-20-4.png?fit=max&auto=format&n=bfUMfJGiNN2sOYvn&q=85&s=eea66650483bc8c04d20163c25a79f37" alt="erc-20-4" width="519" height="967" data-path="assets/img/erc-20-4.png" />

### 6. Verify Deployment

<img src="https://mintcdn.com/peaq/bfUMfJGiNN2sOYvn/assets/img/erc-20-5.png?fit=max&auto=format&n=bfUMfJGiNN2sOYvn&q=85&s=344094a2786eb6b102e0b9368f5e602a" alt="erc-20-5" width="2026" height="279" data-path="assets/img/erc-20-5.png" />

Remix IDE's console logging a successful execution of the transaction to deploy the smart contract ExampleToken (MyERC20Token.sol) to AGUNG network.

* After deployment, your contract will appear under **Deployed Contracts** in Remix.
* Use the **Read Functions (blue)** to verify details like `name()`, `symbol()`, and `totalSupply()`.
* You can also **check your token balance** using the `balanceOf()` function by inputting your wallet address.
  <img src="https://mintcdn.com/peaq/bfUMfJGiNN2sOYvn/assets/img/erc-20-6.png?fit=max&auto=format&n=bfUMfJGiNN2sOYvn&q=85&s=2cfa06c301c2a14e7739f4bc4865186b" alt="erc-20-6" width="565" height="1027" data-path="assets/img/erc-20-6.png" />

## Summary

🎉 Congratulations! You have successfully deployed your first **ERC-20** token on our AGUNG testnet. You can now view your contract on a block explorer (like Subscan)
and interact with it through the interface in Remix. For further enhancements to your ERC-20 token, explore features like **minting**, **burning**, or **transferring tokens**.
