typescript
/api/metrics
/api/uptime
/api/account/info/{environment}/{index}/{accountId}
/api/account/create
/api/account/balance/{environment}/{index}/{accountId}
/api/account/history/{environment}/{index}/{accountId}/{mint}
/api/account/token-accounts/{environment}/{index}/{accountId}/{mint}
/api/airdrop
/api/airdrop/stats
/api/app/{environment}/{index}/config
/api/app/{environment}/{index}/health
/api/app/{environment}/{index}/webhook/{type}
/api/config
/api/transaction/latest-blockhash/{environment}/{index}
/api/transaction/minimum-rent-exemption-balance/{environment}/{index}
/api/transaction/make-transfer
Kinetic TypeScript SDK
Learn how to use the Kinetic TypeScript SDK
Installation
yarn add @kin-kinetic/sdk @kin-kinetic/keypair @kin-kinetic/solana
Initialize SDK
Initialise the SDK so that you have access to all of Kinetic's methods.
import { KineticSdk, KineticSdkConfig } from '@kin-kinetic/sdk'
const config: KineticSdkConfig = {
environment: 'devnet',
index: 1
}
const sdk: KineticSdk = await KineticSdk.setup(config)
// Note - Setting up the Kinetic SDK is an async action
If you're self-hosting Kinetic, you can include an optional endpoint value pointing at your server.
Here's the config Type for reference:
export interface KineticSdkConfig {
index: number;
endpoint?: KineticSdkEndpoint;
environment: KineticSdkEnvironment;
logger?: KineticSdkLogger;
solanaRpcEndpoint?: string;
}
Generate a Keypair
A Keypair contains a 'secretKey' that you can use to sign transactions and a 'publicKey' that you can use as an address for paying towards or checking a balance, etc.
Using Keypair.random() will also return a mnemonic that you can use to recreate you wallet in other applications / wallets should you choose to do so.
import { Keypair } from '@kin-kinetic/keypair'
const keypair = Keypair.random()
const { mnemonic, secretKey, publicKey } = keypair;
Create a Kin Account
Use your keypair to create your account on the Solana blockchain.
const account = await sdk.createAccount({ owner: keypair })
Generate your keypair from your mnemonic for an existing account:
const keypair = Keypair.fromMnemonic(mnemonic);
Use the SDK with the Keypair
Get the balance
Use a publicKey to check your Kin balance.
const balance = await sdk.getBalance({ account: keypair.publicKey })
Request an Airdrop
Send Kin to a publicKey on the Solana devnet.
Airdrops take some time to complete as we make sure the transaction has been confirmed on the blockchain before returning a response.
const signature = await sdk.requestAirdrop({ account: keypair.publicKey, amount: '1000' })
Make a Transfer
Send Kin from a Keypair (as you need the privateKey) to a publicKey on the blockchain.
You can optionally set the commitment level before returning ('Confirmed', 'Finalized' or Processed), the transaction type, or add a referenceId / referenceType.
const result = await sdk.makeTransfer({
amount: "42",
destination: "ALisrzsaVqciCxy8r6g7MUrPoRo3CpGxPhwBbZzqZ9bA",
owner: keypair,
})
Here's the makeTransfer Type for reference:
makeTransfer({ amount, commitment, destination, owner, referenceId, referenceType, type, }: {
amount: string;
commitment?: Commitment;
destination: string;
owner: Keypair;
referenceId?: string;
referenceType?: string;
type?: TransactionType;
}): Promise<AppTransaction>;