-1

I'm trying to deploy to Ganache, which is running and configured and I keep getting the same error when running truffle migrate --network development --reset

Ganache log:

[8:17:47 AM] (node:19312) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [Server]. Use emitter.setMaxListeners() to increase limit [8:17:47 AM] Starting server with initial configuration: {"gasLimit":6721975,"gasPrice":20000000000,"hardfork":"merge","hostname":"127.0.0.1","port":8545,"network_id":5777,"default_balance_ether":1000000000000000,"total_accounts":10,"unlocked_accounts":[],"locked":false,"vmErrorsOnRPCResponse":true,"verbose":true,"flavor":"ethereum","db_path":"C:\Users\**\AppData\Roaming\Ganache\ui\workspaces\wide-leaf\chaindata","mnemonic":"","logDirectory":"C:\Users\*\Logs"} [8:17:47 AM] Ganache started successfully! [8:17:47 AM] Waiting for requests... [8:17:47 AM] (node:19312) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [Server]. Use emitter.setMaxListeners() to increase limit

Error message from truffle:

Compiling your contracts... =========================== Compiling .\contracts\IERC20.solsolc-bin. Attempt #1 Compiling .\contracts\Migrations.sol Compiling .\contracts\TestToken.sol Compiling .\contracts\SafeMath.sol Artifacts written to C:\Users*\TestToken\build\contracts Compiled successfully using:

  • solc: 0.8.20+commit.a1b79de6.Emscripten.clang ⠇ Fetching solc version list from solc-bin. Attempt #1

Starting migrations...

Network name: 'development' Network id: 5777 Block gas limit: 6721975 (0x6691b7)

1_initial_migration.js

⠏ Fetching solc version list from solc-bin. Attempt #1 Deploying 'TestToken'

*** Deployment Failed ***st from solc-bin. Attempt #1

"TestToken" 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.

Exiting: Review successful transactions manually by checking the transaction hashes above on Etherscan.

Error: *** Deployment Failed ***

"TestToken" 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 C:\Users\*\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\deployer\src\deployment.js:330:1

Truffle v5.9.0 (core: 5.9.0) Node v18.16.0

This is the constructor with params:

uint128 private constant _initialSupply = 1_000_000_000_000_000 ether;
uint128 private constant _yearlySupplyIncrease = 10_000_000_000 ether;
uint128 private constant _reflectionFeePercentage = 1;
uint128 private constant _burnFeePercentage = 2;

constructor() {
    _totalSupply = _initialSupply;
    _balances[msg.sender] = _initialSupply;
    emit Transfer(address(0), msg.sender, _initialSupply);

    require(_totalSupply >= 0, "Error: Invalid total supply");
    require(_balances[msg.sender] == _initialSupply, "Error: Initial supply not assigned correctly");
}
zendek
  • 24
  • 3

1 Answers1

0

I had the same problem changing the solc version to '0.8.0' in truffle-config.js solved the problem for me

  • Thanks for the suggestion ירדן חובב, I believe this is already set compilers: { solc: { version: "^0.8.0", // Use a compiler version compatible with your contract settings: { optimizer: { enabled: true, runs: 200, }, – zendek May 19 '23 at 06:20