Defender minting issue (unable to mint a token)

I followed the tutorial "Manage an ERC20 token using Defender Admin and Gnosis Safe"

However, I cannot mint a new token.

:computer: Environment
I am using component "New Admin Action", I have followed instructions on the page. Every input shows a "green tick" but it shows error when I press "create admin action"

:memo:Details
Error: Transaction validation failed. This usually means that this proposal would fail to execute given its current parameters.

  • Make sure all involved accounts have the necessary permissions for the transaction to succeed.
  • Check mint 's code to identify possible revert conditions.
  • You are proposing to execute function mint through address 0xABF23e2dc8CAc7a9f543117801E91362402850E9 . Make sure that address has enough permissions to execute the function.

:1234: Code to reproduce
Didn't use code

Thank you!

Hey @Cheryl! That error means that the mint action would revert if executed, so Defender is preventing you from creating a proposal that would fail. Do you mind sharing the address, network, and code of the token contract you have deployed and are trying to mint? Thanks!

Hey @spalladino ! Thanks for your help! Please find the address, network and code of the token contract as below (it's actually the sample code from Manage an ERC20 token using Defender Admin and Gnosis Safe)

  1. address : 0x52a75Fbd3796211d8F7FE8d4028e912e1a76EA9c
  2. Network : rinkeby
  3. code as below :
// SPDX-License-Identifier: MIT
// Based on https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.2.0/contracts/presets/ERC20PresetMinterPauser.sol
pragma solidity ^0.6.0;

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.2.0/contracts/access/AccessControl.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.2.0/contracts/GSN/Context.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.2.0/contracts/token/ERC20/ERC20.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.2.0/contracts/token/ERC20/ERC20Burnable.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.2.0/contracts/token/ERC20/ERC20Pausable.sol";

contract MyToken is Context, AccessControl, ERC20Burnable, ERC20Pausable {
    bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
    bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");

    /**
     * @dev Grants `DEFAULT_ADMIN_ROLE`, `MINTER_ROLE` and `PAUSER_ROLE` to the
     * account.
     *
     */
    constructor(string memory name, string memory symbol, address account) public ERC20(name, symbol) {
        _setupRole(DEFAULT_ADMIN_ROLE, account);

        _setupRole(MINTER_ROLE, account);
        _setupRole(PAUSER_ROLE, account);
    }

    /**
     * @dev Creates `amount` new tokens for `to`.
     *
     * Requirements:
     *
     * - the caller must have the `MINTER_ROLE`.
     */
    function mint(address to, uint256 amount) public virtual {
        require(hasRole(MINTER_ROLE, _msgSender()), "MyToken: must have minter role to mint");
        _mint(to, amount);
    }

    /**
     * @dev Pauses all token transfers.
     *
     * Requirements:
     *
     * - the caller must have the `PAUSER_ROLE`.
     */
    function pause() public virtual {
        require(hasRole(PAUSER_ROLE, _msgSender()), "MyToken: must have pauser role to pause");
        _pause();
    }

    /**
     * @dev Unpauses all token transfers.
     *
     * Requirements:
     *
     * - the caller must have the `PAUSER_ROLE`.
     */
    function unpause() public virtual {
        require(hasRole(PAUSER_ROLE, _msgSender()), "MyToken: must have pauser role to unpause");
        _unpause();
    }

    function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override(ERC20, ERC20Pausable) {
        super._beforeTokenTransfer(from, to, amount);
    }
}

@Cheryl from what I see on the deployment, the minter address was set to 0x16442a31363327499ab4f09c33b3121823c24374. Can you confirm if that is the same address you have in metamask when creating the proposal for calling mint?

@spalladino Yes, I think I had wrong setting in the minting contract. Yesterday I tried to deploy again with granting the multisig contract (which was created in Defender) the mint role and the problem solved.
Thanks for go through this debugging with me.

1 Like