LangChain Implementation Example

This guide shows how to integrate Boson Protocol commerce capabilities into a LangChain AI agent. The bosonprotocol/agent-builder repository contains different AI agent examples using Boson tools, with the LangChain example at src/examples/standalone/langchain/index.ts.

Integration Code Snippets

1. Getting Boson Tools

import { bosonProtocolPlugin } from "@bosonprotocol/agentic-commerce";
import { BOSON_MCP_URL, CHAIN_MAP } from "@common/chains.ts";
import { getOnChainTools } from "@goat-sdk/adapter-langchain";
import { viem } from "@goat-sdk/wallet-viem";

// Get tools with the Boson Protocol plugin
const tools = await getOnChainTools({
  wallet: viem(walletClient),
  plugins: [bosonProtocolPlugin({ url: bosonMcpUrl })],
});

console.log(
  "Available tools:",
  tools.map((tool: any) => tool.name),
);

2. LangChain Agent Integration

Transaction Signing

The example shows how wallet setup enables automatic transaction signing through the GOAT SDK plugin:

When you provide this wallet client to the GOAT SDK plugin, it handles all transaction signing automatically when the agent calls Boson tools.

Required Environment Variables

Agent Usage Example

Key Dependencies

Additional Examples

Other framework implementations in the repository:

Next Steps

  1. Clone the Repository: Get the complete working example

  2. Set Environment Variables: Configure for your target network

  3. Optional - Local Development Setup: For local testing, fork the agentic-commerce repository and follow these steps:

    Step 1: Install and Build

    Step 2: Start E2E Services

    Step 3: Start MCP Server (New Terminal)

    Step 4: Optional - Start Inspector (New Terminal)

    Prerequisites:

    • Make sure you have .env file configured

    • Ensure mcpServer.json exists in project root

  4. Run the Example: Test the integration with your setup

Last updated