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())));
    }
}
6 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
Can't import ./Owned.sol on Remix
Create ERC20 with burn function on Remix
Where is ERC20Mintable.sol in OpenZeppelin Contracts 3.0?
Help creating an ERC20 token using Remix
Truffle Box Tutorial Token on Git Hub Error
ERC20 shows pragma error on Remix
Unable to mint ERC20 token
Using ERC20 transferFrom on Remix
Importing OpenZeppelin on Remix
Create ERC20 social token for online community
Define parameters in ERC20
Is there a simple ERC20 token and test contract example?
Set ERC20 token supply to 1 or less?
Introduce yourself here!
ERC20 token not displaying Metadata or Total supply
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
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
Developer wanted to help me understand how to use OpenZeppelin smart contracts/functions
Unable to import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol" on Remix

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).