I'm trying to deploy this code.

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

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

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

It compiles successfully, but throws an error when I click transact.

creation of GLDToken errored: VM error: revert.

    The transaction has been reverted to the initial state.
Note: The called function should be payable if you send value and the value you send should be less than your current balance.
Debug the transaction to get more information.

I can't figure out how to fix it, these are the parameters I'm using.

1 Answer 1


After a bit of scratching my head, I believe I found the issue. The problem is in registering the contract interfaces. This is needed in order to construct the receive hooks.

If you look at the references OpenZeppelin source code https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC777/ERC777.sol#L31 you'll see it uses a hardcoded address (0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24) as the registry. This address exists on (at least) mainnet, but obviously doesn't exist in your JavaScript VM.

The OpenZeppelin ERC777 documentation at https://docs.openzeppelin.com/contracts/4.x/erc777 forgets to mention that the example only works on mainnet.

If you want to get it working in your own environment, you first have to deploy the registry and change the hardcoded address. Since OpenZeppelin contracts are not meant to be changed locally (you should only extend them) and the variable is internal (can't be overridden) I honestly don't know how they expect people to use the template. I guess you simply need to modify the source code locally.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.