Deploy a simple ERC20 token in Remix

I have been using Remix for really quick contracts rather than spinning up a Truffle or a Hardhat project (both of which are still pretty quick to do).

Remix supports importing via GitHub. See the documentation for details:
https://remix-ide.readthedocs.io/en/latest/import.html

This makes it easy to import OpenZeppelin Contracts.

:warning: Note: You should only use code published in an official release of OpenZeppelin Contracts, the latest release is 3.4. When importing via GitHub on Remix you can specify the release tag, (otherwise you will get the latest code in the master branch). The example below imports v3.4.0.

An example ERC20 token:

Token.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.4.0-solc-0.7/contracts/token/ERC20/ERC20.sol";

contract Token is ERC20 {

    constructor () ERC20("Token", "TKN") {
        _mint(msg.sender, 1000000 * (10 ** uint256(decimals())));
    }
}
13 Likes
No initialSupply being added to contract
How can I make an ERC20 both Burnable and Detailed?
Can't import OpenZeppelin Contracts library in Remix
How to verify a contract deployed using Remix importing OpenZeppelin via GitHub?
It is time for Zeppelin Solidity - Remix integration
Create ERC20 with burn function on Remix
Can't import ./Owned.sol on Remix
Importing OpenZeppelin on Remix
Developer wanted to help me understand how to use OpenZeppelin smart contracts/functions
Where is ERC20Mintable.sol in OpenZeppelin Contracts 3.0?
Cannot transfer tokens from contract to wallet
Help creating an ERC20 token using Remix
Unable to mint ERC20 token
Define parameters in ERC20
Burn token
Why does my balance still show "0"?
Unable to import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol" on Remix
Create ERC20 social token for online community
Using ERC20 transferFrom on Remix
ERC20 shows pragma error on Remix
Truffle Box Tutorial Token on Git Hub Error
Is there a simple ERC20 token and test contract example?
Error on deploy: contract may be abstract, not implement an abstract parent’s methods completely or not invoke an inherited contract’s constructor correctly
Set ERC20 token supply to 1 or less?
Introduce yourself here!
ERC20 token not displaying Metadata or Total supply
Is it safe to publish to IPFS when using Remix?
Transfer method is not working, I am getting a returned error - "Gas Required"
TypeError: Derived contract must override function "_beforeTokenTransfer"
Convert erc20 to erc777?
Cannot transfer tokens from contract to wallet
How to verify ERC20 deployed via Remix on Etherscan?
Compilation error in OpenZeppelin Contracts on Windows
Transfer method is not working, I am getting a returned error - "Gas Required"
Request for ERC721 token

2 posts were split to a new topic: Issue deploying ERC20 token to Ropsten using Remix

A post was split to a new topic: Import OpenZeppelin Contracts from GitHub in Remix?

We can Create an ERC20 using Remix, without writing Solidity

4 posts were split to a new topic: How to verify simple ERC20 deployed via Remix on Etherscan?

Thanks for this, Andrew @abcoathup . Just to confirm for others as I have tested it, this contract creates an ERC-20 with fixed supply, 18 as decimal input with your chosen token symbol and name. @abcoathup can you confirm that this is fixed supply? I think for burn / mint it would need to invoke a more complex smart contract.

1 Like

I think yes, cause the type of function _mint() is internal and it only is called in the constructor .

If you want mint/burn in your token contract, you can write a contract derives from ERC20, so you can write function contains _mint() and _burn() to achieve, such as:

function mint(address to, uint256 amount) public onlyOwner {
    _mint(to, amount);
}
1 Like

Hi @Link,

Welcome to the community :wave:

The example is of a fixed supply ERC20, with 18 decimals and hardcoded name and symbol.

As @skyge suggested, for a mintable, pausable contract you could create your own extending from the OpenZeppelin Contracts ERC20 implementation and Access Control.

You can use the Preset contract as a guide.
To get familiar with the ERC20PresetMinterPauser you can use the following tutorial: Create an ERC20 using Remix, without writing Solidity

1 Like

A post was split to a new topic: Pending contract deployment

Hello, where can I find which release is the latest for an OpenZepplin contract? Thanks!

1 Like

Hi @jsmellz,

The latest release is OpenZeppelin Contracts 3.4:

I have updated the example above to use Solidity 0.7 and OpenZeppelin Contracts 3.4 (Solidity 0.7 version).

1 Like

4 posts were split to a new topic: How to create ERC20 without initial supply

Should the imported code version (0.8.0) the written code version (0.8.0) and the Remix compiler version (0.8.0) all be the same?

Trying to verify my token on PolygonScan 0x3d1a45b45f7d2476ca093b02179daeffd6a95213.

I did a simple contract in remix the other day using the import function but when you do that it doesnt show the whole contract. I successfully deployed the token but Now I would like to verify it on Polygonscan.

This is what I originally deployed in Solidity

pragma solidity ^0.7.0;

import “https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.4.0-solc-0.7/contracts/token/ERC20/ERC20.sol”;

contract Token is ERC20 {

constructor () ERC20("Digital Asset Universe", "DAU") {
    _mint(msg.sender, 1000000 * (10 ** uint256(decimals())));
}

I didnt change anything else. I cant remember if the pragma was a different version but I dont think so. Is there anyway to find this whole source code to verify it??

Hi, welcome! :wave:

I have not tried to verify contracts on the PolygonScan, but you can have a look at this tutorial: Verify ERC20 token on Etherscan that was deployed through Remix: Step by Step Guide

1 Like