@cetusprotocol/launchpad-sdk
v1.2.0
Published
SDK for cetus launchpad
Readme
@cetusprotocol/launchpad-sdk
@cetusprotocol/launchpad-sdk is an SDK designed for interacting with the Cetus Protocol Launchpad, providing convenient methods to participate in token sales, query project information, and manage orders.
Getting Started
How to Use the Launchpad SDK ?
Installation
To start using the launchpad SDK, you first need to install it in your TypeScript project:
npm link: https://www.npmjs.com/package/@cetusprotocol/launchpad-sdk
npm install @cetusprotocol/launchpad-sdkSetup
Import the SDK into the TypeScript file where you intend to use it:
import { CetusLaunchpadSDK } from '@cetusprotocol/launchpad-sdk'Initializing the SDK
Initialize the SDK with the required configuration parameters. This typically includes setting up the network and API keys, if needed.
If you would like to use the mainnet network and the official Sui rpc url, you can do so as follows:
const sdk = CetusLaunchpadSDK.createSDK()If you wish to set your own full node URL or network (You have the option to select either 'mainnet' or 'testnet' for the network), you can do so as follows:
const env = 'mainnet'
const full_rpc_url = 'YOUR_FULL_NODE_URL'
const wallet = 'YOUR_WALLET_ADDRESS'
const sdk = CetusLaunchpadSDK.createSDK({ env })If you wish to set your own full node URL or SuiClient, you can do so as follows:
const sdk = CetusLaunchpadSDK.createSDK({ env, sui_client })
// or
const sdk = CetusLaunchpadSDK.createSDK({ env, full_rpc_url })Features & Usage
After linking your wallet, if you need use your wallet address to do something, you should set it by sdk.setSenderAddress.
const wallet = 'YOUR_WALLET_ADDRESS'
sdk.setSenderAddress(wallet)if you need to change your rpc url, you can do so as follows:
const new_rpc_url = 'YOUR_NEW_FULL_NODE_URL'
sdk.updateFullRpcUrl(new_rpc_url)Get all pools list
const pools = await router.getPools()Get Pool by pool id
const pool = await router.getPool('0xe914f2082ceda4583c93cdfda6bb269...')Get join pools by id
const all_pools = await router.getPools()
const join_pools = await router.getJoinPools('0xe914f2082ceda4583c93cdfda6bb2692c2620870570d4617e492f93aabd010fd', all_pools)Get your own pools
const all_pools = await router.getPools()
const owner_pools = await router.getOwnerPools(wallet, all_pools)Purchase
const send_key_pair = 'THE_KEY_PAIR_GENERATED_BY_YOUR_PRIVATE_KEY'
const pool = await router.getPool('0xe914f2082ceda4583c93cdfda6...')
const payload = await router.purchasePayload(pool, '0.1')
const result = await sdk.FullClient.sendTransaction(send_key_pair, payload)Withdraw
const pool = await router.getPool('0xe914f2082ceda4583c93cdfda6...')
const payload = await router.withdrawPayload(pool)
const result = await sdk.FullClient.sendTransaction(send_key_pair, payload)Redeem
const pool = await router.getPool('0xe914f2082ceda4583c93cdfda6...')
const payload = await router.redeemPayload(pool)
const result = await sdk.FullClient.sendTransaction(send_key_pair, payload)Get locked NFT list by pool id
const pool = await router.getPool('0xc85b81e7e4d218c1bdb58c79a8d8d4d7e...')
const nft_list = await router.getLockNFTList(pool)Determine whether the user is on the whitelist
const pool = await router.getPool('0xc85b81e7e4d218c1bdb58c79a8d8d4d7e...')
const is_white_list_user = await router.isWhiteListUser(wallet, pool)Get Purchase info by pool id
const pool = await router.getPool('0xc85b81e7e4d218c1bdb58c79a8d8d4d7e...')
const get_purchase_info = await router.getPurchaseInfo(wallet, pool)Get white protection info by pool id
const pool = await router.getPool('0xcd9163d840408445ff3703c7ada84c7e94b...')
const info = await router.getWhiteProtectionInfo('send_key_pair.getPublicKey().toSuiAddress()', pool)Calculate withdraw amount
const pool = await router.getPool('0xe914f2082ceda4583c93cdfda6bb269...')
const amount = await router.calculateWithdrawAmount(pool)More About Cetus
Use the following links to learn more about Cetus:
Learn more about working with Cetus in the Cetus Documentation.
Join the Cetus community on Cetus Discord.
License
MIT
