AI Agent SDK
The Etch AI Agent SDK lets autonomous agents create wallets, authenticate, and launch tokens with no human interaction. Use the API at https://etch.film.fun for production.
Installation
npm install @solana/web3.js bs58 tweetnaclCopy the SDK from the examples or use the reference below.
Configuration
import { EtchAIAgent } from './ai-agent-sdk';
// Production: use Etch API
const agent = new EtchAIAgent({
apiUrl: 'https://etch.film.fun'
});
// With existing wallet
const agent = new EtchAIAgent({
secretKey: process.env.AGENT_WALLET_SECRET,
apiUrl: 'https://etch.film.fun'
});Class: EtchAIAgent
Constructor
| Option | Type | Description |
|---|---|---|
secretKey | string | Base58 secret key (optional; generates new wallet if omitted) |
apiUrl | string | Etch API base URL (default: use https://etch.film.fun ) |
Methods
getPublicKey(): string
Returns the agent wallet’s public key (Solana address).
getSecretKey(): string
Returns the agent’s secret key as base58. Store securely!
authenticate(): Promise<string>
- Requests a challenge from
POST {apiUrl}/api/auth/challenge - Signs the message with the wallet
- Exchanges signature for JWT via
POST {apiUrl}/api/auth/verify
Returns the JWT token. Called automatically by launchToken and getLaunchStatus if needed.
launchToken(config): Promise<Launch>
Launches a new token. Config:
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Token name |
ticker | string | Yes | Symbol (e.g. AIGT) |
description | string | Yes | Description |
totalSupply | number | Yes | Total supply |
reservePercent | number | No | Reserve percentage (default 0) |
imageUrl | string | No | Token image URL |
Example:
const launch = await agent.launchToken({
name: 'AI Generated Token',
ticker: 'AIGT',
description: 'Autonomous token created by AI',
totalSupply: 1_000_000_000,
reservePercent: 20
});getLaunchStatus(launchId): Promise<Launch>
Polls GET {apiUrl}/api/launches/{launchId} for current status.
waitForLaunch(launchId, maxWaitMs?): Promise<Launch>
Polls every 2 seconds until status is success or failed. Default timeout 5 minutes.
listLaunches(): Promise<Launch[]>
Returns all launches for the agent’s wallet via GET {apiUrl}/api/launches?wallet=....
Launch Object
| Field | Type | Description |
|---|---|---|
id | string | Launch ID |
status | string | queued | processing | deploying | success | failed |
mint | string? | Token mint address (when success) |
pool | string? | Liquidity pool (when success) |
error | string? | Error message (when failed) |
Full Example
import { EtchAIAgent } from './ai-agent-sdk';
async function main() {
const agent = new EtchAIAgent({
apiUrl: 'https://etch.film.fun'
});
console.log('Agent Wallet:', agent.getPublicKey());
await agent.authenticate();
const launch = await agent.launchToken({
name: 'AI Generated Token',
ticker: 'AIGT',
description: 'Autonomous token created by AI',
totalSupply: 1_000_000_000,
reservePercent: 20
});
const completed = await agent.waitForLaunch(launch.id);
console.log('Token launched:', completed.mint);
}Multi-Agent Example
const agents = await Promise.all(
Array.from({ length: 5 }, () => new EtchAIAgent({
apiUrl: 'https://etch.film.fun'
}))
);
const launches = await Promise.all(
agents.map((agent, i) =>
agent.launchToken({
name: `Agent ${i + 1} Token`,
ticker: `AGT${i + 1}`,
description: `Token from AI Agent #${i + 1}`,
totalSupply: 1_000_000
})
)
);See Also
- AI Agent Guide — use cases, security, and patterns
- Authentication — auth API details
- Launch API — launch request/response reference
Last updated on