SDKs & tools
CLI
The layerhop command line — chains, tokens, quotes, order status, deep links, project scaffolding and a local mock devnet.
@layerhop/cli installs a layerhop command. It quotes swaps, tracks orders, prints deep links, scaffolds projects and runs the API locally with a mock provider. It never signs or sends transactions.
Source: github.com/layerhop/layerhop-js (
packages/cli) — source repository (opens at launch).
Install#
npm install -g @layerhop/cli # or: npx @layerhop/cli <command>Node 20+. The package is a single file with no runtime dependencies.
Quote#
layerhop quote 100 USDC base SOL solana \
--sender 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 \
--recipient 9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM100 USDC on Base -> SOL on Solana
PROVIDER YOU GET MIN ETA FEE GAS QUOTE ID
- -------- --------------- --------------- --- ------ ----- ------------
* relay 0.949831057 SOL 0.945081902 SOL 1s 20 bps $0.00 q_1c9461ac-…
lifi 0.949599891 SOL 0.940127633 SOL 3s 20 bps $0.02 q_d81e9e99-…The CLI takes <amount> in human units and converts it to base units using the built-in token list. For any other token, pass base units with --base-units. Other options are --slippage-bps and --integrator. Add --json to get the raw QuoteResponse.
Commands#
| Command | What it does |
|---|---|
layerhop chains |
Supported chains (falls back to the built-in list when offline) |
layerhop tokens <chain> |
Built-in tokens of a chain |
layerhop quote <amount> <token> <chain> <toToken> <toChain> --sender --recipient |
Ranked quotes, best first |
layerhop status <provider> <txhash> [--watch] [--interval s] |
Order status. --watch prints each change until the order is final. Exits 0 on filled, 1 on refunded / failed. |
layerhop link <amount> <token> <chain> <toToken> <toChain> |
A https://layerhop.com/swap?… deep link. Options: --recipient, --slippage-bps, --ref, --integrator. Add --embed for an /embed URL; it also takes --theme, --accent, --radius, --lock-src, --lock-dst and --hide-history. |
layerhop init [node|next] <dir> |
Scaffolds a minimal project that uses @layerhop/sdk: a Node script, or a Next.js app with a server-side quote route. It refuses a non-empty directory unless you pass --force. |
layerhop devnet |
Inside the monorepo, runs @layerhop/api with LAYERHOP_ENABLE_MOCK=1 PROVIDERS=mock. Elsewhere it prints how to get it running. |
Global options:
--api-url: envLAYERHOP_API_URL, defaulthttps://api.layerhop.com--api-key: envLAYERHOP_API_KEY--json--help--version
Local devnet#
layerhop devnet # http://localhost:8787, mock provider only
LAYERHOP_API_URL=http://localhost:8787 layerhop quote 100 USDC base SOL solana --sender 0x… --recipient 9WzD…The mock provider answers instantly and deterministically, which makes it good for CI. Its transactions are dummies, so never broadcast them.
Exit codes#
0: success.1: an API error or a failed order. The CLI printserror: CODE: messageand a link to the error page.2: a usage error.