The Kinetic Client will give you access to all the methods you need to work with Kinetic on the blockchain.We recommend starting with Devnet before moving on to Mainnet.
Copy
import { KineticSdk } from '@kin-kinetic/sdk'const clientOptions = { environment: 'devnet', // the name of your environment, e.g. devnet, mainnet index: 1, // your App Index endpoint: 'https://app.altude.so', // devnet endpoint}const kineticClient = await KineticSdk.setup(clientOptions)
Don’t have an App Index? Join our Discord and we’ll get you started.While you’re waiting for confirmation of your App Index, use 1 on devnet so you can get started.
You can create accounts randomly or from existing mnemonics or secret keys. Below, we’ll make a keypair and use that for creating an account on the blockchain.
Copy
import { Keypair } from '@kin-kinetic/keypair'import { Commitment } from '@kin-kinetic/solana'const mnemonic = Keypair.generateMnemonic()const keypair = Keypair.fromSecret(mnemonic)const accountOptions = { owner: keypair, commitment: Commitment.Finalized, // Optional, can be Finalized, Confirmed, Processed}await kineticClient.createAccount(accountOptions)
Check a user balance by passing in the public key of the account you want to check.The response object includes your total balance as well as detailing all of the Mints and Tokens held by that Public Key.
import { Commitment, TransactionType } from '@kin-kinetic/solana';const transferOptions = { amount: '5000', destination: `BQJi5K2s4SDDbed1ArpXjb6n7yVUfM34ym9a179MAqVo`, owner: keypair, mint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v' // Optional, can be any token on Solana commitment: Commitment.Finalized, // Optional, can be Finalized, Confirmed, Processed type: TransactionType.P2P, // Optional, can be Unknown, None, Earn, Spend or P2P, reference: 'some reference'; // Optional, stored off-chain and returned via webhooks senderCreate: false; // Optional, will make a Token Account at that destination if true}await kineticClient.makeTransfer(transferOptions)
Note - reference is stored off chain and will be passed back to the app via webhooks if they are set up.
The balance webhook allows you to receive an alert when your app’s hotwallet is running low on Sol so you can top it up and ensure your app can continue to keep transacting.E.g. In a node express server:
Copy
app.use('/balance', async (req, res) => { const data = req.body // DO STUFF WITH THE BALANCE ALERT res.sendStatus(200)})
The verify webhook allows you to have fine-grained control over transactions, making sure they meet your own criteria before allowing them to proceed.E.g. In a node express server return a 200 status code to approve the transaction or a 400 to reject it:
Copy
app.use('/verify', async (req, res) => { const transaction = req.body // CHECK THAT YOU WANT THIS TRANSACTION TO PROCEED // e.g. if (transaction.amount < 1000000) { res.sendStatus(200) } res.sendStatus(400)})
Created to help get you up and running as quickly as possible, these projects can be a great reference point when you get stuck or even a starter for your own project. Happy coding!