0.0.4-alpha • Published 9 months ago
@chainpro/sdk v0.0.4-alpha
ChainPro SDK
API Documentation available here
To get an API key to use the SDK with, go to https://chainpro.xyz/account/api
Then, use the API key name and private key to create a ChainProClient
import { ChainProClient } from "@chainpro/sdk";
const client = new ChainProClient("<key name>", "<private key>");Token Info
To get information about a token and its holders:
// single token
await client.getTokenInfo("2zMMhcVQEXDtdE6vsFS7S7D5oUodfJHE8vd1gnBouauv");
// supports many tokens
await client.getTokenInfo(
"2zMMhcVQEXDtdE6vsFS7S7D5oUodfJHE8vd1gnBouauv",
"0x0b3e328455c4059EEb9e3f84b5543F74E24e7E1b"
);
// get info about top holders
await client.getTokenTopHolders("2zMMhcVQEXDtdE6vsFS7S7D5oUodfJHE8vd1gnBouauv");Wallet Clusters
To get all of your clusters, call getWalletClusters(). To create a new cluster call createWalletCluster("friendly name", <# of wallets>)
Cluster Actions
Once you have a ChainProCluster, you can create and modify orders on it.
import { TokenNetwork } from "@chainpro/sdk";
// create the order
const intentId = await cluster.createLimitOrder(
"So11111111111111111111111111111111111111112",
"2zMMhcVQEXDtdE6vsFS7S7D5oUodfJHE8vd1gnBouauv",
TokenNetwork.Solana,
10000000n,
undefined,
"0.0005", // buy when price is over $0.0005
{
protectedTrade: true,
}
);
// check the status of the order
const intent = await client.getIntent(intentId);
const status = intent.tasks[0].status;
// delete an order
await client.deleteIntent(intent);