var Contract =require('web3-eth-contract');Contract.setProvider('wss://polygon-mainnet.blastapi.io/1160f5ab-4dfa-4ac1-aec4-12c7214ee252');//jsonInterface:Contract ABI,address:Contract Addressvar myContract =newContract(jsonInterface,address);
JsonInterface can be viewed in the blockchain browser, such as the polygon example:
Query NFT Count of ERC1155
//walletAddress:Wallet Address,tokenId:TokenId of ERC1155 NFT myContract.methods["balanceOf"](walletAddress,tokenId).call({}) .then(function(result){ ///Return the number of tokenIds held});
constmySecondPromise=newPromise((resolve, reject) => {myContract.methods["uri"](11).call({}).then(function(result){//result uri of metadataresolve(result); });});mySecondPromise.then((result) => {console.log(result);//return:https://static.bitverse.zone/metadata/WorldcupChampion/11.json})
Parsing Metadata Result from URI:https://static.bitverse.zone/metadata/WorldcupChampion/11.json
Parsing Metadata Results from URI: https://static.bitverse.zone/metadata/GenesisNFT/bitverse
{"name": "BitVerse Genesis", "description": "BitVerse Genesis NFT is linked to user’s Bitverse wallet address with plenty of benefits and privileges like - Free-mint NFT, airdrops, discounts in coming campaigns or activities on Bitverse",
"image": "https://static.bitverse.zone/genesis/bitverse.webp"}