Documentation

Build Autonomous AI Agents

Moltbuilds is an open-source framework for deploying AI agents that can research, trade, create content, and automate workflows across any platform.

Introduction

Moltbuilds provides a unified framework for building AI agents that operate autonomously across different domains. Whether you need an alpha hunter for crypto research, a content creator for social media, or a trading bot for DeFi, Moltbuilds handles the infrastructure so you can focus on strategy.

Fast Setup

Go from zero to deployed agent in under 5 minutes with our CLI tool.

Modular Design

Mix and match tools, integrations, and memory systems.

Secure by Default

Built-in guardrails, rate limiting, and sandboxed execution.

Multi-Platform

Deploy to Discord, Telegram, Slack, or run headless.

Quickstart

Get your first agent running in 3 steps:

  1. Install the CLI

    Install Moltbuilds globally using npm or your preferred package manager.

    bash
    npm install -g @moltbuilds/cli
  2. Initialize a new project

    Create a new agent project with your preferred template.

    bash
    moltbuilds init my-agent --template=alpha-hunter
  3. Configure and run

    Add your API keys to .env and start the agent.

    bash
    # Add your keys to .env
    OPENAI_API_KEY=sk-...
    TWITTER_API_KEY=...
    
    # Start the agent
    npm run start
Pro Tip

Use moltbuilds doctor to verify your configuration and check for common issues before deploying.

Installation

Requirements

  • Node.js 18.0 or higher (20+ recommended)
  • npm, pnpm, or bun
  • At least one LLM API key (OpenAI, Anthropic, or local model)

Package Managers

bash
npm install -g @moltbuilds/cli
bash
pnpm add -g @moltbuilds/cli
bash
bun add -g @moltbuilds/cli

Agent Types

Moltbuilds ships with 6 pre-configured agent templates, each optimized for specific use cases.

Agent Class Use Case
Alpha Hunter Research Scans CT, Discord, and on-chain data for alpha signals
Content Creator Creative Generates threads, memes, and social content
Trading Bot Finance Executes DCA, grid, and sniper strategies
Airdrop Farmer Hunter Tracks protocols and automates interactions
Code Architect Builder Writes and audits smart contracts
Data Sentinel Analytics Monitors whales and generates insights

Creating Custom Agents

You can extend the base agent class to create custom agents:

typescript
import { Agent, Tool } from '@moltbuilds/core';

export class MyCustomAgent extends Agent {
  name = 'custom-agent';
  description = 'My custom agent description';
  
  tools: Tool[] = [
    new WebScraperTool(),
    new AlertTool(),
  ];

  async onMessage(message: string) {
    // Handle incoming messages
    const response = await this.think(message);
    return response;
  }
}

Configuration

Agent configuration is stored in moltbuilds.config.ts at the root of your project.

typescript
import { defineConfig } from '@moltbuilds/core';

export default defineConfig({
  agent: {
    name: 'my-alpha-hunter',
    model: 'gpt-4o',
    temperature: 0.7,
  },
  
  memory: {
    type: 'vector',
    provider: 'pinecone',
    contextWindow: 32000,
  },
  
  tools: [
    'web-scraper',
    'sentiment-analyzer',
    'twitter-api',
  ],
  
  security: {
    rateLimit: 100,
    contentFilter: 'medium',
    sandboxed: true,
  },
});

Environment Variables

Sensitive configuration should be stored in .env:

env
# LLM Providers
OPENAI_API_KEY=sk-...
ANTHROPIC_API_KEY=sk-ant-...

# Integrations
TWITTER_API_KEY=...
TWITTER_API_SECRET=...
DISCORD_BOT_TOKEN=...

# Database
PINECONE_API_KEY=...
PINECONE_ENVIRONMENT=us-east-1
Security Warning

Never commit your .env file to version control. Use a secrets manager like AWS Secrets Manager or Doppler for production deployments.

Memory System

Moltbuilds provides three memory types for different use cases:

Buffer Memory

Stores recent messages in a sliding window. Best for simple conversational agents with short context needs.

Summary Memory

Periodically summarizes conversation history to compress context. Good balance of context retention and token efficiency.

Vector Memory

Stores embeddings in a vector database for semantic retrieval. Best for agents that need long-term memory and knowledge base access.

typescript
import { VectorMemory } from '@moltbuilds/memory';

const memory = new VectorMemory({
  provider: 'pinecone',
  index: 'agent-memory',
  embedModel: 'text-embedding-3-small',
  topK: 5,
});

// Store a memory
await memory.store('User prefers technical analysis over fundamentals');

// Retrieve relevant memories
const memories = await memory.retrieve('What trading style does the user prefer?');

Tools & Plugins

Tools extend your agent's capabilities. Moltbuilds includes 20+ built-in tools and supports custom plugins.

Built-in Tools

Tool Description
web-scraperExtract data from any webpage
browserFull browser automation with Puppeteer
calculatorMathematical computations
code-interpreterExecute Python/JS code safely
image-genGenerate images with DALL-E or Stable Diffusion
twitter-apiPost, reply, and search Twitter
discord-apiSend messages and manage servers
wallet-connectInteract with blockchain wallets

Creating Custom Tools

typescript
import { Tool, ToolInput } from '@moltbuilds/core';

export class PriceFetcherTool extends Tool {
  name = 'price-fetcher';
  description = 'Fetches current token prices from CoinGecko';
  
  schema = {
    token: { type: 'string', required: true },
  };

  async execute(input: ToolInput) {
    const response = await fetch(
      `https://api.coingecko.com/api/v3/simple/price?ids=${input.token}&vs_currencies=usd`
    );
    return response.json();
  }
}

LLM Providers

Moltbuilds supports multiple LLM providers out of the box:

  • OpenAI — GPT-4o, GPT-4 Turbo, GPT-3.5
  • Anthropic — Claude 3 Opus, Sonnet, Haiku
  • Google — Gemini Pro, Gemini Ultra
  • Local — Ollama, LM Studio, vLLM
Model Routing

Use model: 'auto' to let Moltbuilds automatically route requests to the best available model based on task complexity and cost.

Messaging Apps

Deploy your agent to any messaging platform with built-in adapters.

Discord

Full bot support with slash commands, reactions, and thread management.

Telegram

Bot API integration with inline keyboards and group chat support.

Slack

Workspace apps with channel posting, DMs, and app home tabs.

WhatsApp

Business API support for automated customer interactions.

Discord Setup

typescript
import { DiscordAdapter } from '@moltbuilds/adapters';

const discord = new DiscordAdapter({
  token: process.env.DISCORD_BOT_TOKEN,
  intents: ['Guilds', 'GuildMessages', 'DirectMessages'],
});

// Register slash commands
discord.registerCommand({
  name: 'ask',
  description: 'Ask the AI agent a question',
  handler: async (interaction) => {
    const response = await agent.chat(interaction.options.getString('question'));
    await interaction.reply(response);
  }
});

discord.start();

Telegram Setup

typescript
import { TelegramAdapter } from '@moltbuilds/adapters';

const telegram = new TelegramAdapter({
  token: process.env.TELEGRAM_BOT_TOKEN,
  allowedChats: ['@mychannel', -1001234567890],
});

telegram.on('message', async (ctx) => {
  const response = await agent.chat(ctx.message.text);
  await ctx.reply(response);
});

telegram.launch();

Blockchain Integrations

Connect your agents to Web3 with built-in blockchain support.

Supported Chains

Chain Features RPC Provider
Solana Token swaps, NFT minting, staking Helius, QuickNode
Ethereum Smart contracts, ERC-20, DeFi Alchemy, Infura
Base Low-cost transactions, L2 bridging Base RPC, Alchemy
Arbitrum DeFi protocols, fast finality Arbitrum RPC

Wallet Integration

typescript
import { SolanaWallet } from '@moltbuilds/blockchain';

const wallet = new SolanaWallet({
  rpcUrl: process.env.HELIUS_RPC_URL,
  privateKey: process.env.WALLET_PRIVATE_KEY,
});

// Get balance
const balance = await wallet.getBalance();
console.log(`Balance: ${balance} SOL`);

// Swap tokens via Jupiter
const tx = await wallet.swap({
  inputMint: 'So11111111111111111111111111111111111111112', // SOL
  outputMint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', // USDC
  amount: 0.1,
  slippage: 0.5,
});

console.log(`Swap tx: ${tx.signature}`);

On-Chain Data

typescript
import { DuneClient, BirdeyeClient } from '@moltbuilds/data';

// Query Dune Analytics
const dune = new DuneClient(process.env.DUNE_API_KEY);
const whales = await dune.query(3156732); // Top SOL holders

// Get token price from Birdeye
const birdeye = new BirdeyeClient(process.env.BIRDEYE_API_KEY);
const price = await birdeye.getPrice('So11111111111111111111111111111111111111112');
Security Warning

Never expose private keys in code. Always use environment variables and consider using a hardware wallet or MPC solution for production deployments.

API Overview

The Moltbuilds API follows RESTful conventions and uses JSON for all requests and responses.

Base URL

text
https://api.moltbuilds.dev/v1

Authentication

All API requests require a Bearer token in the Authorization header:

bash
curl -X POST https://api.moltbuilds.dev/v1/agents \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "my-agent", "template": "alpha-hunter"}'

Agents API

Manage agent lifecycle programmatically.

Endpoints

Method Endpoint Description
POST /agents Create a new agent
GET /agents List all agents
GET /agents/:id Get agent details
PATCH /agents/:id Update agent config
DELETE /agents/:id Delete an agent
POST /agents/:id/chat Send message to agent
POST /agents/:id/start Start agent runtime
POST /agents/:id/stop Stop agent runtime

Create Agent

bash
curl -X POST https://api.moltbuilds.dev/v1/agents \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "my-alpha-hunter",
    "template": "alpha-hunter",
    "model": "gpt-4o",
    "tools": ["web-scraper", "twitter-api"],
    "config": {
      "temperature": 0.7,
      "maxTokens": 4096
    }
  }'

Response

json
{
  "id": "agt_abc123",
  "name": "my-alpha-hunter",
  "status": "created",
  "template": "alpha-hunter",
  "model": "gpt-4o",
  "tools": ["web-scraper", "twitter-api"],
  "createdAt": "2024-01-15T10:30:00Z"
}

Chat with Agent

bash
curl -X POST https://api.moltbuilds.dev/v1/agents/agt_abc123/chat \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "message": "Find the top trending tokens on Solana today",
    "stream": false
  }'

Tools API

Manage and invoke tools directly via the API.

Endpoints

Method Endpoint Description
GET /tools List available tools
GET /tools/:name Get tool schema
POST /tools/:name/invoke Execute a tool
POST /tools/register Register custom tool

Invoke Tool

bash
curl -X POST https://api.moltbuilds.dev/v1/tools/web-scraper/invoke \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com",
    "selector": ".main-content",
    "format": "markdown"
  }'

Response

json
{
  "success": true,
  "tool": "web-scraper",
  "result": {
    "content": "# Page Title\n\nExtracted content here...",
    "metadata": {
      "url": "https://example.com",
      "scrapedAt": "2024-01-15T10:30:00Z",
      "contentLength": 2450
    }
  },
  "executionTime": 1234
}

Register Custom Tool

bash
curl -X POST https://api.moltbuilds.dev/v1/tools/register \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "price-alert",
    "description": "Set price alerts for tokens",
    "schema": {
      "token": { "type": "string", "required": true },
      "targetPrice": { "type": "number", "required": true },
      "direction": { "type": "string", "enum": ["above", "below"] }
    },
    "webhookUrl": "https://your-server.com/webhook/price-alert"
  }'

Examples

Real-world examples to get you started quickly.

Alpha Hunter Bot

A complete example of an alpha hunting agent that monitors Twitter and Discord for signals.

typescript
import { Agent, WebScraperTool, TwitterTool, AlertTool } from '@moltbuilds/core';
import { TelegramAdapter } from '@moltbuilds/adapters';

const agent = new Agent({
  name: 'alpha-hunter',
  model: 'gpt-4o',
  systemPrompt: `You are an alpha hunter that finds early crypto opportunities.
    Monitor social signals, analyze sentiment, and alert on high-conviction plays.`,
  tools: [
    new WebScraperTool(),
    new TwitterTool({ apiKey: process.env.TWITTER_API_KEY }),
    new AlertTool({ webhook: process.env.ALERT_WEBHOOK }),
  ],
});

// Schedule hourly scans
agent.schedule('0 * * * *', async () => {
  const signals = await agent.chat('Scan Twitter for trending crypto tokens and analyze sentiment');
  console.log(signals);
});

// Connect to Telegram
const telegram = new TelegramAdapter({ token: process.env.TELEGRAM_BOT_TOKEN });
telegram.connect(agent);
telegram.launch();

Trading Bot with DCA

An automated trading agent with dollar-cost averaging strategy.

typescript
import { Agent } from '@moltbuilds/core';
import { SolanaWallet, JupiterSwap } from '@moltbuilds/blockchain';

const wallet = new SolanaWallet({
  rpcUrl: process.env.HELIUS_RPC_URL,
  privateKey: process.env.WALLET_PRIVATE_KEY,
});

const jupiter = new JupiterSwap(wallet);

const agent = new Agent({
  name: 'dca-bot',
  model: 'gpt-4o',
  tools: [wallet, jupiter],
});

// DCA: Buy $10 of SOL every day at 9am
agent.schedule('0 9 * * *', async () => {
  const result = await jupiter.swap({
    inputMint: 'USDC',
    outputMint: 'SOL',
    amount: 10,
    slippage: 0.5,
  });
  console.log(`DCA executed: ${result.signature}`);
});

agent.start();

Content Creator Agent

An agent that generates and schedules social media content.

typescript
import { Agent, ImageGenTool, TwitterTool } from '@moltbuilds/core';

const agent = new Agent({
  name: 'content-creator',
  model: 'gpt-4o',
  systemPrompt: `You are a crypto content creator. Create engaging threads,
    memes, and educational content about DeFi and blockchain.`,
  tools: [
    new ImageGenTool({ provider: 'dall-e-3' }),
    new TwitterTool({ 
      apiKey: process.env.TWITTER_API_KEY,
      apiSecret: process.env.TWITTER_API_SECRET,
    }),
  ],
});

// Generate and post a thread
const thread = await agent.chat(`
  Create a Twitter thread explaining liquid staking on Solana.
  Make it educational but engaging. Include relevant emojis.
  Generate a header image for the thread.
`);

console.log(thread);
More Examples

Check out the examples repository for 20+ complete agent implementations including airdrop farmers, whale watchers, and portfolio trackers.

Changelog

Recent updates and improvements to Moltbuilds.

v2.4.0 — January 2024

  • New: Added Base and Arbitrum blockchain support
  • New: WhatsApp Business API adapter
  • New: Claude 3 Opus and Sonnet model support
  • Improved: 40% faster tool execution pipeline
  • Fixed: Memory leak in long-running vector store queries

v2.3.0 — December 2023

  • New: Scheduled tasks with cron syntax
  • New: Multi-agent orchestration support
  • New: Built-in rate limiting and retry logic
  • Improved: TypeScript types for all APIs
  • Fixed: Discord slash command registration race condition

v2.2.0 — November 2023

  • New: Jupiter aggregator integration for Solana swaps
  • New: Dune Analytics data tool
  • New: Image generation with DALL-E 3
  • Improved: Context window management for long conversations
  • Fixed: Telegram inline keyboard callback handling

v2.1.0 — October 2023

  • New: Vector memory with Pinecone and Weaviate
  • New: Slack workspace app adapter
  • New: Custom tool plugin system
  • Improved: CLI initialization wizard
  • Fixed: OpenAI API streaming responses

v2.0.0 — September 2023

  • Breaking: Complete rewrite with new architecture
  • New: Agent templates (Alpha Hunter, Trading Bot, etc.)
  • New: Discord and Telegram adapters
  • New: Solana wallet integration
  • New: Web scraping and browser automation tools
Stay Updated

Follow @moltbuilds on Twitter or join our Discord to get notified about new releases and features.