Best-price cross-chain swap quotes across 70 chains (EVM + Solana). Holds no keys, never signs.
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
| 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/widget | Embed the LayerHop cross-chain swap widget in any site: React component, framework-agnostic mount() and a drop-in |
@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. |
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.
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" });
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.
corepack enable
pnpm install
pnpm typecheck && pnpm test && pnpm build
This repository is exported from the LayerHop monorepo. PRs are welcome; see CONTRIBUTING.md. Security reports: SECURITY.md.
Source-derived launch command. Check the maintainer’s required arguments and credentials before running:
npx -y @layerhop/mcpMerge this template into ~/Library/Application Support/Claude/claude_desktop_config.json. Keep existing servers. Add any arguments, credentials, and permissions required by the maintainer; this template has not been install-tested.
{
"mcpServers": {
"com-layerhop-mcp": {
"command": "npx",
"args": [
"-y",
"@layerhop/mcp"
]
}
}
}Restart Claude Desktop completely for changes to take effect. Confirm the server appears connected in the client’s tool list, then try a read-only example from its documentation.
Claude Desktop setup referenceLayerHop works with any MCP-compatible client. Copy the config snippet from the Configuration section above and add it to the file shown for your client, then restart the application.
~/Library/Application Support/Claude/claude_desktop_config.jsonRestart Claude Desktop completely for changes to take effect.~/.cursor/mcp.jsonRestart Cursor for changes to take effect..vscode/mcp.jsonReload VS Code window for changes to take effect.~/.codeium/windsurf/mcp_config.jsonRestart Windsurf for changes to take effect..mcp.jsonSave at the project root, then start Claude Code in that project and review the MCP server approval prompt. Keep real credentials out of shared files.