I have smart contract server function and that function including emit and event.
event TokenMinted(
address indexed _recipient,
uint256 indexed _tokenId
);
function mintToken(address to, address[] memory bundle) public {
// Mint new token
uint256 tokenId = _tokenIdCounter.current();
.........
// Emit TokenMinted event
emit TokenMinted(to, tokenId);
// Increase the token counter
_tokenIdCounter.increment();
}
Not I'm going to call this function and hope to get tokenId.
But In my React frontend code, I can't find method to get tokenId.
export const mintToken = async (contract, to, address) => {
let tokenId = await contract.mintToken(to, address);
console.log('contracts', contract)
// console.log('contract.events', contract.filters.TokenMinted())
//get the latest blocknumber
return tokenId;
}
The contract generated like this.
new ethers.Contract(ROCI_MINTER_ADDR, ROCI_MINTER_ABI, library.getSigner());
How can I get this value correctly? Thanks for attention.
getBalance
view function which returns an array of ids that the caller owns. Then you can use this function to see if there are any changes.