Hi team,
I’m a begginer in smart contracts programming and I’m having trouble deploying my ERC777 contract following the SimpleERC777 example. Could you please give me some hints ? I’ve been trying for hours but I don’t know if it come from my contract itself, my deployement file, my network (ganache), my config WSL2…
(In my opinion it’s a problem related to test-helpers dependencies access after runing npm. I think the require statement in my deploy file can not be found.)
truffle migrate
Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.
Starting migrations...
======================
> Network name: 'ganache'
> Network id: 5777
> Block gas limit: 6721975 (0x6691b7)
2_deploy.js
===========
Deploying 'QlayToken'
---------------------
Error: *** Deployment Failed ***
"QlayToken" hit a require or revert statement somewhere in its constructor. Try:
* Verifying that your constructor params satisfy all require conditions.
* Adding reason strings to your require statements.
at /home/hydris/.nvm/versions/node/v14.3.0/lib/node_modules/truffle/build/webpack:/packages/deployer/src/deployment.js:364:1
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at Migration._deploy (/home/hydris/.nvm/versions/node/v14.3.0/lib/node_modules/truffle/build/webpack:/packages/migrate/migration.js:70:1)
at Migration._load (/home/hydris/.nvm/versions/node/v14.3.0/lib/node_modules/truffle/build/webpack:/packages/migrate/migration.js:57:1)
at Migration.run (/home/hydris/.nvm/versions/node/v14.3.0/lib/node_modules/truffle/build/webpack:/packages/migrate/migration.js:167:1)
at Object.runMigrations (/home/hydris/.nvm/versions/node/v14.3.0/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:148:1)
at Object.runFrom (/home/hydris/.nvm/versions/node/v14.3.0/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:110:1)
at Object.run (/home/hydris/.nvm/versions/node/v14.3.0/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:87:1)
at runMigrations (/home/hydris/.nvm/versions/node/v14.3.0/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:253:1)
at /home/hydris/.nvm/versions/node/v14.3.0/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:218:1
Truffle v5.1.27 (core: 5.1.27)
Node v14.3.0
Code to reproduce
My token contract
pragma solidity ^0.6.0;
import "@openzeppelin/contracts/token/ERC777/ERC777.sol";
/**
* @title QlayToken
* @dev Very simple ERC777 Token example, where all tokens are pre-assigned to the creator.
* Note they can later distribute these tokens as they wish using `transfer` and other
* `ERC20` or `ERC777` functions.
* Based on https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/examples/SimpleToken.sol
*/
contract QlayToken is ERC777 {
/**
* @dev Constructor that gives msg.sender all of existing tokens.
*/
constructor () public ERC777("QlayToken", "MIM", new address[](0)) {
_mint(msg.sender, 10000 * 10 ** 18, "", "");
}
}
My migration
const QlayToken = artifacts.require('QlayToken');
require('@openzeppelin/test-helpers/configure')({ provider: web3.currentProvider, environment: 'truffle' });
const { singletons } = require('@openzeppelin/test-helpers');
module.exports = async function (deployer, network, accounts) {
if (network === 'development') {
// In a test environment an ERC777 token requires deploying an ERC1820 registry
await singletons.ERC1820Registry(accounts[0]);
}
await deployer.deploy(QlayToken);
};
I suspected the issue was node v14.3 but I just used nvm to change to node v14.3 and could migrate ok. I normally use node v10 as the ecosystem has had trouble in the past with the latest versions of node.
Thank you for your reply @abcoathup.
I’ve tried using ganache-cli before but I have an error message (below). That is why I decided to use Ganache GUI.
hydris LAPTOP-JPBVRK0A ~ code qlay-token master $ ganache-cli
Ganache CLI v6.9.1 (ganache-core: 2.10.2)
Error: Callback was already called.
at /home/hydris/.nvm/versions/node/v14.3.0/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:17:276
at s.<anonymous> (/home/hydris/.nvm/versions/node/v14.3.0/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:17:2238)
at s.emit (events.js:315:20)
at s.destroy (/home/hydris/.nvm/versions/node/v14.3.0/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:37:712589)
at finish (_stream_writable.js:658:14)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
I’ve also tried to change my node version with nvm and use Node v10.19.0 :
2_deploy.js
===========
Deploying 'QlayToken'
---------------------
Error: *** Deployment Failed ***
"QlayToken" hit a require or revert statement somewhere in its constructor. Try:
* Verifying that your constructor params satisfy all require conditions.
* Adding reason strings to your require statements.
at /usr/local/lib/node_modules/truffle/build/webpack:/packages/deployer/src/deployment.js:364:1
at process._tickCallback (internal/process/next_tick.js:68:7)
Truffle v5.1.26 (core: 5.1.26)
Node v10.19.0
I’ve tried to check for this file “deployement.js” but I can’t find it…
Also, I’m using Windows terminal to run all my commands.
These are my hypothesis :
1 - TRUFFLE INSTALLING PROBLEM
There is no file deployement.js existing on my WSL -> Maybe a probleme while installing truffle ? (after reinstall it, nothing changed)
2 - WSL PATH
There is a problem related to my path - (I don’t have the linux Icon on my windows file explorer though)
My starting directory from my Windows Terminal (Ubuntu) is //wsl$/Ubuntu/home/hydris
Hi @abcoathup,
I come back because I still haven't found the answer to my problem...
Both my assumptions are wrong. I've reinstalled WSL so it's not that.
I managed to use ganache-cli, but that doesn't solve anything.
If you have any advice... it would help me a lot.
I assume that you used an earlier version of node (than node 14). What was the error that you had when trying to migrate?
Would you mind sharing a repository or your current contract, migrations script and your current versions of node, npm, truffle that you are using. (If you use npx truffle version this will give you these).
I used nvm to change my node version from 14.3 to 10.19 -> The result is : I have less errors but still one.
2_deploy.js
===========
Replacing 'QlayToken'
---------------------
Error: *** Deployment Failed ***
"QlayToken" hit a require or revert statement somewhere in its constructor. Try:
* Verifying that your constructor params satisfy all require conditions.
* Adding reason strings to your require statements.
at /home/hydris/.nvm/versions/node/v10.19.0/lib/node_modules/truffle/build/webpack:/packages/deployer/src/deployment.js:364:1
at process._tickCallback (internal/process/next_tick.js:68:7)
Truffle v5.1.28 (core: 5.1.28)
Node v10.19.0
Also, I’ve tried to use Remix IDE to have an other point of view. I can successfully compile but I still can’t migrate for some reasons. I believe there is a problem in the structure of my token contract (which is the SimpleERC777)
I figured out the solution and I’m a little disappointed ahah.
It’s a bad configuration of my ganache connection… So I modified the truffle-config file to match with ganache…