nomis-sdk v1.1.4
Nomis Ton Score 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-sdk
Methods
1. 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.
2. mintScore
Provides theree 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 asendTransaction
method.
Returns:
lastTx
(object instance of Transaction): The last transaction in the user's wallet.
getMintingTxParams
Prepares the transaction parameters required for minting a score token without tonconnect.
const txParams = await getMintingTxParams(mintData);
Parameters:
params: IMintData
- An object containing the necessary data for minting a score token.
Returns:
Promise<SenderArguments>
- A promise that resolves to theSenderArguments
object, which contains the prepared transaction parameters.
getNewTxHash
Obtains the transaction hash for the mintToken transaction.
const txHash = await getNewTxHash(lastTx);
Parameters:
lastTx
(object): The last transaction.
Returns:
txHash
(string): The transaction hash.
3. 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.
4. 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
Here’s a simple example of how to use the Nomis Ton Score SDK in your project:
import {
getScoreData,
mintScore,
getMintedToken,
isScoreHolder,
getMintingTxParams,
} from "nomis-sdk";
// Example usage of getScoreData
async function fetchScoreData(address) {
const { isUpdate, scoreData, scoreName, token, mintData } =
await getScoreData({ address });
console.log(scoreData);
/*
isUpdate: boolean;
scoreData: {
address: string;
mintData: MintData;
mintPrice: number;
referralCode: string;
referrerReward: number;
referrerAddress: string | null;
score: number;
scoreType: number;
stats: Stats;
signature: string | null;
};
mintData: {
calculationModel: number;
chainId: number;
deadline: number;
metadataUrl: string;
mintedChain: MintedChain;
mintedScore: number;
nonce: number;
referralCode: string;
referrerCode: string;
signature: string;
referrerAddress: string;
referrerReward: string
mintPrice: number
},
scoreName: string;
token: {
name: string;
score: number;
updated: number;
tokenId: number;
calculationModel: number;
chainId: number;
owner: string;
realTokenId: string;
}
*/
}
// Example usage of mintScore
async function mintScoreForWallet(address, tonConnect) {
const { mintToken, getNewTxHash, getMintingTxParams } = mintScore({
address,
});
const lastTx = await mintToken({ ...mintData, tonConnect });
const txHash = await getNewTxHash(lastTx);
console.log(txHash);
//string
const txParams = getMintingTxParams(mintData);
console.log(txParams);
/*
value: bigint;
to: Address;
body?: Maybe<Cell>;
*/
}
// Example usage of getMintedToken
async function fetchMintedToken(address) {
const token = await getMintedToken({ address });
console.log(token);
/*
name: string;
score: number;
updated: number;
tokenId: number;
calculationModel: number;
chainId: number;
owner: string;
realTokenId: string
*/
}
// Example usage of isScoreHolder
async function checkScoreHolder(address) {
const isHolder = await isScoreHolder({ address });
console.log(isHolder);
//boolean
}
// Example usage of mintScore
License
This project is licensed under the MIT License. See the LICENSE file for more details.
Contributing
Contributions are welcome! Please open an issue or submit a pull request for any bugs or features.
Support
If you have any questions or need help, please open an issue on our GitHub repository.
Authors
Enjoy using Nomis Ton Score SDK!
4 months ago
4 months ago
4 months ago
4 months ago
8 months ago
9 months ago
9 months ago
9 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago