ERC777 constructor arguments

erc777
#1

Hi,
I’m trying to deploy zeppelin’s implementation of ERC777 just as an example. I understand the constructor takes three arguments: name, symbol and an array of addresses (default operators), hence the following 2_another_migrate.js code in truffle:

var MyContract = artifacts.require("./ERC777.sol");
var defaultOperators = ["0xEe545e6239a7e0d42095872956DdC981f028da60","0x3e576F19520215637569c6aCB0740723326d1375", "0x569bd2696200ce347f72cE586B6d355C28E5aAf4"];

module.exports = function(deployer) {
deployer.deploy(MyContract, "TestToken", "TTN", defaultOperators);
}

BUT, when I to run the migration the console says:

“ERC777” 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.

So what exactly should I pass as a third argument? My goal is to eventually deploy it to a test network and interact with it via MEW… any other thing I might be missing here? Thank you

#2

Hi @Bleier, I deployed a simple ERC777 to Rinkeby testnet with a similar deploy script to yours using Truffle.

In a testing environment an ERC777 requires deploying an ERC1820 registry using openzeppelin-test-helpers. See the test suite: https://github.com/OpenZeppelin/openzeppelin-solidity/blob/release-v2.3.0/test/drafts/ERC777/ERC777.test.js

Smart contract:

pragma solidity ^0.5.0;

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

contract ABC777 is ERC777 {
    constructor(
        string memory name,
        string memory symbol,
        address[] memory defaultOperators
    ) public ERC777(name, symbol, defaultOperators) {
        _mint(msg.sender, msg.sender, 10000 * 10 ** 18, "", "");
    }
}

2_deploy.js:

var MyContract = artifacts.require("ABC777");
var defaultOperators = [
"0xEe545e6239a7e0d42095872956DdC981f028da60",
"0x3e576F19520215637569c6aCB0740723326d1375",
"0x569bd2696200ce347f72cE586B6d355C28E5aAf4"];

module.exports = function(deployer) {
    deployer.deploy(MyContract, "ABC 777 Token", "ABC", defaultOperators);
}

Deployed contract:

Etherscan: 0x8312703dd4296D5c98Ab885e6E5BA12147aC168C
OneClickDapp: ABC777 (to interact with the contract)

2 Likes
#3

Thanks so much! I was missing the contract itself hehe

1 Like
#4

For the record, when testing against a development network like ganache or geth --dev you need to use openzeppelin-test-helpers as shown below.

const { singletons } = require('openzeppelin-test-helpers');

contract('ERC777', function (accounts) {
  before(async function () {
    const funder = accounts[0]; // account that will be used to fund the deployment
    await singletons.ERC1820Registry(funder);
  });

  it(...your test here...);
});
1 Like
#5

Yup, I realized my problem was not the constructor but the deployment of the ERC12820Registry. I followed the instructions you gave to CrazyRabbitLTC a couple of days ago. but truffle “Cannot find module ‘openzeppelin-test-helpers/configure’”

This is the deploy code I wrote after going over that issue:

var ERC777 = artifacts.require("TTN777");

require('openzeppelin-test-helpers/configure')({ web3 });

const { singletons } = require('openzeppelin-test-helpers');

const name = "TestToken777";
const symbol = "TTN";
const defaultOperators = [];

module.exports = async function(deployer, network, accounts) {
  const erc1820 = await singletons.ERC1820Registry(accounts[0]);
  deployer.deploy(ERC777, name, symbol, defaultOperators);
};
1 Like
#6

Configure is still unreleased! :slightly_smiling_face: You can try it for now by installing the latest code from GitHub directly: npm install github:OpenZeppelin/openzeppelin-test-helpers. The feature will be released on npm likely next week.

Check out the changelog in case there are any breaking changes you need to adapt to.

2 Likes