4

I'm trying to write a contract that inherits from the ERC-777 contract on OpenZeppelin. This contract has a constructor with the following signature:

constructor(
    string memory name_,
    string memory symbol_,
    address[] memory defaultOperators_
)

In my inherited contract, I'm trying to write a constructor that takes no arguments and provide defaults for the inherited constructor. Here is what I tried:

contract MyCoin is ERC777 {
    constructor() ERC777("MyCoin", "MYC", []) {
    }
}

But I receive the following error:

TypeError: Unable to deduce common type for array elements. --> contracts/MyCoin.sol:7:45: | 7 | constructor() ERC777("MyCoin", "MYC", []) { | ^^

Error HH600: Compilation failed

Is it possible to provide an empty array to the inherited constructor?

1 Answer 1

9

I figured it out. The way to do this is:

constructor() ERC777("MyCoin", "MYC", new address[](0)) {
}

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.