← minia2a.uk  ·  Blog

How to Give Your LangChain Agent a Wallet in 5 Minutes

August 6, 2026 · 7 min read · by Iris

Your LangChain agent can search the web, call LLMs, and query databases. But there's one thing it can't do: pay for things. Until now.

@minia2a/langchain gives your LangChain agents access to 299+ live x402 APIs — crypto data, web scraping, CAPTCHA solving, AI inference, and more — with 15 free trials per endpoint and automatic USDC payments when trials run out.

In this tutorial, you'll go from zero to a paying LangChain agent in 5 minutes.

🆕 Just launched: @minia2a/langchain v0.1.0. No API keys. No signup. npm install and go.

What You'll Build

A LangChain agent that can:

  1. Search a live marketplace of 299+ APIs by keyword
  2. Discover trending services agents are actually using
  3. Call any endpoint with automatic free trials (15 per endpoint)
  4. Pay with USDC on Base when trials run out (optional)

Step 1: Install

npm install @minia2a/langchain zod @langchain/core @langchain/openai

Three packages: the @minia2a/langchain toolkit, zod for schema validation (peer dependency), and LangChain core + your LLM of choice.

Step 2: Create the Toolkit

import { Minia2aToolkit } from "@minia2a/langchain";

const toolkit = new Minia2aToolkit({
  config: {
    autoTrial: true,           // Use 15 free trials per endpoint
    maxPricePerCall: 0.05,     // Max $0.05 per paid call (optional)
  }
});

That's it. autoTrial: true means your agent gets 15 free calls to every endpoint on the marketplace — no wallet, no USDC, no setup.

Step 3: Build the Agent

import { ChatOpenAI } from "@langchain/openai";
import { AgentExecutor, createOpenAIFunctionsAgent } from "langchain/agents";
import { ChatPromptTemplate } from "@langchain/core/prompts";

const llm = new ChatOpenAI({ model: "gpt-4o" });

const prompt = ChatPromptTemplate.fromMessages([
  ["system", `You are a helpful agent with access to the minia2a API marketplace.
Use search_minia2a_apis to find services by keyword.
Use call_minia2a_api to try them (auto-trial: 15 free calls each).
Use list_popular_minia2a_apis to see what's trending.
Always try an endpoint before reporting results — don't guess.`],
  ["human", "{input}"],
  ["placeholder", "{agent_scratchpad}"],
]);

const agent = await createOpenAIAccountFunctionsAgent({
  llm,
  tools: toolkit.getTools(),
  prompt,
});

const executor = new AgentExecutor({
  agent,
  tools: toolkit.getTools(),
  verbose: true,
});

Step 4: Use It

// Ask about crypto
const result1 = await executor.invoke({
  input: "What's the current Ethereum gas price? Find and use a gas API."
});
console.log(result1.output);
// → "The current Ethereum gas price is 12 gwei (low), 18 gwei (average),
//    25 gwei (high). Data from minia2a /x402/gas endpoint."

// Scrape a website
const result2 = await executor.invoke({
  input: "Scrape the headline from news.ycombinator.com"
});
console.log(result2.output);
// → "The top story on Hacker News right now is..."

// Discover trending APIs
const result3 = await executor.invoke({
  input: "What are the most popular APIs on minia2a right now?"
});
console.log(result3.output);
// → "The most popular APIs are: CAPTCHA solving (1,240 trials),
//    web recall/search (1,134 trials), gas prices (648 trials)..."

The Three Tools

ToolWhat It DoesExample
search_minia2a_apisSearch 299+ APIs by keyword or category"Find web scraping APIs"
call_minia2a_apiCall any endpoint with auto-trial + paymentCall /x402/gas for gas prices
list_popular_minia2a_apisBrowse trending and popular services"What's trending?"

How Free Trials Work

Every endpoint on minia2a offers 15 free trial calls. No wallet needed. No signup. The toolkit handles this automatically:

  1. Agent calls call_minia2a_api with an endpoint path
  2. The toolkit sends the request to minia2a.uk
  3. If trials remain → result returned immediately
  4. If trials exhausted → HTTP 402 Payment Required with price + wallet address
  5. If you've set maxPricePerCall > 0 and configured a wallet → payment auto-handled via x402
Real data: Across 9,000+ trials on minia2a, the top 10 endpoints capture 54% of all activity. The most popular are CAPTCHA solving, web recall/search, on-chain data lookup, and gas price APIs — exactly the kind of infrastructure tools agents need.

Adding Real Payments (Optional)

When you're ready to go beyond free trials, add a wallet:

import { Minia2aToolkit } from "@minia2a/langchain";

const toolkit = new Minia2aToolkit({
  config: {
    autoTrial: true,
    maxPricePerCall: 0.10,  // Willing to pay up to $0.10/call
  },
  wallet: {
    privateKey: process.env.AGENT_PRIVATE_KEY,  // Base wallet with USDC
    // Or use Cloudflare Wallets / Coinbase SDK
  }
});

The payment flow is fully automated:

  1. Agent gets 402 Payment Required
  2. Toolkit checks price against maxPricePerCall
  3. Signs and sends USDC on Base (~$0.003 gas, ~2s settlement)
  4. Retries with payment proof → receives result + receipt

With LangGraph

The toolkit works natively with LangGraph:

import { StateGraph, MessagesAnnotation } from "@langchain/langgraph";
import { ToolNode } from "@langchain/langgraph/prebuilt";
import { Minia2aToolkit } from "@minia2a/langchain";

const toolkit = new Minia2aToolkit();
const tools = toolkit.getTools();
const toolNode = new ToolNode(tools);

const graph = new StateGraph(MessagesAnnotation)
  .addNode("agent", agentNode)
  .addNode("tools", toolNode)
  .addEdge("__start__", "agent")
  .addConditionalEdges("agent", shouldContinue)
  .addEdge("tools", "agent")
  .compile();

// Stream agent decisions
for await (const chunk of await graph.stream({
  messages: [{ role: "user", content: "Find and use a CAPTCHA solver" }]
})) {
  console.log(chunk);
}

Real-World Use Cases

Here's what developers are actually building with agent+marketplace combinations:

Why This Matters

The agent economy is moving from "one agent, one API key" to "one agent, one wallet, any API." The x402 protocol — now under the Linux Foundation with 40+ member organizations including Visa, Mastercard, Stripe, Google, and Cloudflare — makes this possible. @minia2a/langchain is the bridge between LangChain agents and this new economy.

No more API key management. No more subscription overhead. Agents pay for what they use, when they use it.

Next Steps

  1. npm install @minia2a/langchain
  2. Run the quick start example above
  3. Browse the live marketplace (299 services, 375K+ requests)
  4. Register for 500 free credits
  5. Star the GitHub repo
🔗 Related packages: @minia2a/sdk (CLI for x402 devs) · minia2a-mcp (MCP server for Claude/Cursor) · @minia2a/elizaos-plugin-minia2a (ElizaOS plugin)