1.1.4 • Published 4 months ago

nomis-sdk v1.1.4

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

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 a sendTransaction 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 the SenderArguments 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!

1.1.7

4 months ago

1.1.6

4 months ago

1.1.5

4 months ago

1.1.4

4 months ago

1.1.2

8 months ago

1.1.1

9 months ago

1.1.0

9 months ago

1.0.10

9 months ago

1.0.9

11 months ago

1.0.8

11 months ago

1.0.7

11 months ago

1.0.6

11 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago