How to deploy ERC777 using OpenZeppelin CLI?

Hi, trying to reproduce this example with the CLI:

// contracts/GLDToken.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;

import "@openzeppelin/contracts/token/ERC777/ERC777.sol";

contract GLDToken is ERC777 {
    constructor(uint256 initialSupply, address[] memory defaultOperators)
        ERC777("Gold", "GLD", defaultOperators)
        _mint(msg.sender, initialSupply, "", "");

of this guide:

When trying to enter the defaultOperators argument: address []: with an empty array [] I am getting an error that says Returned error: VM Exception while processing transaction: revert even if I use it as '[]' or "[]" it won’t let me go ahead and suggest that I enter this way:
Enter a valid address[] such as: [0x1df62f291b2e969fb0849d99d9ce41e2f137006e, 0x1df62f291b2e969fb0849d99d9ce41e2f137006e]
But I’ve dealt with directions, no directions, and nothing, it just don’t let me go ahead.
How is the syntax for array arguments?

1 Like

Hi @gabo,

What tool are you using to provide the parameters?

In my simple ERC777 example I set the empty default operators in Solidity.

1 Like

The Command Line Interface (CLI) with npx oz deploy

npx oz --version

Ok, I understand the problem is about the ERC1820 registry, so I’m going to try to prove it with @openzeppelin/test-helpers solution. Thanks a lot for the response.

1 Like

Hi @gabo,

I was able to deploy GLDToken (as a regular contract) to ganache after deploying ERC1820 registry using a simple script.

Please note, if you want to create an upgradeable contract then you would need to use OpenZeppelin Contracts Ethereum Package which is upgrade safe. You could also use OpenZeppelin Upgrades Plugins to deploy upgradeable contracts:


// src/index.js
const Web3 = require('web3');
const web3 = new Web3('http://localhost:8545');
require('@openzeppelin/test-helpers/configure')({ provider: web3.currentProvider });

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

async function main() {
  // Retrieve accounts from the local node
  const accounts = await web3.eth.getAccounts();

  await singletons.ERC1820Registry(accounts[0]);


Deploy ERC1820 registry

$ node src/index.js

Deploy GLDToken

$ npx oz deploy
Nothing to compile, all contracts are up to date.
? Choose the kind of deployment regular
? Pick a network development
? Pick a contract to deploy GLDToken
? initialSupply: uint256: 100000000000000000000
? defaultOperators: address[]:
✓ Deployed instance of GLDToken


$ npx oz call
? Pick a network development
? Pick an instance GLDToken at 0xCfEB869F69431e42cdB54A4F4f105C19C080A601
? Select which function name()
✓ Method 'name()' returned: Gold
1 Like

Everything is running perfect now, even with the upgradeable contract:

$ node src/index.js
$ npx oz deploy     
Nothing to compile, all contracts are up to date.
? Choose the kind of deployment upgradeable
? Pick a network development
? Pick a contract to deploy GLDToken
✓ Deploying @openzeppelin/contracts-ethereum-package dependency to network dev-1602104572874
✓ Contract GLDToken deployed
All implementations have been deployed
? Call a function to initialize the instance after creating it? Yes
? Select which function * initialize(initialSupply: uint256, defaultOperators: address[])
? initialSupply: uint256: 100000000000
? defaultOperators: address[]:  
✓ Setting everything up to create contract instances
✓ Instance created at 0x9b1f7F645351AF3631a656421eD2e40f2802E6c0
To upgrade this instance run 'oz upgrade'
1 Like

Hi @gabo,

Glad to hear. If you have a moment, it would be great if you could introduce yourself to the community.