Remix Error: insufficient data for uint256 type when minting to a contract using ERC20PresetMinterPauser

Hello,
I’m using the v3.01 preset ERC20PresetMinterPauser to create an erc20 mintable token using Remix. However when I try to mint, I get the following message

transact to Token.mint pending …
transact to Token.mint errored: Error: insufficient data for uint256 type (arg=“tokenId”, coderType=“uint256”, value=“0x”, version=4.0.45)

Strangely, the tokens are minted successfully. Any idea what is causing this?

Thanks

1 Like

Hi @guiguy,

Welcome to the community :wave:

I tried to reproduce by minting without setting a value for the amount of tokens:
ERC20 mint with no amount

Though that results in a mint with an amount of 0.

Can you share your contract and what you call mint with?


If you haven’t already, you could look at the following tutorial: Create an ERC20 using Remix, without writing Solidity

Thanks for your reply
I have two simple contracts to test, Token.sol (ERC20) and Test721 (ERC721)

Token.sol

    pragma solidity ^0.6.2;
    import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.0.1/contracts/presets/ERC20PresetMinterPauser.sol";

    contract Token is ERC20PresetMinterPauser {
    constructor() public ERC20PresetMinterPauser("AAA Token", "AAA") {}
    }

Test721.sol

pragma solidity ^0.6.2;

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v3.0.0/contracts/token/ERC721/ERC721.sol";

interface Token{
    function transfer(address _to, uint256 _value) payable external returns (bool success);
    function balanceOf(address account) external view returns (uint256);//
}

contract Test721 is ERC721{
    address payable admin;
    Token tokenContract;   
    
    constructor(Token _tokenContract) public
        ERC721(
            "Test721",
            ""
        )
    {
        tokenContract = _tokenContract;
        admin = msg.sender;
    }

  
    function transferToken() external {
        require(msg.sender == admin);
        require(tokenContract.transfer(admin, tokenContract.balanceOf(address(this))));
    }

}

I mint ERC20 tokens using the Remix UI, the recipient being the Test721 contract.

When I mint to Test721.sol, I get the error message
transact to Token.mint errored: Error: insufficient data for uint256 type (arg=“tokenId”, coderType=“uint256”, value=“0x”, version=4.0.45)

But the Test721 contract does receive the Tokens.

(Note, I get the same error minting to any other Externally Owned Account.)

Then when I do transferTokens from the Test721.sol contract to return the tokens to admin, I get the same message
transact to Test721.transferToken errored: Error: insufficient data for uint256 type (arg=“tokenId”, coderType=“uint256”, value=“0x”, version=4.0.45)

But the tokens are sent by the contract to the admin (deployer) account successfully.

1 Like

Hi @guiguy,

I get the same issue when deploying to the JavaScript VM. It looks like an error with Remix, as the tokens are appropriately minted. I couldn’t see any open issues for this in Remix, so we may need to create an Issue.

Looking at your Test721.sol code, you are importing from a branch used to develop the v3 release and not using an official release tag of OpenZeppelin Contracts

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v3.0.0/contracts/token/ERC721/ERC721.sol";

The import should be as follows:

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.0.1/contracts/token/ERC721/ERC721.sol";

Please note that v3.0.2 is the latest release.

Thanks so much for your help. I was playing the different branches to see if the error would go away. Shouldn’t I be using the master branch for the latest? , in which case the import is just

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/ERC721.sol"

1 Like

Hi @guiguy,

It would be great to narrow down the issue to a simple reproduceable example.

We shouldn’t import from the master branch as this may not be part of an official release.

:warning: Note: We should only use code published in an official release of OpenZeppelin Contracts, the latest release is 3.0.2. When importing via GitHub on Remix we can specify the release tag, (otherwise we will get the latest code in the master branch).

I don’t think I can make the example any simpler. It happens when the 721contract has an interface back to the ERC20 token contract.

Is there a link to the official releases of OpenZeppelin Contracts? On the github page the only reference I found to 3.02 is on the Branch: release-v3.0.0 page and a small note by nventuro, but the Latest release is still 3.01 on github

1 Like

Hi @guiguy,

I will see if I can track this error down some more.

Releases can be found on GitHub: https://github.com/OpenZeppelin/openzeppelin-contracts/releases
They are also announced in #general:announcements

no worries, thanks. Using remix for prototyping, it seems ok deployed in truffle.

1 Like

I know it's a while ago since this issue was discussed here. Right now I'm facing exactly the same situation. My current observation is I used Hardhat and there were no errors. I switched to Ganache and since then I get this error. Did you find out anything else or just the switch to truffle solved it.

Sorry, I left in in the unsolved but moved on folder and it hasn't been a problem in Truffle

Thanks for the reply! I switched to Truffle and the error still persists. So it's not about the tooling I guess. I also tried to compare the JSON Hardhat and Truffle is compiling. There are minor differences beside Truffle is adding a huge block at the end which looks to me like a "precompiled" something.