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 NFTFactory.mint [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 "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.2.0/contracts/token/ERC721/ERC721.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.2.0/contracts/utils/Counters.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.2.0/contracts/token/ERC20/ERC20.sol";
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) {
_tokenIds.increment();
uint256 newTokenId = _tokenIds.current();
_mint(recipient, newTokenId);
_setTokenURI(newTokenId, tokenURI);
return newTokenId;
}
}
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
Details
Code to reproduce
** edited to add truffle debug info

