finsky
March 1, 2022, 6:24pm
1
Hello !
I'm trying to learn how to deploy an ERC777Upgradeable token, but when deploying I get the following error message :
Error: Returned error: intrinsic gas too low -- Reason given: Address: low-level delegate call failed.
This is my contract code :
pragma solidity >=0.8.0 <0.9.0;
import "@openzeppelin/contracts-upgradeable/token/ERC777/ERC777Upgradeable.sol";
contract Token is ERC777Upgradeable {
function initialize() public initializer {
address[] memory _defaultOperators;
__ERC777_init('Token', 'TKN', _defaultOperators);
}
}
And my deployment code :
const { deployProxy } = require('@openzeppelin/truffle-upgrades');
const Token = artifacts.require("Token");
module.exports = async function(deployer) {
await deployProxy(Token, {initializer: 'initialize'});
};
What am I doing wrong ? I can't seem to find any example of ERC777Upgradeable's implementation anywhere.
Thanks a lot !
Skyge
March 2, 2022, 2:59pm
2
Hi, welcome to the community!
I think your code is ok, maybe you can update the truffle to the latest version, and then have a try.
What command are you running? Are you running this against a local Ganache network?
finsky
March 2, 2022, 11:01pm
4
Thanks for the replies !
Truffle is up to date. I'm running "truffle test", so using the default local development network. I have other non-ERC777 contracts that are deploying just fine, it is just this one causing the issue.
I've tried the above mentioned code in a brand new "truffle init" project, and on another computer as well.
Oh, I know, ERC777 requires the ERC1820 registry to be deployed. You can deploy it using OpenZeppelin Test Helpers .
1 Like
finsky
March 4, 2022, 11:53am
6
Amazing ! That was it.
For anyone else reading this, here's what I did.
Run npm install --save-dev @openzeppelin/test-helpers
Update the deployement code to :
const { deployProxy } = require('@openzeppelin/truffle-upgrades');
const { singletons } = require('@openzeppelin/test-helpers');
const Token = artifacts.require("Token");
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 deployProxy(Token, {initializer: 'initialize'});
};
Thank you so much @frangio .
1 Like