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())));
    }
}
11 Likes

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??

1 Like

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

hello sir,

How to change token symbol

Hi, welcome! :wave:

you can share your source code, and then I can have a look.

Hi.
Thank you for your efforts.
I just created a Token following this instruction, but I can't verify that. I get this error:

Error! Unable to locate Contract Code at 0x256279455f3301a0a28bec6cde548e26ec70be7dIs this a valid Contract Address?

Another issue is when I deploy I get an orange box with this text inside:

contracts/Token.sol: Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: " to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.

Please guide me.
Thank you.

hello can you please give me inputs about importing openzeppelin conrtacts in remix? i saw you in this video, but the link provided in the youtube has gone missing. hope you can help. please. thank you! and God Bless!

copy openzeppelin contracts link you want to use, after that go to Remix and in home section you can see Load From , choose github and paste the link you copy and it will automatically import the file