TypeScript SDK
The official TypeScript SDK for agent-launch.ai. Three lines to tokenize your agent — no raw HTTP calls required. Includes on-chain trading: buy, sell, and balance queries.
Installation
npm install agentlaunch-sdkQuick Start
Install the SDK
30snpm install agentlaunch-sdk
Set your API key
1 minAdd AGENTLAUNCH_API_KEY to your environment. Get it from agentverse.ai/profile/api-keys.
Tokenize your agent
30sCall client.tokenize() and share the handoffLink with a human to complete deployment.
import { AgentLaunch } from 'agentlaunch-sdk';
const client = new AgentLaunch({ apiKey: process.env.AGENTLAUNCH_API_KEY });
const result = await client.tokenize({ agentAddress: 'agent1q...', // your Agentverse agent address name: 'MyBot', symbol: 'MYB', description: 'My AI agent token',});
console.log(result.handoffLink); // https://agent-launch.ai/deploy/42Authentication
Environment variable (recommended)
# .envAGENTLAUNCH_API_KEY=your_agentverse_api_keyThe SDK automatically reads AGENTLAUNCH_API_KEY from the environment.
Constructor option
import { AgentLaunch } from 'agentlaunch-sdk';
const client = new AgentLaunch({ apiKey: 'your_agentverse_api_key', // Optional overrides: baseUrl: 'https://agent-launch.ai/api', // default chainId: 97, // 97 = BSC Testnet, 56 = BSC Mainnet});Methods
| import { AgentLaunch } from 'agentlaunch-sdk'; |
| const client = new AgentLaunch({ apiKey: process.env.AGENTLAUNCH_API_KEY }); |
| const result = await client.tokenize({ |
| agentAddress: 'agent1q...', // required — your Agentverse agent address |
| name: 'TradingBot', // optional — max 32 chars (auto-fetched from Agentverse) |
| symbol: 'TBOT', // optional — 2–11 chars (auto-derived from name) |
| description: 'An autonomous trading agent for the ASI ecosystem.', // optional |
| image: 'https://example.com/logo.png', // optional — auto-generated if omitted |
| chainId: 97, // optional — 97 (testnet) | 56 (mainnet) |
| }); |
| console.log(result.tokenId); // 42 |
| console.log(result.handoffLink); // https://agent-launch.ai/deploy/42 |
Error Handling
AgentLaunchError. Catch this class to differentiate SDK errors from network failures.| import { AgentLaunch, AgentLaunchError } from 'agentlaunch-sdk'; |
| const client = new AgentLaunch({ apiKey: process.env.AGENTLAUNCH_API_KEY }); |
| try { |
| const result = await client.tokenize({ |
| agentAddress: 'agent1q...', |
| name: 'MyToken', |
| symbol: 'MTK', |
| description: 'My token', |
| }); |
| console.log(result.handoffLink); |
| } catch (err) { |
| if (err instanceof AgentLaunchError) { |
| switch (err.code) { |
| case 'UNAUTHORIZED': |
| console.error('Invalid API key — get one at agentverse.ai/profile/api-keys'); |
| break; |
| case 'VALIDATION_ERROR': |
| console.error('Invalid input:', err.details); |
| break; |
| case 'CONFLICT': |
| console.error('Token name/symbol already exists'); |
| break; |
| case 'RATE_LIMITED': |
| // Retry with exponential backoff |
| await new Promise((r) => setTimeout(r, err.retryAfterMs ?? 1000)); |
| break; |
| default: |
| console.error('Unexpected error:', err.message); |
| } |
| } else { |
| throw err; |
| } |
| } |
Error codes
UNAUTHORIZEDVALIDATION_ERRORNOT_FOUNDCONFLICTRATE_LIMITEDSERVER_ERRORTypeScript Types
All types are exported from the package root. The SDK is fully typed with no any.
| import type { |
| TokenizeParams, |
| TokenizeResult, |
| ListTokensParams, |
| ListTokensResult, |
| Token, |
| BondingCurve, |
| GenerateDeployLinkParams, |
| GenerateTradeLinkParams, |
| AuthenticateResult, |
| AgentLaunchConfig, |
| } from 'agentlaunch-sdk'; |
| // Full Token type |
| interface Token { |
| id: number; |
| name: string; |
| symbol: string; |
| description: string; |
| logo: string; |
| address: string | null; // null until deployed on-chain |
| status: 'pending' | 'bonding' | 'listed'; |
| chainId: number; |
| category: { id: number; name: string }; |
| creator: { address: string }; |
| bondingCurve: BondingCurve; |
| stats: { |
| holders: number; |
| transactions: number; |
| volume24h: string; |
| }; |
| links: { |
| platform: string; // https://agent-launch.ai/token/{address} |
| explorer: string; // BscScan / Etherscan link |
| dex: string | null; // PancakeSwap link when listed |
| }; |
| createdAt: string; |
| listedAt: string | null; |
| } |
| // BondingCurve type |
| interface BondingCurve { |
| currentPrice: string; // FET per token |
| totalRaised: string; // FET raised so far |
| targetLiquidity: string; // always "30000" |
| progress: number; // 0–100 percentage |
| tokensRemaining: string; // tokens still available on curve |
| priceAtTarget: string; // price when 30,000 FET target is hit |
| } |
On-Chain Trading
Execute buys and sells directly on the bonding curve without a browser. Requires ethers@^6 as a peer dependency and a wallet private key.
ethers@^6 which is an optional peer dependency. Install it separately if you use buyTokens, sellTokens, or getWalletBalances.npm install agentlaunch-sdk ethers@^6Environment variables
# .envWALLET_PRIVATE_KEY=0xabc123...your_private_key_hereCHAIN_ID=97 # 97=BSC Testnet, 56=BSC MainnetWALLET_PRIVATE_KEY is required for buyTokens and sellTokens. Use a dedicated testnet wallet — never commit private keys to source control.
buyTokens()
Execute a buy on a bonding curve token. Automatically approves FET spend, calculates slippage protection, and waits for confirmation.
| import { buyTokens } from 'agentlaunch-sdk'; |
| // Requires WALLET_PRIVATE_KEY env var (or pass privateKey in config) |
| const result = await buyTokens('0xF7e2F77f...', '10', { |
| chainId: 97, // BSC Testnet |
| slippagePercent: 5, // 5% slippage tolerance |
| }); |
| console.log(`Tx: ${result.txHash}`); |
| console.log(`Received: ${result.tokensReceived} tokens`); |
| console.log(`Fee: ${result.fee} FET`); |
sellTokens()
Execute a sell on a bonding curve token. No approval needed — tokens are sent directly to the contract.
| import { sellTokens } from 'agentlaunch-sdk'; |
| const result = await sellTokens('0xF7e2F77f...', '50000', { |
| chainId: 97, |
| }); |
| console.log(`Tx: ${result.txHash}`); |
| console.log(`Received: ${result.fetReceived} FET`); |
getWalletBalances()
Query BNB (gas), FET, and a specific token balance for the configured wallet. Useful for checking balances before trading.
| import { getWalletBalances } from 'agentlaunch-sdk'; |
| const balances = await getWalletBalances('0xF7e2F77f...'); |
| console.log(`BNB: ${balances.bnb}`); |
| console.log(`FET: ${balances.fet}`); |
| console.log(`Token: ${balances.token}`); |
On-chain type definitions
| import type { |
| OnchainConfig, |
| BuyResult, |
| SellResult, |
| WalletBalances, |
| ChainConfig, |
| } from 'agentlaunch-sdk'; |
| interface OnchainConfig { |
| privateKey?: string; // Falls back to WALLET_PRIVATE_KEY env var |
| chainId?: number; // 97 = BSC Testnet, 56 = BSC Mainnet. Default: 97 |
| slippagePercent?: number; // 0-100. Default: 5 |
| client?: AgentLaunchClient; // Optional — for calculateBuy/Sell API calls |
| } |
| interface BuyResult { |
| txHash: string; |
| tokensReceived: string; // tokens received (API estimate) |
| fetSpent: string; // FET amount spent |
| fee: string; // protocol fee in FET (2%, 100% to treasury) |
| priceImpact: number; |
| approvalTxHash: string | null; // FET approval tx hash (null if not needed) |
| blockNumber: number; |
| } |
| interface SellResult { |
| txHash: string; |
| fetReceived: string; |
| tokensSold: string; |
| fee: string; // protocol fee in FET (2%, 100% to treasury) |
| priceImpact: number; |
| blockNumber: number; |
| } |
| interface WalletBalances { |
| wallet: string; |
| bnb: string; // BNB balance (native gas token) |
| fet: string; // FET balance |
| token: string; // token balance |
| tokenAddress: string; |
| chainId: number; |
| } |