I seem to be having issues with the Mint NFT function:
The receipt returned from my createItem method in my tokenβs solidity file, seems to have an empty events subobject:
Console Log:
mintNFT function code from main.js
const mintNft = async (metadataUrl) => {
const receipt = await tokenContract.methods.createItem(metadataUrl).send({from: ethereum.selectedAddress});
console.log("minted, tokenID: ", receipt);
console.log('events:: ', JSON.stringify(receipt.events));
console.log('transfer :: ', JSON.stringify(receipt.events.Transfer));
// events seems to be empty here:
return receipt.events.Transfer.returnValues.tokenId;
}
TestToken.js (What Iβm naming this instead of MorarableToken) Solidity code:
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
contract TestToken is ERC721 {
using Counters for Counters.Counter;
Counters.Counter private _tokenIds;
constructor() ERC721("TestToken", "TEST") {}
struct Item {
uint256 id;
address creator;
string uri;
}
mapping(uint256 => Item) public Items;
function createItem(string memory uri) public returns (uint256) {
_tokenIds.increment();
uint256 newItemId = _tokenIds.current();
_safeMint(msg.sender, newItemId);
Items[newItemId] = Item(newItemId, msg.sender, uri);
return newItemId;
}
function tokenURI(uint256 tokenId)
public
view
override
returns (string memory)
{
require(
_exists(tokenId),
"ERC721Metadata: URI query for nonexistent token"
);
return Items[tokenId].uri;
}
}
Has anyone ran into a similar bug before / any tips to help me begin debugging this?