Hi,
I want to create ERC721 token for each application form submitted by user(where their application number is using Counter.sol increment function) and next time when application form opens up i would like to get next incremented value as its application number,now I get only 1 as application number & after token creation not getting next incremented value
For Example : first form Application number 1 then token 1 and mint token to address 1
Next Application number 2 then token 2 and mint token 2 to address 1
next application number 3 then token 3 to address 2 and so on
Truffle v5.4.6 (core: 5.4.6)
Solidity v0.5.16 (solc-js)
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.16 <0.9.0;
import "@openzeppelin/contracts/token/ERC721/ERC721Full.sol";
import "@openzeppelin/contracts/drafts/Counters.sol";
contract MyToken is ERC721Full {
using Counters for Counters.Counter;
Counters.Counter private _tokenIds;
constructor() public ERC721Full("MyNFT", "MNFT") {
}
//Get unique application number on application form
function getApplicationNo() public returns (uint256) {
_tokenIds.increment();
return _tokenIds.current();
}
//Create token for an application which can be tracked
function mintToken(address owner, string memory tokenURI)
public
returns (uint256)
{
uint256 newItemId = _tokenIds.current();
_tokenIds.increment();
_mint(owner, newItemId);
//set token with its URI -JSON format
_setTokenURI(newItemId, tokenURI);
return newItemId;
}