Skip to main content
bankr-x402-sdk-client-patterns This skill should be used when the user asks to "implement Bankr SDK client", "write bankr-client.ts", "create SDK client setup", "common files for SDK project", "package.json for Bankr SDK", "tsconfig for Bankr", "SDK TypeScript patterns", "execute SDK transactions", or needs the reusable client code and common project files for Bankr SDK integrations.
الانتقال إلى التثبيت سوق المهارات اكتشف واستكشف مهارات الذكاء الاصطناعي التي بناها المجتمع.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
نسخ Promptعرض تفاصيل Prompt يتجاوز الأمر المباشر Prompt المخصّص للمراجعة. افحص المصدر قبل تشغيله.
npx skills add https://github.com/BankrBot/claude-plugins --skill bankr-x402-sdk-client-patternsيبقى الأمر في سطر واحد. مرّر أفقيًا لمراجعته كاملًا قبل النسخ.
تفضّل نسخة محلية؟ نزّل الملفات المتاحة حاليًا لدى SkillsMP.
تحميل Zip جاري التحميل... المزيد من هذا المستودع This skill should be used when building the async job workflow, implementing polling loops, handling job status transitions, processing rich data, managing conversation threads, or understanding the full submit-poll-complete lifecycle of the Bankr Agent API.
bankr-dev-safety-access-control This skill should be used when building secure Bankr integrations, implementing API key management, configuring access controls, setting up dedicated agent wallets, or handling rate limits and security best practices in Bankr API projects.
bankr-dev-sign-submit-api This skill should be used when building apps that need to sign messages, sign typed data (EIP-712), sign transactions, or submit raw transactions via the Bankr API. Covers the synchronous /agent/sign and /agent/submit endpoints with TypeScript patterns.
المهن ذات الصلة SOC
استنادا إلى تصنيف SOC المهني
name Bankr x402 SDK - Client Patterns description This skill should be used when the user asks to "implement Bankr SDK client", "write bankr-client.ts", "create SDK client setup", "common files for SDK project", "package.json for Bankr SDK", "tsconfig for Bankr", "SDK TypeScript patterns", "execute SDK transactions", or needs the reusable client code and common project files for Bankr SDK integrations. version 1.0.0
x402 SDK Client Patterns
Reusable client code and common files for Bankr SDK projects.
bankr-client.ts
The core SDK client module for all Bankr SDK projects:
import "dotenv/config" ;
import { BankrClient } from "@bankr/sdk" ;
if (!process.env .BANKR_PRIVATE_KEY ) {
throw new Error (
"BANKR_PRIVATE_KEY environment variable is required. " +
"This wallet pays $0.01 USDC per request (needs USDC on Base)."
);
}
bankrClient = ({
: process. . ,
: process. . ,
...(process. . && { : process. . }),
});
walletAddress = bankrClient. ();
{ , } ;
export
const
new
BankrClient
privateKey
env
BANKR_PRIVATE_KEY
as
`0x${string } `
walletAddress
env
BANKR_WALLET_ADDRESS
env
BANKR_API_URL
baseUrl
env
BANKR_API_URL
export
const
getWalletAddress
export
type
JobStatusResponse
Transaction
from
"@bankr/sdk"
executor.ts Transaction execution helper using viem:
import { createWalletClient, http, type WalletClient } from "viem" ;
import { privateKeyToAccount } from "viem/accounts" ;
import { base, mainnet, polygon } from "viem/chains" ;
import type { Transaction } from "@bankr/sdk" ;
const chains = {
8453 : base,
1 : mainnet,
137 : polygon,
} as const ;
const account = privateKeyToAccount (
process.env .BANKR_PRIVATE_KEY as `0x${string } `
);
function getWalletClient (chainId : number ): WalletClient {
const chain = chains[chainId as keyof typeof chains];
if (!chain) {
throw new Error (`Unsupported chain ID: ${chainId} ` );
}
return createWalletClient ({
account,
chain,
transport : http (),
});
}
export async function executeTransaction (tx : Transaction ): Promise <string > {
const txData = tx.metadata .transaction ;
const client = getWalletClient (txData.chainId );
console .log (`Executing ${tx.type } on chain ${txData.chainId} ...` );
const hash = await client.sendTransaction ({
to : txData.to as `0x${string } ` ,
data : txData.data as `0x${string } ` ,
value : BigInt (txData.value || "0" ),
gas : BigInt (txData.gas ),
});
console .log (`Transaction submitted: ${hash} ` );
return hash;
}
export async function executeAllTransactions (
transactions : Transaction []
): Promise <string []> {
const hashes : string [] = [];
for (const tx of transactions) {
const hash = await executeTransaction (tx);
hashes.push (hash);
}
return hashes;
}
Common Files
package.json Base package.json for all Bankr SDK projects:
{
"name" : "{project-name}" ,
"version" : "0.1.0" ,
"description" : "{description}" ,
"type" : "module" ,
"main" : "dist/index.js" ,
"scripts" : {
"build" : "tsc" ,
"start" : "node dist/index.js" ,
"dev" : "tsx src/index.ts"
} ,
"dependencies" : {
"@bankr/sdk" : "^1.0.0" ,
"dotenv" : "^16.3.1" ,
"viem" : "^2.0.0"
} ,
"devDependencies" : {
"@types/node" : "^20.10.0" ,
"tsx" : "^4.7.0" ,
"typescript" : "^5.3.0"
}
}
Framework-Specific Dependencies Add based on project template:
"dependencies" : {
"express" : "^4.18.0"
} ,
"devDependencies" : {
"@types/express" : "^4.17.21"
}
"dependencies" : {
"commander" : "^12.0.0"
}
tsconfig.json TypeScript configuration:
{
"compilerOptions" : {
"target" : "ES2022" ,
"module" : "NodeNext" ,
"moduleResolution" : "NodeNext" ,
"outDir" : "./dist" ,
"rootDir" : "./src" ,
"strict" : true ,
"esModuleInterop" : true ,
"skipLibCheck" : true ,
"forceConsistentCasingInFileNames" : true ,
"declaration" : true
} ,
"include" : [ "src/**/*" ] ,
"exclude" : [ "node_modules" , "dist" ]
}
.env.example Environment variables template:
.gitignore Standard ignore patterns:
# Dependencies
node_modules/
# Build output
dist/
# Environment
.env
.env.local
.env.*.local
# Logs
*.log
npm-debug.log*
# IDE
.idea/
.vscode/
*.swp
*.swo
# OS
.DS_Store
Thumbs.db
# Testing
coverage/
Usage Patterns
Basic Usage import { bankrClient } from "./bankr-client" ;
const result = await bankrClient.promptAndWait ({
prompt : "What is the price of ETH?" ,
onStatusUpdate : (msg ) => console .log ("Progress:" , msg),
});
console .log (result.response );
With Transaction Execution import { bankrClient } from "./bankr-client" ;
import { executeTransaction } from "./executor" ;
const result = await bankrClient.promptAndWait ({
prompt : "Swap 0.1 ETH to USDC on Base" ,
});
if (result.status === "completed" && result.transactions ?.length ) {
console .log ("Transaction ready:" , result.transactions [0 ].type );
console .log ("Details:" , result.transactions [0 ].metadata .__ORIGINAL_TX_DATA__ );
const hash = await executeTransaction (result.transactions [0 ]);
console .log ("Executed:" , hash);
}
With Error Handling import { bankrClient } from "./bankr-client" ;
import { executeAllTransactions } from "./executor" ;
async function performSwap (prompt : string ) {
try {
const result = await bankrClient.promptAndWait ({
prompt,
onStatusUpdate : console .log ,
});
if (result.status === "completed" ) {
console .log ("Success:" , result.response );
if (result.transactions ?.length ) {
const hashes = await executeAllTransactions (result.transactions );
console .log ("Transactions:" , hashes);
}
} else if (result.status === "failed" ) {
console .error ("Failed:" , result.error );
}
} catch (error) {
console .error ("Error:" , error.message );
}
}
Query Without Transactions import { bankrClient } from "./bankr-client" ;
const balances = await bankrClient.promptAndWait ({
prompt : "What are my balances on Base?" ,
});
console .log (balances.response );
const price = await bankrClient.promptAndWait ({
prompt : "Price of DEGEN" ,
});
console .log (price.response );
SDK Reference Consult the sdk-capabilities skill for:
Complete operation reference
Supported chains and tokens
Example prompts for each operation
Consult the sdk-token-swaps skill for:
Swap patterns and approval handling
Transaction execution details