Insufficient data for uint256 type (arg="value") on ERC721 minting

I’m trying to write a really simple ERC721, but keep running into the following error when trying to mint the token to an address;

transact to NFT.mintTo errored: Error: insufficient data for uint256 type (arg="value", coderType="uint256", value="0x", version=4.0.47)

When debugging with Truffle, I get a runtime error at

set._indexes[value] = set._values.length;
Error: Revert or exceptional halt
  at EnumerableSet._add [address 0x20a13824C80d728dda0B4761f051E4100B832a57] (@openzeppelin/contracts/utils/EnumerableSet.sol:59:13)
  at EnumerableSet.add [address 0x20a13824C80d728dda0B4761f051E4100B832a57] (@openzeppelin/contracts/utils/EnumerableSet.sol:203:16)
  at ERC721._mint [address 0x20a13824C80d728dda0B4761f051E4100B832a57] (@openzeppelin/contracts/token/ERC721/ERC721.sol:339:9)
  at NFT.mintTo [address 0x20a13824C80d728dda0B4761f051E4100B832a57] (/Users/hdahme/Projects/dapps/nft-factory/contracts/NFTFactory.sol:17:7)
  at NFT [address 0x20a13824C80d728dda0B4761f051E4100B832a57] (/Users/hdahme/Projects/dapps/nft-factory/contracts/NFTFactory.sol:13:5)
  at [address 0x5fD6AdC24B58204911f6F683F70a71262eCF7D0E] (/Users/hdahme/Projects/dapps/nft-factory/contracts/NFTFactory.sol:42:7)
  at NFTFactory [address 0x5fD6AdC24B58204911f6F683F70a71262eCF7D0E] (/Users/hdahme/Projects/dapps/nft-factory/contracts/NFTFactory.sol:41:5)
  at ExampleToken.transfer [address 0xB02612e4B658A8C1E13CBe4486F51c34Ec36E6bF] (/Users/hdahme/Projects/dapps/nft-factory/contracts/ExampleToken.sol:21:5)
  at ExampleToken [address 0xB02612e4B658A8C1E13CBe4486F51c34Ec36E6bF] (/Users/hdahme/Projects/dapps/nft-factory/contracts/ExampleToken.sol:18:3)

Has anyone encountered this before?

Here’s the complete code;

pragma solidity ^0.6.0;

import "";
import "";
import "";

contract NFT is ERC721 {
    using Counters for Counters.Counter;
    Counters.Counter private _tokenIds;

    constructor(string memory name, string memory symbol) ERC721(name, symbol) public {

    function mintTo(address recipient, string memory tokenURI) public returns (uint256) {

       uint256 newTokenId = _tokenIds.current();
      _mint(recipient, newTokenId);
      _setTokenURI(newTokenId, tokenURI);

      return newTokenId;

:computer: Environment
Using Remix with compiler 0.6.12

For truffle;
Truffle v5.1.52 (core: 5.1.52)
Solidity - 0.6.2 (solc-js)
Node v14.15.0
Web3.js v1.2.9


:1234: Code to reproduce

** edited to add truffle debug info

1 Like

Hi @Harrison_Dahme,

Welcome to the community :wave:

I deployed the above contract using Remix and I was able to call mintTo with the following parameters: “0x5B38Da6a701c568545dCfcB03FcB875f56beddC4”,“

I am not sure what was causing the error that you were seeing.

Please note, in your token, there is no access control, so anyone could call the mintTo function.

I suggest having a look at the ERC721 preset contract as an example:

You may want to look at this guide: [DRAFT] Create an NFT and deploy to a public testnet, using Truffle

1 Like

Thank you so much @abcoathup! I was able to work backwards from the guide you sent over, and was able to get something working. I’m still not sure what the issue was :man_shrugging:

1 Like