Kohin SDK
The Kohin SDK is a comprehensive developer toolkit designed to integrate Kohin's decentralized insurance system seamlessly into your applications. It enables efficient interaction with Kohin smart contracts and backend APIs, facilitating management and analytics for user bets, coverage, and liquidity pools.
Installation
npm install kohin-sdk
Requirements
- Access Key and Secret Key
- Polygon Network RPC URL
Network Support
- Test: Polygon Amoy (Chain ID: 80002)
- Pre-Production: Polygon (Chain ID: 137)
- Production: Polygon Mainnet
Quick Start
import { Kohin } from "kohin-sdk";
const kohin = new Kohin({
accessKey: "<ACCESS_KEY>",
secretKey: "<SECRET_KEY>",
rpcUrl: "<RPC_URL>",
envMode: "<ENV_MODE>",
});
Core Features
Betting Operations
const activeBets = await kohin.getActiveBetData({
bettorAddress: "0x...",
pageCount: 1,
});
const details = await kohin.getBetDetails({
betId: "0x...",
});
const history = await kohin.getOddsHistory({
conditionId: "0x...",
});
Insurance Operations
const premium = await kohin.calculatePremium({
betId: 123,
betType: "Combo",
odds: 2.5,
betAmount: 100,
numLegs: 2,
});
const cover = await kohin.buyCover({
betId: 123,
betAmount: 100,
betType: "Combo",
slippagePercent: 5,
coverPremium: BigInt(1000000),
});
Liquidity Management
await kohin.approveAmount({ amount: 1000 });
const deposit = await kohin.addLiquidity({ amount: 1000 });
const withdrawal = await kohin.removeLiquidity({
depositId: 1099511627894,
percent: 16,
});
Response Types
All methods return a consistent response format:
interface ResponseData<T> {
success: boolean;
data?: T;
error?: string;
}
Error Handling
try {
const result = await kohin.someOperation(params);
if (result.success) {
} else {
}
} catch (error) {
}
Dependencies
- viem: Web3 interactions
- axios: API requests
- typescript: Type definitions
Security Best Practices
- Store credentials securely
- Validate all transaction parameters
- Maintain sufficient gas for transactions
License
MIT