ମୁଖ୍ୟ ବିଷୟବସ୍ତୁକୁ ଛାଡ଼ନ୍ତୁ
ଲ୍ୟାଙ୍ଗଚେନ୍ ଇଣ୍ଟେଗ୍ରେସନ୍

LangChain ଅର୍ଥପ୍ରଦାନ ଇଣ୍ଟେଗ୍ରେସନ୍।

କୌଣସି LangChain ଏଜେଣ୍ଟକୁ USDC ଦେୟଗୁଡିକୁ ଯୋଗ କରନ୍ତୁ। ବାସ୍ତବ Python ପ୍ୟାକେଜ୍ ଏହାକୁ ୱାଲେଟ୍ ଟୁଲ୍ ଦେଇଥାଏ - ପଠାଇବା, ସେଟଲ୍ କରିବା, ଏବଂ ପଢିବା - କିଛି ଲାଇନ୍ ମଧ୍ୟରେ।

ସଂକ୍ଷିପ୍ତ ଉତ୍ତର

Blockchain0x ଏକ real Python package, , ଶିପ୍ କରେ, ଯାହା LangChain agent କୁ native wallet tools ଦିଏ: Base ରେ USDC ପଠାନ୍ତୁ, on-chain proof ସହିତ invoice settle କରନ୍ତୁ, ଏବଂ wallets ଏବଂ transactions ପଢ଼ନ୍ତୁ। Install କରନ୍ତୁ, ସେଟ୍ କରନ୍ତୁ, କଲ୍ କରନ୍ତୁ, ଏବଂ tools କୁ ଆପଣଙ୍କ agent କୁ ଦିଅନ୍ତୁ। TypeScript ରେ? କୌଣସି npm adapter ନାହିଁ - x402 client କୁ LangChain.js tool ମଧ୍ୟରେ wrap କରନ୍ତୁ।

କାହିଁକି ଓଡ଼ିଆ ଅଛି

Blockchain0x HTTP API ଉପରେ ଏକ ପତଳା ତଳ।

blockchain0x-langchain ରେ ପ୍ରତି ଟୁଲ୍ ଏକ ରୁପାରେ ଅଧିକାରୀ blockchain0x କୋର SDK ଉପରେ ଏକ ପତଳା ଓରାକଲ୍। କୌଣସି ପୁନର୍ନିର୍ମିତ REST କିମ୍ବା x402 ତର୍କ, କୌଣସି କୀ କଷ୍ଟୋଡୀ: ଏଡାପ୍ଟର ଆପଣଙ୍କର API କୀକୁ ବ୍ୟାକେଣ୍ଡକୁ ଫର୍ୱାର୍ଡ କରେ ଏବଂ ତାହାର କୌଣସି ସିକ୍ରେଟ୍ ଧରେ ନାହିଁ। create_blockchain0x_toolset(client) LangChain କୁ ପାଞ୍ଚ ଟୁଲ୍ ହାତରେ ଦେଇଥାଏ - ଏକ ଭୁଗତାନ ପଠାନ୍ତୁ, ଏକ ଇନଭଏସ୍ ସେଟଲ୍ କରନ୍ତୁ, ଏକ ୱାଲେଟ୍ ପଢନ୍ତୁ, ୱାଲେଟ୍ ତାଲିକା କରନ୍ତୁ, ଏକ ଲେନଦେନ ପଢନ୍ତୁ - ପ୍ରତିଟି ଆଗରୁ ଟାଇପ୍ ଏବଂ ସ୍କୋପ୍ କରାଯାଇଛି।

ଆପଣ ଚାହିଲେ raw API କିମ୍ବା core SDK କୁ ସିଧା କଲ୍ କରିପାରିବେ। adapter ହେଉଛି ସବୁଠାରୁ ସହଜ ପଥ; API ହେଉଛି contract। blockchain0x-langchain କୁ ସେ ଯେ langchain-core range ସମର୍ଥନ କରେ ସେଥିରେ pin କରନ୍ତୁ, ଦୁହିଁଟିର latest ପଛରେ ଧାଉନ୍ତୁ ନାହିଁ।

ଇନ୍ସ୍ଟଲେସନ୍

ଗୋଟିଏ ଇନ୍‌ସ୍ଟଲ୍। ଗୋଟିଏ ପରିବେଶ ଚଳକ। ପ୍ରସ୍ତୁତ।

ଏହି package କୁ Python 3.9 କିମ୍ବା ତାହାଠାରୁ ନୂତନ ଆବଶ୍ୟକ। ଏହା core blockchain0x SDK ଏବଂ langchain-core କୁ dependencies ଭାବେ ନେଇଆସେ; ଆଉ କିଛି ଯୋଡ଼ିବାକୁ ନାହିଁ।

ଇନ୍ସ୍ଟଲ୍
pip install blockchain0x-langchain
ପରିବେଶ ଚଳକଗୁଡିକ
export BLOCKCHAIN0X_API_KEY=sk_test_...   # sk_test_ = Base Sepolia, sk_live_ = Base mainnet

BLOCKCHAIN0X_API_KEY ହେଉଛି ଆପଣଙ୍କ Blockchain0x dashboard ରୁ ମିଳୁଥିବା sk_test_ testnet କିମ୍ବା sk_live_ mainnet key। ଏହାହିଁ adapter ଦ୍ୱାରା ଆବଶ୍ୟକ ଏକମାତ୍ର variable; ଏହା key କୁ backend କୁ ପଠାଏ ଏବଂ ନିଜସ୍ୱ କୌଣସି secret ରଖେ ନାହିଁ। ନିମ୍ନରେ ଦେଖାଯାଇଥିବା webhook handler ପାଇଁ ଆପଣ BLOCKCHAIN0X_WEBHOOK_SECRET ମଧ୍ୟ set କରନ୍ତି, ଯାହା dashboard webhook create କିମ୍ବା rotate କରିବାବେଳେ ଗୋଟିଏଥର ଦେଉଛି।

ସମ୍ପୂର୍ଣ୍ଣ ଏଜେଣ୍ଟ ଉଦାହରଣ

ପେମେଣ୍ଟ ସମର୍ଥନ ସହିତ କାମ କରୁଥିବା LangChain ଏଜେଣ୍ଟ।

ନିମ୍ନରେ Python ରେ ଏକ ସମ୍ପୂର୍ଣ୍ଣ LangChain agent ଅଛି। create_blockchain0x_toolset wallet tools ଫେରାଇଦିଏ, create_react_agent ସେଗୁଡିକୁ ReAct loop ରେ wire କରେ, ଏବଂ model prompt ରୁ ଠିକ୍ tool ବାଛେ। BLOCKCHAIN0X_API_KEY ସେଟ୍ କରନ୍ତୁ, run କରନ୍ତୁ, ଏବଂ agent Base ରେ USDC move ଏବଂ read କରିପାରିବ।

AGENT.PY
from blockchain0x import Client
from blockchain0x_langchain import create_blockchain0x_toolset
from langchain_openai import ChatOpenAI
from langgraph.prebuilt import create_react_agent

client = Client()  # reads BLOCKCHAIN0X_API_KEY from the environment
tools = create_blockchain0x_toolset(client)

llm = ChatOpenAI(model="gpt-4o")
agent = create_react_agent(llm, tools)

result = agent.invoke({
    "messages": [{
        "role": "user",
        "content": "Pay 0.01 USDC from my agent to 0xRecipient for the dataset.",
    }],
})

Run it with the prompt above and the model picks the send-payment tool, the SDK submits the transfer on Base, and you get a transaction hash back. amount_wei is USDC base units (6 decimals), so 0.01 USDC is the string "10000". A sk_test_ key keeps you on Base Sepolia until you switch to sk_live_. Heads up: payments.create can answer 503 until the chain adapter is wired for your network.

ୱେବ୍‌ହୁକ୍ ହ୍ୟାଣ୍ଡଲିଂ

ବ୍ୟବହାରକାରୀ ଦେୟ କରିବା ପରେ କଣ ଘଟେ।

ଆପଣଙ୍କ agent ର webhook URL (Blockchain0x dashboard ରେ ସେଟ୍ କରାଯାଇଥିବା) payment settle ହେଲେ ଗୋଟିଏ POST ଗ୍ରହଣ କରେ। webhook verify helper Node SDK ରେ ଅଛି, ସେଥିପାଇଁ ଆପଣଙ୍କ agent Python ହେଲେ ମଧ୍ୟ ଏହି handler TypeScript ରେ ଅଛି। ତଳେ ଗୋଟିଏ Express handler ଅଛି ଯାହା signature check କରେ ଏବଂ paid work ଚଲାଏ। ଯେକୌଣସି HTTP framework ରେ ସେହି pattern ବ୍ୟବହାର କରନ୍ତୁ।

ୱେବ୍‌ହୁକ୍-ହ୍ୟାଣ୍ଡଲର୍.TS
import express from "express";
import { webhooks } from "@blockchain0x/node";

const app = express();
// Capture the RAW body. The HMAC is over the exact bytes on the wire.
app.use(express.raw({ type: "application/json" }));

app.post("/webhooks/payment", (req, res) => {
  const result = webhooks.verify({
    headers: req.headers,
    rawBody: req.body, // Buffer, raw bytes
    secret: process.env.BLOCKCHAIN0X_WEBHOOK_SECRET!,
  });
  if (!result.ok) return res.status(400).json({ code: result.code });

  if (result.eventType === "payment.received") {
    // USDC landed in your agent wallet - do the paid work
  }
  res.status(200).send("ok");
});

webhooks.verify constant time ରେ HMAC-SHA256 କରେ ଏବଂ discriminated union ଫେରାଏ, ସେଥିପାଇଁ ଆପଣ try/catch ବିନା result.ok ଉପରେ branch କରନ୍ତୁ ଏବଂ result.eventType ପଢ଼ନ୍ତୁ। parsed copy ନୁହେଁ, raw body ପଢ଼ନ୍ତୁ: parse କରି ପୁନଃ serialize କଲେ signature ଭାଙ୍ଗିଯାଏ। shipped events ହେଉଛି payment.received, payment.sent, wallet.deployed, ଏବଂ webhook.test; ଆପଣଙ୍କ agent କୁ ଆସୁଥିବା inbound charge ହେଉଛି payment.received।

TYPESCRIPT? X402 CLIENT କୁ wrap କରନ୍ତୁ

କୌଣସି npm LangChain adapter ନାହିଁ। ଏହା ହେଉଛି ସତ୍ୟ recipe।

ship କରାଯାଇଥିବା LangChain adapter କେବଳ Python ପାଇଁ। npm ରେ କୌଣସି LangChain adapter ନାହିଁ। TypeScript LangChain କିମ୍ବା LangGraph agent ପାଇଁ, ଆପଣ real x402 client କୁ LangChain.js tool ଭିତରେ ନିଜେ wrap କରନ୍ତୁ। ଏହା କେବଳ କିଛି line, ଏବଂ dedicated adapter ଯେଉଁଟି under the hood କରିଥାନ୍ତା, ସେଇଥିକି କରେ।

PAY-TOOL.TS
import { createClient } from "@blockchain0x/node";
import { createX402Client } from "@blockchain0x/x402/client";
import { tool } from "@langchain/core/tools";
import { z } from "zod";

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

// There is no npm LangChain adapter. Wrap the x402 client in a LangChain.js tool.
export const payAndFetch = tool(
  async ({ url }) => (await fetchWithPay(url)).text(),
  {
    name: "pay_and_fetch",
    description: "Fetch a URL, answering any x402 payment challenge automatically",
    schema: z.object({ url: z.string().url() }),
  },
);

source ଏବଂ testnet example ଗୁଡ଼ିକ the Python SDK repo ରେ ଅଛି; SDK support matrix the docs ରେ ଅଛି। Python smoke example LangChain tool ଯେଉଁ send-payment action କୁ wrap କରେ, ସେହି ଏକେ action ମାଧ୍ୟମରେ Base Sepolia ଉପରେ ଗୋଟିଏ ପ୍ରକୃତ $0.01 USDC transfer ପଠାଏ।

ସାଧାରଣ ବିପଦ

ପ୍ରଥମ ସଂଯୋଜନରେ ଦାନ୍ତ କାଟିବାକୁ ଯୋଗ୍ୟ ପାଞ୍ଚ ଜିନିଷ।

ଏହାଗୁଡିକ ଆମର ସମର୍ଥନ ଇନବକ୍ସରୁ ଆସିଛି। ଏହାର କୌଣସି ଏକ ଦେଲ-ବ୍ରେକର ନୁହେଁ, କିନ୍ତୁ ଏହାଗୁଡିକୁ ପୂର୍ବରୁ ଜାଣିବା ଏକ ଘଣ୍ଟାର ମୁଣ୍ଡ ଘୁରାଇବା ସଂରକ୍ଷଣ କରେ।

PITFALL 1

ରାଶିଗୁଡ଼ିକ USDC base units ରେ, string ଭାବେ

The payment tools take amount_wei: a string of USDC base units, not a float and not a dollar figure. USDC has 6 decimals, so 0.01 USDC is "10000" and 5 USDC is "5000000". Always pass a string; large integers lose precision as JSON numbers. Send "5.00" and you will either get a validation error or move a millionth of what you meant.

PITFALL 2

invoice tool ଦେୟ ନିର୍ବାହ କରେ, ସୃଷ୍ଟି କରେ ନାହିଁ

blockchain0x_settle_invoice on-chain proof ସହିତ ଏକ EXISTING payment request କୁ settle କରେ। ନୂତନ invoice କିମ୍ବା hosted checkout link ସୃଷ୍ଟି କରିବାକୁ କୌଣସି tool ନାହିଁ: payment requests dashboard ରେ ସୃଷ୍ଟି ହୁଏ, ଏବଂ core SDK କେବଳ settlement ଦେଖାଏ। ଯଦି ଆପଣ agent କୁ on the fly ଏକ payable link ସୃଷ୍ଟି କରିବାକୁ ଆଶା କରୁଥିଲେ, ସେଟି ସେ ଆକାର ନୁହେଁ। Request କୁ out of band ସୃଷ୍ଟି କରନ୍ତୁ, ତାପରେ agent କୁ ସେହିଟି settle କରିବାକୁ ଦିଅନ୍ତୁ।

PITFALL 3

କଚା ଦେହ ବିପରୀତ ଓେଭୁକ୍ସକୁ ପରୀକ୍ଷା କରନ୍ତୁ

ଓେଭୁକ୍‌ଗୁଡିକ ଆପଣଙ୍କର URL କୁ POST କରେ, ଏବଂ ଯେକୌଣସି ଲୋକ ଯେଉଁଥିରେ ସେହି URL ଜାଣିଛି ସେହି ଜଙ୍କକୁ POST କରିପାରିବ। ଘଟଣାକୁ ବିଶ୍ୱାସ କରିବା ପୂର୍ବରୁ RAW ଅନୁରୋଧ ବାଇଟ୍‌ଗୁଡିକରେ @blockchain0x/node ରୁ webhooks.verify ଚଲାନ୍ତୁ। ପ୍ରଥମେ JSON କୁ ପାର୍ସ କରନ୍ତୁ ଏବଂ HMAC ମିଳିବ ନାହିଁ, କାରଣ ସାଇନ୍ ଆସିଥିବା ସଠିକ୍ ବାଇଟ୍‌ଗୁଡିକୁ ଆବରଣ କରେ। ଏହା HMAC-SHA256 ସହିତ 300-ସେକେଣ୍ଡ ରିପ୍ଲେ ୱିଣ୍ଡୋ ଅଟକାଇଥାଏ। ଏହାକୁ ଛାଡ଼ିବା ସାଧାରଣ ଉତ୍ପାଦନ ମିସ୍।

PITFALL 4

send_payment ପ୍ରାରମ୍ଭରେ 503 ଫେରାଇପାରେ

blockchain0x_send_payment ଯାହାକୁ wrap କରେ ସେହି payments.create default ଭାବରେ retry କରେ ନାହିଁ ଏବଂ chain adapter ଆପଣଙ୍କ network ପାଇଁ wired ହେଉପର୍ଯ୍ୟନ୍ତ 503 ଫେରାଇପାରେ। error ଉପରେ retry loop ରେ LLM କୁ tool କୁ ହାମର କରିବାକୁ ଦିଅନ୍ତୁ ନାହିଁ: ସେ tokens ଜଳାଇଦେଏ ଏବଂ ଆପଣଙ୍କ intent log କୁ ଧୁସର କରେ। built-in idempotency key ଉପରେ ଭରସା କରନ୍ତୁ, failure କୁ ସ୍ପଷ୍ଟ କରନ୍ତୁ, ଆଗକୁ ବଢ଼ନ୍ତୁ।

PITFALL 5

langchain-core version ସହ ମେଳ କରନ୍ତୁ

blockchain0x-langchain 0.1.x targets langchain-core >=0.2,<0.4. ଯଦି ଆପଣ adapter ସମର୍ଥନ କରୁଥିବାଠାରୁ ନୂତନ core ରେ ଅଛନ୍ତି, ଦୁହିଁଟିର latest ପଛରେ ଧାଉଥିବା ପ୍ରତିବଦଳରେ ମେଳ ମିଳୁଥିବା pair କୁ pin କରନ୍ତୁ। support matrix docs ରେ ଅଛି।

ପ୍ରାୟତଃ ପ୍ରଶ୍ନ

ତିନି LangChain-ନିର୍ଦ୍ଦିଷ୍ଟ ପ୍ରଶ୍ନ।

କି ମୋର ଏଜେଣ୍ଟ USDC ଗ୍ରହଣ କରିପାରିବ, କେବଳ ଏହାକୁ ପଠାଇବା ନୁହେଁ?

ହଁ, ଦୁଇଟି ଉପାୟ। Passive ଭାବେ: ଆପଣଙ୍କ agent ର wallet address ଏବଂ public page ଅଛି, ସେହିପାଇଁ କେହି ମଧ୍ୟ ଏହାକୁ pay କରିପାରେ ଏବଂ chain settle ହେଲେ payment.received webhook fire ହୁଏ। Active ଭାବେ: blockchain0x_settle_invoice dashboard ରେ ଆପଣ ତିଆରି କରିଥିବା payment request କୁ settle କରେ ଏବଂ on-chain proof record କରେ। ଯାହା ନାହିଁ ସେହେଲା agent ଭିତରୁ fresh invoice କିମ୍ବା hosted link mint କରୁଥିବା tool। request dashboard ରେ create କରନ୍ତୁ, agent କୁ ଏହା settle କରିବାକୁ ଦିଅନ୍ତୁ। ଅନେକ setup ଦୁଇଟିକୁ ଏକାସାଥିରେ ବ୍ୟବହାର କରନ୍ତି: tips ପାଇଁ public page, specific invoices ପାଇଁ settle tool।

ଏହା LangGraph ସହ କାମ କରେ କି?

ହଁ। create_blockchain0x_toolset standard LangChain tools ଫେରାଏ, ସେହିପାଇଁ ସେଗୁଡ଼ିକ create_react_agent (ଉପରେ ଦେଖାଯାଇଛି), AgentExecutor, କିମ୍ବା messages handle କରୁଥିବା ଯେକୌଣସି LangGraph node ଭିତରେ drop ହୁଏ, ଏବଂ checkpointing ଏବଂ human-in-the-loop ସହିତ compose ହୁଏ। ସେହି ହେଉଛି Python story। ଯଦି ଆପଣଙ୍କ LangGraph agent TypeScript ରେ ଅଛି, npm adapter ନାହିଁ: createX402Client (କିମ୍ବା @blockchain0x/node client) କୁ LangChain.js tool ରେ wrap କରନ୍ତୁ, ଉପର TypeScript recipe ପରି।

କେଉଁ ଚେନ୍ ଏବଂ ଟୋକେନ୍‌ଗୁଡିକୁ ସମର୍ଥନ କରାଯାଇଛି?

Base mainnet (sk_live_ keys) ଏବଂ Base Sepolia testnet (sk_test_ keys), 6 decimals ସହିତ USDC ରେ settle ହୁଏ। ଆଜିର ସମ୍ପୂର୍ଣ୍ଣ live surface ଏହିଟି: ଗୋଟିଏ chain family, ଗୋଟିଏ token। ଅନ୍ୟ chains roadmap ରେ ଅଛନ୍ତି, ଚାଲୁ ହୋଇନାହାନ୍ତି, ସେଥିପାଇଁ ଏବେଠାରୁ ସେଗୁଡ଼ିକ ଉପରେ design କରନ୍ତୁ ନାହିଁ। key prefix ଆପଣଙ୍କ ପାଇଁ network ବାଛେ, ଏବଂ sk_test_ key mainnet funds move କରିପାରେ ନାହିଁ, ଯାହା build କରୁଥିବାବେଳେ ଆପଣଙ୍କୁ ଆବଶ୍ୟକ guardrail।

ଆପଣଙ୍କର LangChain ଏଜେଣ୍ଟରେ ଦେୟଗୁଡିକୁ ଯୋଡନ୍ତୁ।

pip ସଂସ୍ଥାପନରୁ ଆପଣଙ୍କର ପ୍ରଥମ ଭୁଗତାନ ଅନୁରୋଧ ପାଇଁ କିଛି ମିନିଟ୍। ଆରମ୍ଭ କରିବାକୁ ମାଗଣା।