question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Migration of simple ERC20 token fails with constantinople

See original GitHub issue

I have this very simple test contract:

pragma solidity 0.5.4;

import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol";

contract TutorialToken is ERC20 {
    string public name = "TutorialToken";
    string public symbol = "TT";
    uint8 public decimals = 18;
    uint public INITIAL_SUPPLY = 1000000000000;

    constructor() public {
        _mint(msg.sender, INITIAL_SUPPLY);
    }
}

I added evmVersion: 'constantinople' to my truffle-config.js and tried to migrate, but got this error:

   Deploying 'TutorialToken'
   -------------------------
Error:  *** Deployment Failed ***

"TutorialToken" hit an invalid opcode while deploying. Try:
   * Verifying that your constructor params satisfy all assert conditions.
   * Verifying your constructor code doesn't access an array out of bounds.
   * Adding reason strings to your assert statements.

    at /usr/src/app/node_modules/truffle/build/webpack:/packages/truffle-deployer/src/deployment.js:364:1
    at process._tickCallback (internal/process/next_tick.js:68:7)
Truffle v5.0.5 (core: 5.0.5)
Node v10.15.1

It migrates fine on byzantium.

💻 Environment

openzeppelin-solidity@2.1.3

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
WyseNynjacommented, Apr 12, 2019

Just cleared my build artifacts, ran yarn upgrade, changed my contracts to use solc 0.5.7, and removed evmVersion from settings. yarn compile works successfully and most of the contracts are able to migrate, but TutorialToken still fails:

2_bootstrap_development.js
==========================

   Deploying 'GasToken2'
   ---------------------
   > transaction hash:    0x65af43004b33ebc99096e06b5b37dd7b29f03a1ab82fcc55fab29ad67774ad73
   > Blocks: 0            Seconds: 0
   > contract address:    0x7C7cC36FcE214C0D61a5BbFE592dae71422321B5
   > block number:        19
   > block timestamp:     1555100577
   > account:             0xa2138e2a036cd5468868b8f50B921040Bd5aE092
   > balance:             9999999999999.7409726
   > gas used:            800928
   > gas price:           20 gwei
   > value sent:          0 ETH
   > total cost:          0.01601856 ETH


   Deploying 'TutorialToken'
   -------------------------
Error:  *** Deployment Failed ***

"TutorialToken" hit an invalid opcode while deploying. Try:
   * Verifying that your constructor params satisfy all assert conditions.
   * Verifying your constructor code doesn't access an array out of bounds.
   * Adding reason strings to your assert statements.

    at /usr/src/app/node_modules/truffle/build/webpack:/packages/truffle-deployer/src/deployment.js:364:1
    at process._tickCallback (internal/process/next_tick.js:68:7)
Truffle v5.0.12 (core: 5.0.12)
Node v10.15.1

I can’t share my repo, but I’ll try to make a repo that can reproduce this sometime in the next week o two.

1reaction
hudhaifahzcommented, Feb 10, 2021

Sure! Reesolved though. I’d just like to leave a note that my difficulty was with "truffle-hdwallet-provider": "1.0.5" and I got around it by using "@truffle/hdwallet-provider": "1.0.34" instead.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Migration of simple ERC20 token fails with constantinople #1657
I have this very simple test contract: pragma solidity 0.5.4; import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol"; ...
Read more >
How contract migration works | Trail of Bits Blog
For ERC20 token contracts, you can find the list of all the holders by tracking the addresses of the Transfer events. This process...
Read more >
Points to consider when creating a fungible token (ERC20 ...
Will burning a percentage of the amount transferred for an ERC20 token cause issues? Creating Capped ERC20 gives error in contract constructor.
Read more >
Uncovering a Four Year Old Bug - Paradigm
The transaction in question was a simple ERC20 transfer, so I quickly simulated it on Anatol's node, which failed.
Read more >
All about CRO Token Migration - Crypto.com Help Center
Token migration is the process of migrating your ERC20 CRO on the Ethereum network to CRO on Crypto.org Chain. There will be multiple...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found