addMinter
/**
* Add minter function: Grant the 'minter' role to an address
* @param {string} publicAddress the address to be elevated at 'minter' role
* @notice Warning: This method will consume gas (30000 gas estimated)
* @returns {Promise<ethers.providers.TransactionResponse>} Transaction
*/
async addMinter({ publicAddress }) {
if (!this.#contractDeployed && !this.contractAddress) {
throw new Error('[ERC721Mintable.addMinter] A contract should be deployed or loaded first');
}
if (!publicAddress || !ethers.utils.isAddress(publicAddress)) {
throw new Error(
'[ERC721Mintable.addMinter] A valid address is required to add the minter role.',
);
}
try {
return await this.#contractDeployed.grantRole(this.MINTER_ROLE, publicAddress);
} catch (error) {
const { message, type } = networkErrorHandler(error);
throw new Error(`${type}[ERC721Mintable.addMinter] An error occured: ${message}`);
}
}
Copy link