Closed ade-hardhat closed 2 years ago
The value of s_tokenCounter is initialised to zero (s_tokenCounter = 0;) in both the constructors of BasicNft.sol and DynamicSvgNft.sol . This seems to be missing in that of RandomIpfsNft.sol but it is used and incremented in fulfillRandomWords
s_tokenCounter
s_tokenCounter = 0;
fulfillRandomWords
constructor( address vrfCoordinatorV2, uint64 subscriptionId, bytes32 gasLane, // keyHash uint256 mintFee, uint32 callbackGasLimit, string[3] memory dogTokenUris ) VRFConsumerBaseV2(vrfCoordinatorV2) ERC721("Random IPFS NFT", "RIN") { i_vrfCoordinator = VRFCoordinatorV2Interface(vrfCoordinatorV2); i_gasLane = gasLane; i_subscriptionId = subscriptionId; i_mintFee = mintFee; i_callbackGasLimit = callbackGasLimit; _initializeContract(dogTokenUris); } function fulfillRandomWords(uint256 requestId, uint256[] memory randomWords) internal override { address dogOwner = s_requestIdToSender[requestId]; uint256 newItemId = s_tokenCounter; s_tokenCounter = s_tokenCounter + 1; uint256 moddedRng = randomWords[0] % MAX_CHANCE_VALUE; Breed dogBreed = getBreedFromModdedRng(moddedRng); _safeMint(dogOwner, newItemId); _setTokenURI(newItemId, s_dogTokenUris[uint256(dogBreed)]); emit NftMinted(dogBreed, dogOwner); }
Ah good point! Could you add this in a pull request?
The value of
s_tokenCounter
is initialised to zero (s_tokenCounter = 0;
) in both the constructors of BasicNft.sol and DynamicSvgNft.sol . This seems to be missing in that of RandomIpfsNft.sol but it is used and incremented infulfillRandomWords