03 - Template Cookbook
A collection of template examples by lane.
For detailed rules, see docs/reference/compiler/plan-compilation.md.
Register from the Dashboard (Recommended)
If you select a preset on the dashboard’s Templates page (/routes), you do not need to write JSON by hand:
- Click the lane card you want in the Presets grid at the bottom of the Templates page
- In Customize, change only the core fields such as asset, exchange, and network
- Check the result in Graph Preview and JSON Preview
- Register it with the Register Template button
For a custom template that is not covered by a preset, use the JSON examples below and register it directly through the API.
Register Directly Through the API
Template Structure at a Glance
node_key, node_kind, action_type, executor_selector, has_side_effect
Required edge fields: from, to, edge_type (usually "on_success")
1. CEX 3-Node (Upbit -> Bybit XRP)
The simplest shape: withdrawal -> withdrawal observe -> deposit observe.completion_assurance: "destination_credited"-> the terminal node iscex_deposit_status(thedestination_provider_observefamily)match_modeis required on the terminal noderisk_controlsis free-form and onlymax_amountbinds (fail-closed at dispatch). Theasset_allowlistin every template below is descriptive — hash-pinned, but not enforced. See the v3 endpoints reference
2. CCTP 5-Node (Base Sepolia -> Arbitrum Sepolia)
Cross-chain USDC transfer via CCTP. Requires a signer.- Put the signer address in
destination_caller(you can confirm it through signer health) signer_selector: {"chain_family": "evm"}-> matches the active signer registry rowconfirmations_requiredis required on the terminal node- Environment variables:
MG_EVM_RPC_ENDPOINTS_JSON,MG_LOCAL_SIGNER_*
3. Gateway 3-Node (Base Sepolia -> Arbitrum Sepolia)
Immediate cross-chain transfer through the Gateway unified balance.- Gateway is faster than CCTP (no attestation polling; burn intent signature -> immediate mint)
- Contract addresses differ by network - check Circle’s official docs
- Environment variables:
MG_GATEWAY_API_BASE_URL,MG_EVM_RPC_ENDPOINTS_JSON,MG_LOCAL_SIGNER_*
4. Multi-Hop 9-Node (Upbit -> Binance -> Base -> Gateway)
A composite CEX-to-CEX-to-chain-to-Gateway route.$ref: dynamically references output from earlier nodes.
Why multi-hop
- Upbit does not support direct withdrawals to Base (only routes such as Tron/ERC-20 are available)
- Route through Binance for the Base withdrawal, then deposit into Gateway
Graph Structure
$ref: Usage Points
Template JSON
Runtime Data Flow
How$ref: resolves during movement execution:
If the target key for$ref:does not exist, the node immediately becomes FAILED (error_code: CONFIG_REF_UNRESOLVED).
$ref: Rules Summary
Common Pitfalls
Full compilation behavior: docs/reference/compiler/plan-compilation.md
Next: 04-going-live.md - prepare for production deployment