Documentation
You are in:TutorialDiscoverConnectTokenize (SDK)API Docs

TypeScript SDK

agentlaunch-sdk
v0.2.13

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

bash
npm install agentlaunch-sdk

Quick Start

01

Install the SDK

30s

npm install agentlaunch-sdk

02

Set your API key

1 min

Add AGENTLAUNCH_API_KEY to your environment. Get it from agentverse.ai/profile/api-keys.

03

Tokenize your agent

30s

Call client.tokenize() and share the handoffLink with a human to complete deployment.

typescript
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/42

Authentication

API Key required for write operations
Read operations (listTokens, getToken) work without a key. Write operations (tokenize) require an Agentverse API key.

Environment variable (recommended)

bash
# .envAGENTLAUNCH_API_KEY=your_agentverse_api_key

The SDK automatically reads AGENTLAUNCH_API_KEY from the environment.

Constructor option

typescript
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

typescript
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
All SDK errors are instances of AgentLaunchError. Catch this class to differentiate SDK errors from network failures.
typescript
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

UNAUTHORIZED
401
Invalid or missing API key
VALIDATION_ERROR
400
Missing or invalid request fields
NOT_FOUND
404
Token address or ID not found
CONFLICT
409
Token name or symbol already exists
RATE_LIMITED
429
Too many requests — check retryAfterMs
SERVER_ERROR
500
Server error — retry with backoff

TypeScript Types

All types are exported from the package root. The SDK is fully typed with no any.

typescript
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

New in v0.2.13+

Execute buys and sells directly on the bonding curve without a browser. Requires ethers@^6 as a peer dependency and a wallet private key.

Peer dependency required
On-chain trading uses ethers@^6 which is an optional peer dependency. Install it separately if you use buyTokens, sellTokens, or getWalletBalances.
bash
npm install agentlaunch-sdk ethers@^6

Environment variables

bash
# .envWALLET_PRIVATE_KEY=0xabc123...your_private_key_hereCHAIN_ID=97   # 97=BSC Testnet, 56=BSC Mainnet

WALLET_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.

typescript
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.

typescript
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.

typescript
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

typescript
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;
}

Build your first AI agent in 5 minutes

Create, deploy, and tokenize — all from your terminal.