LayerHop
Best-price cross-chain swap quotes across 70 chains (EVM + Solana). Holds no keys, never signs.
التثبيت
أضف هذا إلى إعدادات MCP في عميلك (Claude Desktop: claude_desktop_config.json، وCursor: .cursor/mcp.json، ويستخدم VS Code وغيره الصيغة نفسها «mcpServers»).
claude mcp add --transport http layerhop 'https://mcp.layerhop.com/mcp'
{
"mcpServers": {
"layerhop": {
"type": "http",
"url": "https://mcp.layerhop.com/mcp"
}
}
}
@layerhop/mcpclaude mcp add layerhop -e 'LAYERHOP_API_KEY=<your layerhop_api_key>' -e 'LAYERHOP_INTEGRATOR=<LAYERHOP_INTEGRATOR>' -- npx -y @layerhop/mcp@0.5.0
{
"mcpServers": {
"layerhop": {
"command": "npx",
"args": [
"-y",
"@layerhop/mcp@0.5.0"
],
"env": {
"LAYERHOP_API_KEY": "<your layerhop_api_key>",
"LAYERHOP_INTEGRATOR": "<LAYERHOP_INTEGRATOR>"
}
}
}
}
متغيرات البيئة
LAYERHOP_API_KEYسري Optional LayerHop API key from dashboard.layerhop.com, for higher rate limitsLAYERHOP_INTEGRATOROptional partner ID, so swaps made through your agent earn your partner fee
التوثيق
مأخوذ من ملف README للمشروع على GitHub ويُحدَّث أسبوعيًا. تفتح الروابط على GitHub.
LayerHop JavaScript SDKs
TypeScript/JavaScript packages for LayerHop: best-price cross-chain and same-chain swaps across EVM chains and Solana through one non-custodial API. Nothing here holds keys or signs; you get quotes and unsigned transactions that your users' wallets sign.
Docs: https://docs.layerhop.com
Packages
| Package | Description |
|---|---|
@layerhop/sdk | LayerHop SDK — best-price cross-chain and same-chain swaps |
@layerhop/react | React hooks for LayerHop cross-chain swaps: quotes, transactions, order tracking and a wallet-agnostic useSwap state machine |
@layerhop/react-native | LayerHop for React Native and Expo: the swap widget and checkout as native components (react-native-webview) with typed callbacks, plus wallet deep-link helpers |
@layerhop/wagmi | Execute LayerHop quotes with wagmi or viem: ERC-20 approval, swap and extra calls in one EIP-5792 confirmation when the wallet supports it, sequential transactions otherwise |
@layerhop/solana | Execute LayerHop quotes with a Solana wallet: decode the transaction, sign and send it through @solana/wallet-adapter, Wallet Standard or an injected provider, submit-via-API and co-signed modes, then report it |
@layerhop/widget | Embed the LayerHop cross-chain swap widget and checkout in any site: React components, framework-agnostic mount()/openCheckout() and drop-in <script> tags |
@layerhop/cli | LayerHop command line: quotes, order status, deep links, project scaffolding and a local mock devnet |
@layerhop/mcp | LayerHop MCP server: let AI agents (Claude, ChatGPT, Cursor, ...) quote and prepare cross-chain swaps. Holds no keys and never signs. |
@layerhop/ai | LayerHop tools for AI agent frameworks: Vercel AI SDK, LangChain, OpenAI (function calling and Agents SDK). Quotes, unsigned swap transactions, deposit addresses, checkout. Holds no keys and never signs. |
@layerhop/plugin-elizaos | LayerHop plugin for ElizaOS: best-price cross-chain and same-chain swap quotes, unsigned transactions with an explicit confirmation step, deposit addresses and checkout. Holds no keys and never auto-signs. |
@layerhop/agentkit | LayerHop action provider for Coinbase AgentKit: best-price cross-chain and same-chain swaps (EVM and Solana), deposit addresses and checkout for on-chain agents. The wallet provider signs; LayerHop never sees keys. |
@layerhop/goat | LayerHop plugin for the GOAT SDK: best-price cross-chain and same-chain swap quotes, unsigned transactions, deposit addresses and checkout for on-chain agents. LayerHop never sees keys. |
packages/shared is an internal, private package (chain registry, tokens, error codes, types). It is
inlined into each published package at build time, so you never install it.
Quickstarts
SDK (npm install @layerhop/sdk)
import { LayerHop } from "@layerhop/sdk";
const lh = new LayerHop({ integrator: "myapp" });
const { best } = await lh.quote({
srcChain: "base", srcToken: "USDC", amount: "100000000", // 100 USDC, base units
dstChain: "solana", dstToken: "SOL",
sender: "0xYourEvmAddress", recipient: "YourSolanaAddress",
});
const tx = await lh.buildTx(best.quoteId); // unsigned; sign with your wallet
Checkout: pay with any token (@layerhop/sdk 0.2+)
const session = await lh.checkout.create({
amount: "49000000", settleChain: "base", settleToken: "USDC", // 49 USDC on Base
recipient: "0xYourPayoutAddress", successUrl: "https://shop.example.com/thanks",
});
// Send the customer to session.url; fulfil on the checkout.session.completed webhook.
Test mode: use an lh_test_… key from the dashboard and every call is served by the sandbox
(live-priced quotes, placeholder transactions, orders fill in ~10 s). See
https://docs.layerhop.com/guides/test-mode. Try every endpoint in the
API playground.
React (npm install @layerhop/react @layerhop/sdk @tanstack/react-query)
import { LayerHopProvider, useQuote } from "@layerhop/react";
<LayerHopProvider options={{ integrator: "myapp" }}>
<App />
</LayerHopProvider>;
Widget (npm install @layerhop/widget)
import { mount } from "@layerhop/widget";
mount("#swap", { srcChain: "base", dstChain: "solana", dstToken: "SOL" });
React Native / Expo (npx expo install @layerhop/react-native react-native-webview)
import { LayerHopWidget } from "@layerhop/react-native";
<LayerHopWidget srcChain="base" dstChain="solana" dstToken="SOL" onSubmitted={(e) => console.log(e.srcTxHash)} />;
CLI
npx @layerhop/cli quote 100 USDC base SOL solana --sender 0x... --recipient 9WzD...
MCP server for AI agents (npx -y @layerhop/mcp), see packages/mcp.
Each package's README has the full guide.
Development
corepack enable
pnpm install
pnpm typecheck && pnpm test && pnpm build
Source of truth
This repository is exported from the LayerHop monorepo. PRs are welcome; see CONTRIBUTING.md. Security reports: SECURITY.md.
License
الأسئلة الشائعة
ما هو LayerHop؟
Best-price cross-chain swap quotes across 70 chains (EVM + Solana). Holds no keys, never signs.
كيف أثبّت LayerHop؟
يعمل كخادم بعيد. في Claude Code: claude mcp add --transport http layerhop 'https://mcp.layerhop.com/mcp'. وفي العملاء الآخرين، الصق إعداد JSON من هذه الصفحة في إعدادات MCP الخاصة بهم.
هل يحتاج LayerHop إلى مفتاح API؟
نعم. يتطلب LAYERHOP_API_KEY، وتضبطها في إعداداته.
هل LayerHop مفتوح المصدر؟
نعم. شيفرته متاحة على GitHub بترخيص MIT.
من يصون LayerHop؟
ينشره layerhop. يدرجه AI.tn لكنه لا يصونه ولا يوصي به.
من سجل MCP الرسمي. الإدراج ليس توصية: راجع شيفرة الخادم وصلاحياته قبل منحه الوصول إلى بياناتك.