Skip to main content
HomeLanding pagesLangGraph wallet
LANDING PAGE

LangGraph wallet

8 min read·Last updated June 2, 2026

A LangGraph wallet is a reusable tool you put in your ToolNode that pays for what the graph calls. It wraps createX402Client from @blockchain0x/x402 (directly in LangGraph.js, via a local Node proxy in Python), settling any HTTP 402 in USDC on Base. Pair it with a read tool that loads the spend limit into graph state so nodes can plan around budget.

What the wallet tool is

A LangGraph wallet is a reusable tool that gives a graph the ability to pay. You place it in the graph's tool node, and when the model picks it, the graph routes there, runs it, and the tool settles any 402 in USDC on Base and returns the result. Because LangGraph builds on LangChain tools, the wallet tool is an ordinary LangChain tool; LangGraph just decides when the graph runs it.

There is no Blockchain0x LangGraph package. The wallet tool is a pattern you build from @blockchain0x/node and @blockchain0x/x402. This page is the focused artifact; for the broad integration overview, including modelling payment as a graph node, see langgraph-payments; the underlying LangChain tool is covered in langchain-wallet-tool. The payment API product page is the reference.

Build the tool for the ToolNode

The wallet tool wraps the x402 client (LangGraph.js) or the proxy (Python). Here is the LangGraph.js form, which calls the client directly.

TYPESCRIPT
import { DynamicStructuredTool } from "@langchain/core/tools";
import { ToolNode } from "@langchain/langgraph/prebuilt";
import { createClient } from "@blockchain0x/node";
import { createX402Client } from "@blockchain0x/x402/client";
import { z } from "zod";

const sdk = createClient({ apiKey: process.env.B0X_API_KEY! });
const fetchWithPay = createX402Client({ sdk });

export const walletTool = new DynamicStructuredTool({
  name: "pay_and_fetch",
  description: "Fetch a URL, paying in USDC if it requires payment. Returns the body.",
  schema: z.object({ url: z.string() }),
  func: async ({ url }) => {
    const res = await fetchWithPay(url);
    return res.ok ? await res.text() : `Failed: ${res.status}`;
  },
});

export const toolNode = new ToolNode([walletTool]);

Wire toolNode into your graph and the graph can pay. To the graph the wallet tool is just one of the tools in the node; the payment happens inside it, bounded by the wallet's spend limit. On Python, the tool body posts to a local proxy instead, and the rest is identical.

Load the limit into state

LangGraph's state is what makes a wallet feel native, so use it: load the agent's spend limit into state so nodes can plan around budget. Add a read tool (or a plain node) that does a GET to the spend-permissions endpoint and writes the result into state.

TYPESCRIPT
export const limitTool = new DynamicStructuredTool({
  name: "check_spend_limit",
  description: "Return this agent's current spend limit (per-transaction cap and period allowance).",
  schema: z.object({}),
  func: async () => {
    const res = await fetch(
      `https://api.blockchain0x.com/v1/agents/${process.env.AGENT_ID}/spend-permissions`,
      { headers: { Authorization: `Bearer ${process.env.B0X_API_KEY!}` } },
    );
    return await res.text(); // per_tx_wei, allowance_wei, period_seconds
  },
});

With the limit in state, a check node can read it on a conditional edge and route away from a paid call the agent cannot afford, which is the graph-native budget pattern from langgraph-payments made concrete. The limit is enforced on chain regardless, so this read is for smarter routing, not safety; the spend limit is the safety.

Per-agent wallets in a multi-agent graph

A LangGraph app often runs several agents, sometimes as subgraphs, and each should keep its own wallet. Build the wallet tool with a factory so each agent's tool is bound to that agent's key, and give each its own tool node.

TYPESCRIPT
export function makeWalletTool(apiKey: string) {
  const sdk = createClient({ apiKey });
  const fetchWithPay = createX402Client({ sdk });
  return new DynamicStructuredTool({
    name: "pay_and_fetch",
    description: "Fetch a URL, paying in USDC if required.",
    schema: z.object({ url: z.string() }),
    func: async ({ url }) => {
      const res = await fetchWithPay(url);
      return res.ok ? await res.text() : `Failed: ${res.status}`;
    },
  });
}

Give the research subgraph makeWalletTool(researchKey) and the writer subgraph makeWalletTool(writerKey), each in its own ToolNode. The dashboard attributes spend per agent, and a compromised agent can only spend its own balance. Shared code, separate accounts, which is what a multi-agent graph wants. On Python, run one proxy per agent and point each tool at its port.

Reuse across graphs

The point of building the tool once is reuse, so reuse it. The same walletTool (or the factory) goes into any graph that needs to pay, dropped into that graph's tool node without rewriting payment logic. A library of graphs across your app can all import one wallet-tool module, so a change to how payment works happens in one place.

This matters as the number of graphs grows. Rather than each new graph reinventing a paid fetch, it imports the wallet tool and adds it to its node, and the behavior, error handling, and identifiers stay consistent everywhere. Treat the wallet tool as a shared building block, the same way you treat any common tool, and the cost of giving a new graph the ability to pay drops to one import and one entry in its tool node.

Compatibility

Because the wallet tool is an ordinary LangChain tool, it works across LangGraph's surfaces.

LangGraph surface Works? Notes
ToolNode with the wallet tool Yes The common pay path
check_spend_limit read into state Yes Nodes plan budget from state
Multi-agent graph / subgraphs Yes One tool (and node) per agent via the factory
LangGraph.js vs Python Both TS calls the client directly; Python via a proxy
Prebuilt createReactAgent Yes Pass the wallet tool in its tools

When to use it

Reach for the wallet tool when a graph needs to pay for what it calls and you want that capability as one reusable unit dropped into a tool node rather than per-graph glue. It fits when several graphs or several agents share the same paying behavior, since you build the tool once and reuse it, and when payment should be a deliberate tool the graph routes to.

It is the wrong shape when only one specific tool should ever pay (wrap that tool's own call instead) or when the graph is purely internal with no paid calls. Match it to whether paying is a general capability the graph needs or a one-off behavior of a single tool.

The strongest case is a long-running graph that makes many paid calls and must stay within a budget. There the wallet tool gives it the ability to pay, the check_spend_limit read gives it awareness of the cap, and the graph's own nodes give it the control to stop before overspending. That combination, capability plus awareness plus control, is exactly what LangGraph's explicit structure is good at, and it is why a wallet tool plus a budget node beats a flat agent for anything cost-sensitive.

Pricing

The tool is free; you build it from open packages. What you pay is the wallet platform fee per agent on the pricing page: Free is $0 per agent per month at a 5% transaction fee, Pro is $9 at 2%, and Business is $29 at 1%. Per-agent pricing means each agent that transacts through the tool is billed on its own wallet, so a graph where only some agents pay only incurs fees for those agents.

What to ship today

Build pay_and_fetch (around createX402Client on LangGraph.js, around a proxy on Python), put it in a ToolNode, and make one paid call on Base Sepolia. Add check_spend_limit and load the limit into state if nodes should plan around budget. For multiple agents, use the factory. For the broad integration overview see langgraph-payments. Pricing is on the pricing page.

FAQ

Frequently asked questions.

Is there a LangGraph wallet package from Blockchain0x?

No. The wallet tool is a LangChain-style tool you build around createX402Client from @blockchain0x/x402 and place in your ToolNode. In LangGraph.js it calls the client directly; in Python LangGraph it calls a small local Node proxy, since the client is Node-only. There is no dedicated LangGraph adapter package; the tool is a pattern you assemble.

What does the wallet tool let the graph do?

Pay for what it calls. When the model picks the tool, the graph routes to the ToolNode, which runs it; the tool settles any HTTP 402 in USDC on Base and returns the result into the graph. That single pay-by-calling operation covers paying data APIs, paid tools, and other agents, bounded by the wallet's spend limit.

How is this different from the LangGraph payments page?

The payments page is the broad integration reference, including modelling payment as a graph node. This page is one concrete artifact: a reusable wallet tool for your ToolNode, plus a balance read that loads budget into state and a factory for per-agent wallets. Same client underneath; this is the tool you actually add.

Can the graph read its budget before paying?

Yes. Add a second tool (or node) that reads the agent's spend limit with a GET to the spend-permissions endpoint, and write the result into graph state. A node can then check that state on a conditional edge before routing to a paid call. The wallet's spend limit is still the hard backstop; the read is for in-graph planning.

Which network and token does it use?

USDC, 6 decimals, on Base. A sk_test_ key settles on Base Sepolia (eip155:84532), a sk_live_ key on Base mainnet (eip155:8453). The network is read from the key prefix, so the same tool works on either by swapping the key, in the client for LangGraph.js or on the proxy for Python.

Create your free agent wallet in 5 minutes.

First payment confirmed in under ten minutes. Free to start.