2

I've created a erc20 token using openzeppelin, and deployed to rinkeby testnet.

When I call mint(), it always stuck, e.g:

await contract.mint('0x............',ethers.utils.parseEther("0.5")
...

I've already added the address to the whiltelist.
Any idea ?

Contract code:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;

import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20BurnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";

contract FreeBirdTokenV3 is Initializable, ERC20Upgradeable, ERC20BurnableUpgradeable, PausableUpgradeable, OwnableUpgradeable {
    /// @custom:oz-upgrades-unsafe-allow constructor
    constructor() {
        _disableInitializers();
    }

    mapping(address => bool) whitelistedAddresses;

    function addUser(address _addressToWhitelist) public onlyOwner {
        whitelistedAddresses[_addressToWhitelist] = true;
    }

    function verifyUser(address _whitelistedAddress) public view returns (bool) {
        bool userIsWhitelisted = whitelistedAddresses[_whitelistedAddress];
        return userIsWhitelisted;
    }

    function initialize() initializer public {
        __ERC20_init("FreeBirdToken", "FBT");
        _mint(_msgSender(), 10_000_000);
        __ERC20Burnable_init();
        __Pausable_init();
        __Ownable_init();
    }

    function pause() public onlyOwner {
        _pause();
    }

    function unpause() public onlyOwner {
        _unpause();
    }

    function mint(address to, uint256 amount) public {
        require(verifyUser(to));
        _mint(to, amount);
    }

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

3
  • 1
    Not an answer to your problem but consider not using Rinkeby anymore, since it will become deprecated soon (due to the Merge). Switch to the Goerli. Sep 8, 2022 at 10:51
  • @PaulRazvanBerg, would you recommend Sepolia Testnet in addition in Goerli? Dev team promised leave it too after the Merge.
    – Gleichmut
    Sep 8, 2022 at 11:14
  • I don't know about Sepolia so I can't say anything about it. Sep 8, 2022 at 11:38

1 Answer 1

1

I've figured it out, in hardhat, the amount param for mint() is in ether, should pass BigInt.

e.g:

await fbt.mint('0xe38fE38eB33950E21Fa9419178A27C9Be553330A',100n * (10n ** 18n))

Now it succeed: mint transaction

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.