Skip to main content

Overview

LangChain and LangGraph let you build AI agents with custom tools. You can create a Laso Finance tool that wraps the x402 payment flow, giving your LangChain agent the ability to order cards.

Prerequisites

  • Python 3.10+ or Node.js 18+
  • A funded agent wallet with USDC on Base or Solana (Locus, Sponge, or Ampersend)
  • langchain and langgraph installed

Python setup

1. Install dependencies

2. Create a Laso Finance tool

Define a custom LangChain tool that handles x402 payments:

3. Build the agent

TypeScript setup

1. Install dependencies

2. Create tools and agent

LangGraph for multi-step flows

For workflows that require polling (like waiting for card details), LangGraph’s state management is useful:

LangChain Tools Docs

Learn more about creating custom LangChain tools.