Skip to Content
@okito/sdk

@okito/sdk

The @okito/sdk package provides comprehensive utility functions for web3 developers building on Solana. This framework-agnostic toolkit exposes a wide range of functions that developers can use to build custom solutions, from token operations to NFT management and account interactions.

Choose Your Framework

Features

  • Token Management: Create, transfer, burn, and manage tokens
  • NFT Operations: Mint NFTs, manage metadata, and handle collections
  • Account Utilities: Get balances, transaction history, and account information
  • Airdrop Functions: Distribute tokens to multiple addresses efficiently
  • Framework Agnostic: Works with any JavaScript/TypeScript framework
  • TypeScript Support: Full type safety with comprehensive interfaces
  • Error Handling: Built-in error handling and validation
  • Network Support: Works with mainnet, devnet, and testnet

Installation

npm install @okito/sdk # or yarn add @okito/sdk # or pnpm add @okito/sdk

Quick Start

Basic Token Operations

import { createNewToken, transferTokens, getTokenBalanceByMint, burnToken } from '@okito/sdk'; // Create a new token const tokenData = { name: "My Token", symbol: "MTK", imageUrl: "https://example.com/image.png", initialSupply: 1000000000, decimals: 9, freezeAuthority: false, description: "This is my token", externalUrl: "https://example.com" }; const result = await createNewToken(wallet, connection, tokenData); console.log('Token created:', result.mintAddress); // Transfer tokens const transferResult = await transferTokens( wallet, connection, result.mintAddress, recipientAddress, 100 // amount ); // Get token balance const balance = await getTokenBalanceByMint( connection, wallet.publicKey, result.mintAddress ); console.log('Balance:', balance); // Burn tokens await burnToken( wallet, connection, result.mintAddress, 50 // amount to burn );

NFT Operations

import { createNFT } from '@okito/sdk'; const nftData = { name: "My NFT", symbol: "MNFT", description: "This is my NFT", image: "https://example.com/nft-image.png", attributes: [ { trait_type: "Color", value: "Blue" }, { trait_type: "Rarity", value: "Common" } ] }; const nftResult = await createNFT(wallet, connection, nftData); console.log('NFT created:', nftResult.mintAddress);

Airdrop Operations

import { airdropTokens, airdropTokensBatch } from '@okito/sdk'; // Single airdrop const airdropResult = await airdropTokens( wallet, connection, tokenMintAddress, recipientAddress, 100 // amount ); // Batch airdrop const recipients = [ { address: 'address1', amount: 100 }, { address: 'address2', amount: 200 }, { address: 'address3', amount: 150 } ]; const batchResult = await airdropTokensBatch( wallet, connection, tokenMintAddress, recipients );

Core Functions

Token Functions

createNewToken

Creates a new SPL token with metadata.

const result = await createNewToken(wallet, connection, tokenData);

Parameters:

  • wallet: Connected wallet instance
  • connection: Solana connection instance
  • tokenData: Token configuration object

Returns:

interface TokenCreationResult { mintAddress: string; transactionSignature: string; error?: string; }

transferTokens

Transfers tokens between accounts.

const result = await transferTokens( wallet, connection, mintAddress, recipientAddress, amount );

getTokenBalanceByMint

Gets token balance for a specific mint.

const balance = await getTokenBalanceByMint( connection, walletAddress, mintAddress );

burnToken

Burns tokens from an account.

const result = await burnToken( wallet, connection, mintAddress, amount );

NFT Functions

createNFT

Creates a new NFT with metadata.

const result = await createNFT(wallet, connection, nftData);

Parameters:

  • wallet: Connected wallet instance
  • connection: Solana connection instance
  • nftData: NFT configuration object

Account Functions

getTransactionHistory

Retrieves transaction history for an account.

const history = await getTransactionHistory( connection, walletAddress, limit // optional, defaults to 100 );

Airdrop Functions

airdropTokens

Airdrops tokens to a single recipient.

const result = await airdropTokens( wallet, connection, mintAddress, recipientAddress, amount );

airdropTokensBatch

Airdrops tokens to multiple recipients in a single transaction.

const result = await airdropTokensBatch( wallet, connection, mintAddress, recipients );

Configuration

Network Configuration

import { Connection, clusterApiUrl } from '@solana/web3.js'; // Mainnet const connection = new Connection(clusterApiUrl('mainnet-beta')); // Devnet (for development) const connection = new Connection(clusterApiUrl('devnet')); // Testnet const connection = new Connection(clusterApiUrl('testnet')); // Custom RPC endpoint const connection = new Connection('https://your-custom-rpc.com');

Wallet Configuration

import { useWallet } from '@solana/wallet-adapter-react'; // React hook const { wallet, connect, disconnect } = useWallet(); // Or direct wallet instance const wallet = { publicKey: publicKey, signTransaction: signTransaction, signAllTransactions: signAllTransactions };

Error Handling

The SDK includes comprehensive error handling:

try { const result = await createNewToken(wallet, connection, tokenData); if (result.error) { console.error('Token creation failed:', result.error); return; } console.log('Token created successfully:', result.mintAddress); } catch (error) { console.error('Unexpected error:', error); }

TypeScript Types

The package exports comprehensive TypeScript types:

// Token types export type { TokenData, TokenCreationResult, TransferResult, BurnResult } from '@okito/sdk'; // NFT types export type { NFTData, NFTCreationResult, NFTMetadata } from '@okito/sdk'; // Account types export type { TransactionHistory, AccountInfo } from '@okito/sdk'; // Airdrop types export type { AirdropRecipient, AirdropResult, BatchAirdropResult } from '@okito/sdk';

Best Practices

  1. Always validate inputs before calling SDK functions
  2. Handle errors gracefully with proper error messages
  3. Use appropriate networks (devnet for development, mainnet for production)
  4. Test thoroughly before deploying to production
  5. Keep private keys secure and never expose them in client-side code
  6. Use batch operations for multiple transactions when possible
  7. Monitor transaction fees and optimize for cost efficiency

Support

For questions, issues, or feature requests:

Last updated on