TON SDK
The Nomis Ton Score SDK allows you to seamlessly integrate your application with the Nomis Ton Score system. Below are the details for installation and usage of the SDK.
Installation
To install the SDK, use the following command:
npm install nomis-sdkMethods
getScoreData
Retrieves information about a wallet’s score.
const { isUpdate, scoreData, scoreName, token, mintData } = await getScoreData({
address,
referrerCode,
});Parameters
address(string): The wallet address.referrerCode(string, optional): Code for referral rewards.
Returns
isUpdate(boolean): Indicates if the user has previously minted the score.scoreData(object): Detailed information about the wallet’s score.scoreName(string): The network used for scoring.token(object): Information about the minted score.mintData(object): Data required for minting/updating the score.
mintScore
Provides three methods for minting a score and obtaining the transaction hash.
const { mintToken, getNewTxHash, getMintingTxParams } = mintScore({ address });mintToken
Mints a token using the provided mint data and TonConnect object.
const lastTx = await mintToken({ ...mintData, tonConnect: tonConnect });Parameters
mintData(object): Data necessary for minting.tonConnect(object): An instance of TonConnect or TonConnectUi that includes a sendTransaction method.
Returns
lastTx(object instance of Transaction): The last transaction in the user’s wallet.
getMintingTxParams
Prepares transaction parameters required for minting a score token without TonConnect.
const txParams = await getMintingTxParams(mintData);Parameters
mintData(IMintData): Object containing the necessary data for minting a score token.
Returns
Promise<SenderArguments>: Prepared transaction parameters.
getNewTxHash
Obtains the transaction hash for the mintToken transaction.
const txHash = await getNewTxHash(lastTx);Parameters
lastTx(object): The last transaction returned frommintToken.
Returns
txHash(string): The transaction hash.
getMintedToken
Retrieves the minted token object for a given wallet address.
const token = await getMintedToken({ address });Parameters
address(string): The wallet address.
Returns
token(object): The minted token object.
isScoreHolder
Checks if the specified wallet holds a score NFT.
const isHolder = await isScoreHolder({ address });Parameters
address(string): The wallet address.
Returns
isHolder(boolean): True if the wallet holds a score NFT, otherwise false.
Usage Example
import {
getScoreData,
mintScore,
getMintedToken,
isScoreHolder,
getMintingTxParams,
} from "nomis-sdk";
// Example usage of getScoreData
const fetchScoreData = async (address: string) => {
const { isUpdate, scoreData, scoreName, token, mintData } =
await getScoreData({ address });
console.log(scoreData);
};
// Example usage of mintScore
const mintScoreForWallet = async (address: string, tonConnect: any) => {
const { mintToken, getNewTxHash, getMintingTxParams } = mintScore({
address,
});
const lastTx = await mintToken({ ...mintData, tonConnect });
const txHash = await getNewTxHash(lastTx);
console.log(txHash);
const txParams = await getMintingTxParams(mintData);
console.log(txParams);
};
// Example usage of getMintedToken
const fetchMintedToken = async (address: string) => {
const token = await getMintedToken({ address });
console.log(token);
};
// Example usage of isScoreHolder
const checkScoreHolder = async (address: string) => {
const isHolder = await isScoreHolder({ address });
console.log(isHolder);
};