I am looking for an updated and stable standard ERC-20 smart contract template which will pass through Remix compilation (latest version) without errors. The template should preferably be easy to modify as well.

Could any of you guys please post a template or a link to a template somewhere?

Tested: Contacted OpenZeppelin already but have not yet found exactly what I'm looking for. The contract should ideally be clearly commented and easy to modify with some kind of "modify this" section for token amounts, name of token and so on. It would also be great if all of it goes into one file only.


1 Answer 1


This code works. It's from https://programtheblockchain.com/posts/2018/01/30/writing-an-erc20-token-contract/. The changes I made are:

  1. Change the pragma to match the latest Solidity compiler version.
  2. Change the constructor to use the constructor syntax.
  3. Added a comment to indicate the part of the code that specifies the token's name, symbol, decimals, and total supply. That's what you need to modify if you want different values.
pragma solidity 0.5.7;

contract SimpleERC20Token {
    // Track how many tokens are owned by each address.
    mapping (address => uint256) public balanceOf;

    // Modify this section
    string public name = "Simple ERC20 Token";
    string public symbol = "SET";
    uint8 public decimals = 18;
    uint256 public totalSupply = 1000000 * (uint256(10) ** decimals);

    event Transfer(address indexed from, address indexed to, uint256 value);

    constructor() public {
        // Initially assign all tokens to the contract's creator.
        balanceOf[msg.sender] = totalSupply;
        emit Transfer(address(0), msg.sender, totalSupply);

    function transfer(address to, uint256 value) public returns (bool success) {
        require(balanceOf[msg.sender] >= value);

        balanceOf[msg.sender] -= value;  // deduct from sender's balance
        balanceOf[to] += value;          // add to recipient's balance
        emit Transfer(msg.sender, to, value);
        return true;

    event Approval(address indexed owner, address indexed spender, uint256 value);

    mapping(address => mapping(address => uint256)) public allowance;

    function approve(address spender, uint256 value)
        returns (bool success)
        allowance[msg.sender][spender] = value;
        emit Approval(msg.sender, spender, value);
        return true;

    function transferFrom(address from, address to, uint256 value)
        returns (bool success)
        require(value <= balanceOf[from]);
        require(value <= allowance[from][msg.sender]);

        balanceOf[from] -= value;
        balanceOf[to] += value;
        allowance[from][msg.sender] -= value;
        emit Transfer(from, to, value);
        return true;
  • Tried to compile and got these error messages: pastebin.com/NVz92h6P
    – Vesa
    Mar 28, 2019 at 9:51
  • None of those are error messages. Those are warnings/advice from Remix's static analysis module. The first two warnings are because the compiler isn't sophisticated enough to know that the strings have constant length, so it can't estimate how much gas their getters will take. The third message appears any time you use require or assert to remind you of which to use in what circumstances. In the uses in this contract, require is appropriate.
    – user19510
    Mar 28, 2019 at 14:10
  • Ok, I thought so too but I wanted to double check before proceeding. Thanks. Also, I haven't used Remix in a long time - didn't there use to be a create button somewhere which opened up MetaMask? How do I deploy this contract now most conveniently? I can post a new question if it's complicated, but if it's not I would be happy to wrap this up if you know how to do it.
    – Vesa
    Mar 29, 2019 at 6:40
  • Yes, just press the "deploy" button in the "run" tab.-
    – user19510
    Mar 29, 2019 at 6:41
  • That seems to work! Aweeeesome. Is there any third party or community that can audit the source code before I start using the new tokens?
    – Vesa
    Mar 29, 2019 at 11:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.