0

I'm using AccessControlUpgradeable and i get the following error when i try to trigger an adnin function on my deployed smart conntract (it work when tested localy with chai)

Fail with error 'AccessControl: account 'myaddress' is missing role 0x0000000000000000 ...'

function initialize(
    string memory _baseURIMetadata,
    bytes32 _merkleRoot,
) public initializer {
    __ERC721_init("XXX", "XXX");
    __ERC721Enumerable_init();

    __AccessControl_init();

    _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);        
    _grantRole(STARDUST_CONTRACTS_ROLE, _boxContract);

    baseURI = _baseURIMetadata;
    merkleRoot = _merkleRoot;
}

the function i try to trigger

function openPublic(bool _open) public onlyRole(DEFAULT_ADMIN_ROLE) {
    openForPublic = _open;
}

1 Answer 1

0

I'm facing the same issue while using truffle and openzepeline upgradeable contracts.

An upgradeable contracts need to deployed using deployProxy.

make sure you use deployProxy to deploy the contrats, something like this:

const { deployProxy } = require('@openzeppelin/truffle-upgrades');
const ContractArtifact = artifacts.require('ContractArtifact');

module.exports = async function (deployer) {
    const ContractProxy = await deployProxy(ContractArtifact, [], { deployer });
}

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.