ଆପଣଙ୍କର AI ଏଜେଣ୍ଟକୁ ଅର୍ଥପ୍ରଦାନ କିପରି ଯୋଗ କରିବେ।
createClient କୁ @blockchain0x/node (କିମ୍ବା Python client)ରୁ ଏକ ଏଜେଣ୍ଟ ସୃଷ୍ଟି କର, payments.create ସହିତ USDC ଦେୟ ପଠାଇ, ଏବଂ webhooks.verify ସହିତ ସାଇନ୍ କରାଯାଇଥିବା ଓବ୍ହେକ୍ କୁ ନିଶ୍ଚୟ କର। ବ୍ୟୟ ନିୟନ୍ତ୍ରଣଗୁଡିକ ଡ୍ୟାସ୍ବୋର୍ଡ୍ରେ ସେଟ୍ କରାଯାଇଛି ଏବଂ API ଉପରେ ପଢ଼ିବାକୁ ମାତ୍ର। ଏଜେଣ୍ଟ କେବଳ ଗୋପନ କୀଗୁଡିକୁ ସିଧାସଳକ ଚୁଇଁନାହିଁ। ସାଇନ୍-ଅପ୍ କରିବାରୁ ଦଶ ମିନିଟ୍ ମଧ୍ୟରେ Base ଉପରେ ତୁମର ପ୍ରଥମ USDC ଦେୟ, TypeScript କିମ୍ବା Python ରେ।
ଆପଣ ଆରମ୍ଭ କରିବା ପୂର୍ବରୁ।
- ଏକ Blockchain0x account (free signup)।
- ଡ୍ୟାଶବୋର୍ଡରୁ ଏକ API key (ଏହି ଗାଇଡ ପାଇଁ ଏକ
sk_test_key ବ୍ୟବହାର କରନ୍ତୁ; ପରେ ଆପଣsk_live_କୁ ସ୍ୱିଚ୍ କରିବେ)। - ଆପଣଙ୍କ agent runtime ରେ Node.js 20+ କିମ୍ବା Python 3.11+.
- ଯେକୌଣସି framework - LangChain, CrewAI, AutoGen, LlamaIndex, OpenAI Agents SDK, MCP, କିମ୍ବା ସାଧାରଣ SDK code ଉପରେ ନିର୍ମିତ ଏକ agent। ନିର୍ଦ୍ଦେଶଗୁଡ଼ିକ framework-agnostic ଅଟେ।
- webhook ଗ୍ରହଣ କରିବା ପାଇଁ ସାର୍ବଜନୀନ internet ରୁ ପହଞ୍ଚଯୋଗ୍ୟ ଏକ HTTPS endpoint (development ପାଇଁ ngrok କିମ୍ବା deploy preview ଠିକ୍ ଅଟେ)।
ଏଜେଣ୍ଟ ପ୍ରୋଫାଇଲ୍ ସୃଷ୍ଟି କରନ୍ତୁ।
agent profile ହେଉଛି ଆପଣଙ୍କ agent ଯେ ପ୍ରତ୍ୟେକ payment ପଠାଏ କିମ୍ବା ଗ୍ରହଣ କରେ, ସେହାର ପଛରେ ଥିବା addressable identity। ଏଥିରେ wallet address, public page, verification badges, ଏବଂ (ପରେ) spend policy ଅଛି। ପ୍ରତ୍ୟେକ logical agent ପାଇଁ ଗୋଟିଏ create କରନ୍ତୁ।
import { createClient } from "@blockchain0x/node";
const client = createClient({ apiKey: process.env.BLOCKCHAIN0X_API_KEY! }); // sk_test_ / sk_live_
const agent = await client.agents.create({ name: "research-bot" });
console.log(agent.id); // "agt_..."
// Public page: https://wallet.blockchain0x.com/a/{slug}from blockchain0x import Client
client = Client() # reads BLOCKCHAIN0X_API_KEY from the environment
agent = client.agents.create(body={"name": "research-bot"})
print(agent["id"]) # "agt_..."
# Public page: https://wallet.blockchain0x.com/a/{slug}After this call, the agent has a public page at https://wallet.blockchain0x.com/a/<slug> that any counterparty (human or agent) can hover for verification info. See the agent payment identity glossary entry for what that page exposes.
ଗୋଟିଏ payment ପଠାନ୍ତୁ।
payments.create sends USDC from the agent wallet. amountWei is base units (USDC has 6 decimals), so 0.01 USDC is the string "10000". The SDK auto-stamps an Idempotency-Key, and the call can return 503 until the chain adapter is wired for your network. To RECEIVE instead, settle an invoice you created in the dashboard with paymentRequests.settle - see the payment API page.
// Send a USDC payment from the agent wallet. amountWei is base units
// (USDC has 6 decimals): "10000" is 0.01 USDC. payments.create auto-stamps an
// Idempotency-Key and can return 503 until the chain adapter is wired.
const tx = await client.payments.create({
agentId: agent.id,
to: "0xRecipient",
amountWei: "10000",
});
console.log(tx); // the submitted transfer# amountWei is USDC base units (6 decimals): "10000" is 0.01 USDC.
tx = client.payments.create(body={
"agentId": agent["id"],
"to": "0xRecipient",
"amountWei": "10000",
})
print(tx) # the submitted transferୱେବହୁକ୍ କୁ ହ୍ୟାଣ୍ଡଲ୍ କରନ୍ତୁ।
ଓେଭୁକ୍ଗୁଡିକ ହେଉଛି କିପରି ଆପଣ ଜାଣିବେ ଯେ ଏକ ଦେୟ ସମାଧାନ ହୋଇଛି। Node ରେ, @blockchain0x/node ରୁ webhooks.verify HMAC ଚେକ୍ କରେ ଏବଂ ଏକ ଭିନ୍ନ ଯୁଗ୍ମକୁ ଫେରାଇବା; ଅନ୍ୟ ଭାଷାରେ, କଚା ଦେହରେ ସେହି HMAC କୁ ଗଣନା କରନ୍ତୁ। ଘଟଣା ପ୍ରକାର (inbound ପାଇଁ payment.received) ଉପରେ ଶାଖା କରନ୍ତୁ, 2xx ଦ୍ରୁତ ଭାବେ ପ୍ରତିକ୍ରିୟା କରନ୍ତୁ, ଏବଂ 2xx ର ପଛରେ କିଛି ଭାରୀ କୁ କ୍ୟୁ କରନ୍ତୁ ଯାହା ଡିଲିଭରୀ ସମୟ ସମାପ୍ତ ହେବାକୁ ନାହିଁ।
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 - deliver the work, fulfil the order, etc.
void deliver(result.eventId);
}
res.status(200).send("ok");
});import hmac, hashlib, os, time
from flask import Flask, request, abort
app = Flask(__name__)
SECRET = os.environ["BLOCKCHAIN0X_WEBHOOK_SECRET"].encode()
@app.post("/webhooks/payment")
def webhook():
raw = request.get_data() # RAW bytes - do not parse first
sig = request.headers.get("X-Blockchain0x-Signature", "")
ts = request.headers.get("X-Blockchain0x-Timestamp", "")
parts = dict(p.split("=", 1) for p in sig.split(",") if "=" in p)
t, v1 = parts.get("t", ts), parts.get("v1", sig)
want = hmac.new(SECRET, t.encode() + b"." + raw, hashlib.sha256).hexdigest()
if not hmac.compare_digest(want, v1) or abs(time.time() - int(t)) > 300:
abort(401)
if request.headers.get("X-Blockchain0x-Event-Type") == "payment.received":
deliver(request.get_json()) # USDC landed
return ("ok", 200)Dashboard ରେ spend controls ସେଟ୍ କରନ୍ତୁ।
ଯଦି ଆପଣଙ୍କ agent କେବଳ receive କରେ, ଏହାକୁ skip କରିପାରିବେ। ଯଦି ଏହା pay ମଧ୍ୟ କରେ, dashboard ରେ spend permission - ପ୍ରତି period allowance ଏବଂ ପ୍ରତି transaction cap - ସେଟ୍ କରନ୍ତୁ। ଏହା ପ୍ରତ୍ୟେକ payment ରେ backend ଦ୍ୱାରା enforced ହୁଏ, ସେଥିପାଇଁ agent-side rules କେବେ ବଞ୍ଚି ପାରିବା ନୁହେଁ ଭାବରେ prompt injection କୁ survive କରେ। permission କୁ mutate କରିବାକୁ କୌଣସି API କିମ୍ବା SDK call ନାହିଁ (agent ର ନିଜ key ତାହାର limit ବଢ଼ାଇ ପାରେ ନାହିଁ); API read-only, ତେଣୁ ଆପଣଙ୍କ code ଏବର current values ନେଇ display କିମ୍ବା plan କରିପାରିବ।
curl https://api.blockchain0x.com/v1/agents/agt_123/spend-permissions \
-H "Authorization: Bearer $BLOCKCHAIN0X_API_KEY"{
"allowance_wei": "5000000",
"per_tx_wei": "1000000",
"period_seconds": 86400,
"revoked_at": null
}Base Sepolia ରେ ସମସ୍ତ ପ୍ରବାହକୁ ପରୀକ୍ଷା କରନ୍ତୁ।
sk_live_ keys କୁ flip କରିବା ପୂର୍ବରୁ, sk_test_ ସହିତ ସମ୍ପୂର୍ଣ୍ଣ path କୁ end-to-end ଚଳାନ୍ତୁ। test key ସବୁକିଛିକୁ Base Sepolia ରେ ରଖେ, ଯେଉଁଠାରେ ଆପଣ public faucet ରୁ wallet କୁ fund କରନ୍ତି ଏବଂ response shapes live ସହିତ ମେଳ ଖାଏ। key prefix network ଚୟନ କରେ, ସେଥିପାଇଁ test key କୌଣସି mainnet funds move କରିପାରେ ନାହିଁ।
ତିନୋଟି ପରିସ୍ଥିତିରେ ଅଭ୍ୟାସ କରନ୍ତୁ: ଏକ ସୁଖଦ-ପଥ ଭୁଗତାନ ଯାହା payment.received କୁ ଅନ୍ୟାନ୍ୟ କରେ, ଏକ ମିସ୍ ଡେଲିଭରୀ (ୱେବହୁକ୍କୁ ଏକ ମୃତ URL ଦିଆଯାଉ, ପରେ transactions.get ସହିତ ଲେନଦେନ ଆଣିବା ଦ୍ୱାରା ସମ୍ପର୍କ କରନ୍ତୁ), ଏବଂ ଏକ ୱେବହୁକ୍ ପୁନର୍ପ୍ରୟାସ (ପ୍ରଥମ ବେଳେ 500 ଫେରାଇବେ, ଦ୍ୱିତୀୟ ବେଳେ 200, ଏବଂ ଆପଣଙ୍କର ହ୍ୟାଣ୍ଡଲର୍ idempotent ହେବାକୁ ନିଶ୍ଚିତ କରନ୍ତୁ)। ଯେତେବେଳେ ତିନୋଟି ପରୀକ୍ଷାରେ ପାସ୍ ହୁଏ, କୀ ବଦଳାନ୍ତୁ ଏବଂ ଜାହାଜ କରନ୍ତୁ।
ଦଳଗୁଡିକୁ ଏକ ସପ୍ତାହ ଖର୍ଚ୍ଚ କରାଉଥିବା ପାଞ୍ଚ ଭୁଲ।
ହୁଇବୋକ୍ ସିଗ୍ନେଚର୍ ଭେରିଫିକେସନ୍ ଛାଡ଼ିବା
ଯଦି ଆପଣ /webhooks/payment କୁ କୌଣସି POST କୁ ପ୍ରାଧିକାରୀ ଭାବରେ ଗ୍ରହଣ କରନ୍ତି, ଏକ ଆକ୍ରମଣକାରୀ ମିଥ୍ୟା ଭୁଗତାନ ଘଟଣା ତିଆରି କରିପାରିବ ଏବଂ ଆପଣଙ୍କର ଏଜେଣ୍ଟକୁ ମାଗଣାରେ କାମ ଦେବାକୁ ଚାଲାଇପାରିବ। ସଦା HMAC-ସଂସ୍ଥାପନ କରନ୍ତୁ ୱେବହୁକ୍ ସିକ୍ରେଟ୍ ସହିତ, ଏକ ସ୍ଥାୟୀ-ସମୟ ତୁଳନା ବ୍ୟବହାର କରି। ପ୍ରଥମ ବିପରୀତ ସାଧାରଣତଃ ହାରାଇଥିବା ଯାଞ୍ଚ ହୁଏ।
ପୃଥକ confirmation event ଧରି
shipped event ଗୁଡ଼ିକ ହେଉଛି payment.received, payment.sent, wallet.deployed, ଏବଂ webhook.test - ଅଲଗା confirmation event ନାହିଁ। transfer ଏକ block ରେ ଥିବାବେଳେ payment.received fire ହୁଏ। ଅଧିକାଂଶ କାମ ପାଇଁ, ଏହାହିଁ deliver କରିବାର signal। ମହଙ୍ଗା କିମ୍ବା irreversibe କିଛି ପାଇଁ, କାର୍ଯ୍ୟ କରିବା ପୂର୍ବରୁ transactions.get ସହିତ transaction poll କରନ୍ତୁ ଏବଂ ନିଜ confirmation threshold ଲାଗୁ କରନ୍ତୁ; ଅସ୍ତିତ୍ୱହୀନ event ର ପ୍ରତୀକ୍ଷା କରନ୍ତୁ ନାହିଁ।
Webhook ହ୍ୟାଣ୍ଡଲରେ କୌଣସି idempotency ନାହିଁ
Webhook ଗୁଡିକ non-2xx ପ୍ରତିକ୍ରିୟାରେ ପୁନରାବୃତ୍ତି କରେ, ଏବଂ ସେହି ଘଟଣା ଭାର ତଳେ ଅନେକ ଥର ଆସିବ। ଆପଣଙ୍କର ହ୍ୟାଣ୍ଡଲର୍ ଇଡେମ୍ପୋଟେଣ୍ଟ ହେବା ଆବଶ୍ୟକ: ଆପଣଙ୍କର ଆଗରୁ ପ୍ରକ୍ରିୟା କରାଯାଇଥିବା ଘଟଣା ID ଗୁଡିକର ଏକ ଛୋଟ ତାଲିକା ରଖନ୍ତୁ ଏବଂ ଡୁପ୍ଲିକେଟ୍ଗୁଡିକୁ ଛାଡ଼ିଦିଅ। ନହେଲେ ଏକ ଅସ୍ଥାୟୀ ବ୍ଲିପ୍ ସେହି କାମକୁ ଦୁଇଥର ଦେଇଦେବ ଏବଂ ଆପଣ ଦୁଇଥର ପୂରଣ କରିବାକୁ ଘଣ୍ଟା ଖର୍ଚ୍ଚ କରିବେ।
ଟେଷ୍ଟ ଏବଂ ଲାଇଭ୍ API କୀ ମିଶାଇବା
ପରୀକ୍ଷା କୀସ୍ (sk_test_) ସ୍ୟାଣ୍ଡବକ୍ସକୁ ମାରିବା ଏବଂ Base Sepolia ବ୍ୟବହାର କରନ୍ତୁ; ଜୀବନ୍ତ କୀସ୍ (sk_live_) ପ୍ରୋଡକ୍ସନ୍କୁ ମାରିବା ଏବଂ Base mainnet ବ୍ୟବହାର କରନ୍ତୁ। ପରିବେଶ କନଫିଗରେ ସେଗୁଡିକୁ ମିଶାଇବା 'ଡେଭ୍ରେ କାମ କରେ, ପ୍ରୋଡ୍ରେ ବିଫଳ' ଟିକେଟ୍ଗୁଡିକର କାରଣ। ଯଦି ଆପଣଙ୍କର ରନ୍ଟାଇମ୍ ପରିବେଶ ଏବଂ କୀ ପ୍ରେଫିକ୍ସ ମେଳ ନାହିଁ, ଷ୍ଟାର୍ଟଅପ୍ରେ ହାର୍ଡ-ଫେଲ୍ କରନ୍ତୁ।
Missing webhook କୁ failed payment ଭାବେ ଧାରଣ କରିବା
failure event ନାହିଁ, ଏବଂ ଏକ webhook miss ହୋଇପାରେ (ଆପଣଙ୍କ endpoint down ଥିଲା, delivery drop ହୋଇଥିଲା)। ଆପଣଙ୍କ agent କୁ 'waiting for funds' loop ଭିତରେ ଅଟକି ରଖନ୍ତୁ ନାହିଁ। Reconcile କରନ୍ତୁ: real state ଜାଣିବା ପାଇଁ transactions.get ସହିତ transaction fetch କରନ୍ତୁ, ଏବଂ କୌଣସି waiting flow ଉପରେ timeout ରଖନ୍ତୁ, ଯାହାଦ୍ୱାରା abandoned payment held resources release କରିଦେବ, forever hang କରିବ ନାହିଁ।
ଯେତେବେଳେ ତୁମର ପ୍ରଥମ ପେମେଣ୍ଟ ହେବ।
ମୌଳିକ payments କାମ କରୁଥିବାବେଳେ, ସବୁଠୁ ଅଧିକ ଲାଭଦାୟକ follow-up ଗୁଡ଼ିକ ହେଲା spend controls (ଯାହାଦ୍ୱାରା agent budget ସହିତ ପଳାଇ ନପାରେ), webhook robustness (ଯାହାଦ୍ୱାରା load ତଳେ payments ଚୁପଚାପ ହରାଇ ନଯାଏ), ଏବଂ identity verification (ଯାହାଦ୍ୱାରା counterparties agent ର public page ଉପରେ trust କରନ୍ତି)।
ପ୍ରମ୍ପ୍ଟ ଇଞ୍ଜେକ୍ସନ୍ କୁ ଅତିକ୍ରମ କରିବା ପାଇଁ ଏଜେଣ୍ଟ ବ୍ୟୟ ନିୟନ୍ତ୍ରଣ ସେଟ୍ କରନ୍ତୁ
developer ମାନେ ସବୁଠାରୁ ଅଧିକ ପଚାରୁଥିବା webhook pattern
GitHub ଏବଂ ଡୋମେନ୍ ଯାଞ୍ଚ ବ୍ୟାଜ୍ ଉପାର୍ଜନ କରନ୍ତୁ
docs.blockchain0x.com ରେ ପୂର୍ଣ୍ଣ API ସନ୍ଦର୍ଭ ଅଛି। ସେହି APIs ପାଇଁ ଉତ୍ପାଦ ସତହ: Payment API.