Integrate Utility protocol within your wallet/project/ecosystem
To integrate the SDK with your repository, follow the steps below. The following code snippets provide examples of how to use the SDK functions to interact with the smart contract.
conststream=require('streamnft-utility-test');stream.createUtility(utility, chainId, signer).then((result) => {// Handle the result }).catch((error) => {// Handle the error });
This shall return index of utility created: utilityId
{success:true, data: <index> (int)}
Get All Utility By Collection
Get Utilities present on a collection
conststream=require('streamnft-utility-test');stream.getAllUtilityByCollection(collectionAddress).then((result) => {// Handle the result }).catch((error) => {// Handle the error });
Get All Utility By User
Get all Utilities accessible to a wallet
conststream=require('streamnft-utility-test');stream.getAllUtilityByUser(wallet, chainId).then((result) => {// Handle the result }).catch((error) => {// Handle the error });
Join Raffle
Join Raffle Type Utility
conststream=require('streamnft-utility-test');stream.joinRaffle(chainId, utilityId, signer).then((result) => {// Handle the result }).catch((error) => {// Handle the error });
Claim Reward
Claim reward for giveaways utilities
conststream=require('streamnft-utility-test');stream.claimReward(chainId, utilityId, user, proof, signer).then((result) => {// Handle the result }).catch((error) => {// Handle the error });
Claim Utility On NFT
Claim NFT benefit utility
conststream=require('streamnft-utility-test');stream.claimUtilityOnNFT(user, tokenId, utilityId, proof, chainId,signer).then((result) => {// Handle the result }).catch((error) => {// Handle the error });
Redeem Utility On NFT
Redeem NFT benefit utility
conststream=require('streamnft-utility-test');stream.redeemUtilityOnNFT(tokenId, utilityId, chainId,signer).then((result) => {// Handle the result }).catch((error) => {// Handle the error });
Check NFT utility
Check if NFT is valid for any utility
conststream=require('streamnft-utility-test');stream.checkNFTUtility(tokenId, utilityId, chainId, provider).then((result) => {// Handle the result }).catch((error) => {// Handle the error });