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
I also get this error when trying to use solidity >=0.5.5 since it changed the default EVM to Petersburg
Hi @WyseNynja! I was not able to reproduce this. Could you share your full truffle-config.js, and your migrations files?
I'm getting the same issue. It seems to be related to calling a function inside the constructor. If I remove the function call and move the code directly inside the constructor it works just fine.
I believe it has to do with Truffle.
@AleG94 what makes you believe truffle is the culprit?
@nventuro I'm using my own contract and had the same issue. I solved it by updating to solc 0.5.7 and removing evmVersion from settings. So it probably wasn't truffle's fault.
@WyseNynja have you tried what @AleG94 suggests?
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.
Most helpful comment
Just cleared my build artifacts, ran
yarn upgrade, changed my contracts to use solc 0.5.7, and removedevmVersionfrom settings.yarn compileworks successfully and most of the contracts are able to migrate, but TutorialToken still fails: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.