SDK
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.
Testnet SDK: streamnft-utility-test Mainnet SDK: streamnft-evm (TBA)
const stream = require('streamnft-utility');
//for browser wallets
signer = stream.getWalletSigner();
//for signer using private key
signer= stream.getSigner(chainId, privateKey, rpcUrl);
1. Create Utility Create Utility on any NFT collection
create utility schema with UtilitySchema
const stream = require('streamnft-utility');
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
const stream = require('streamnft-utility');
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
const stream = require('streamnft-utility');
stream.getAllUtilityByUser(wallet, chainId)
.then((result) => {
// Handle the result
})
.catch((error) => {
// Handle the error
});
Join Raffle
Join Raffle Type Utility
const stream = require('streamnft-utility');
stream.joinRaffle(chainId, utilityId, signer)
.then((result) => {
// Handle the result
})
.catch((error) => {
// Handle the error
});
Claim Reward
Claim reward for giveaways utilities
const stream = require('streamnft-utility');
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
const stream = require('streamnft-utility');
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
const stream = require('streamnft-utility');
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
const stream = require('streamnft-utility');
stream.checkNFTUtility(tokenId, utilityId, chainId, provider)
.then((result) => {
// Handle the result
})
.catch((error) => {
// Handle the error
});
Last updated