openfin-relay
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRelay Bridging
Relay跨链桥接
Playbook for bridging, swapping, and bridge+calling via Relay through OpenFinance.
通过OpenFinance的Relay进行桥接、兑换和桥接并调用的操作手册。
Three operations, one API
三类操作,一个API
| Operation | What it is |
|---|---|
| Swap | Same-chain token swap (origin = destination chain) |
| Bridge | Move tokens across chains (USDC on Polygon → USDC on Base) |
| Bridge+call | Bridge + execute a destination-chain tx after the bridge lands — pass the tx(s) in |
Relay picks the route automatically; you just provide the inputs.
| 操作 | 说明 |
|---|---|
| Swap(兑换) | 同链代币兑换(源链 = 目标链) |
| Bridge(桥接) | 跨链转移代币(Polygon上的USDC → Base上的USDC) |
| Bridge+call(桥接并调用) | 完成桥接后在目标链执行交易——在 |
Relay会自动选择路由;你只需提供输入参数即可。
Endpoints
接口
All three require . Relay aggregates liquidity across 40+
chains — you pass the chain IDs directly; the backend picks the route.
x-api-key: open_…所有三个接口都需要携带请求头。Relay聚合了40+条链的流动性——你只需直接传入chainId,后端会自动选择路由。
x-api-key: open_…POST /agent/relay/quote
— quote only
POST /agent/relay/quotePOST /agent/relay/quote
— 仅获取报价
POST /agent/relay/quoteFetches a Relay quote for a swap, bridge, or bridge+call. Does NOT submit
any transactions. Use for preview UIs, fee estimation, or to show the user
the route before they confirm.
Request body:
json
{
"originChainId": 137,
"destinationChainId": 8453,
"originCurrency": "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
"destinationCurrency": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"amount": "10000000",
"tradeType": "EXACT_INPUT",
"recipient": "...", // optional; defaults to user's dest-chain addr
"slippageTolerance": "50", // basis points, optional
"topupGas": true, // optional; forced false for Solana routes
"topupGasAmount": "100000", // USD micro-units, optional
"usePermit": false, // EIP-3009 permit for supported tokens
"txs": [{"to", "data", "value"}], // optional; for bridge+call
"appFees": [{"recipient", "fee"}] // optional
}useroriginChainIdReturns the full response: . is an
array of signable/submittable actions (transactions or signatures) with
embedded endpoints for status polling.
{steps, fees, feeSponsorship}stepscheck获取Relay针对兑换、桥接或桥接并调用的报价。不会提交任何交易。用于预览UI、手续费估算,或在用户确认前展示路由信息。
请求体:
json
{
"originChainId": 137,
"destinationChainId": 8453,
"originCurrency": "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
"destinationCurrency": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"amount": "10000000",
"tradeType": "EXACT_INPUT",
"recipient": "...", // 可选;默认值为用户的目标链地址
"slippageTolerance": "50", // 基点,可选
"topupGas": true, // 可选;Solana路由强制设为false
"topupGasAmount": "100000", // USD微单位,可选
"usePermit": false, // 针对支持代币的EIP-3009授权
"txs": [{"to", "data", "value"}], // 可选;用于桥接并调用
"appFees": [{"recipient", "fee"}] // 可选
}useroriginChainId返回完整响应:。是可签名/可提交的操作数组(交易或签名),包含用于状态轮询的嵌入式接口。
{steps, fees, feeSponsorship}stepscheckPOST /agent/relay/execute
— quote + sign + submit + poll
POST /agent/relay/executePOST /agent/relay/execute
— 报价+签名+提交+轮询
POST /agent/relay/executeEnd-to-end flow. Same body as . The backend:
/quote- Fetches the quote
- Walks every :
step- EVM transaction step → sends via viem on the correct chain, waits for 1 confirmation
walletClient.sendTransaction - Solana transaction step → compiles + ALTs into a VersionedTransaction, has Privy sign it (
instructions), broadcasts via our RPC withsignTransaction, confirms with the original blockhash/lastValidBlockHeightskipPreflight: true - EIP-712 signature step → signs with the user's EVM account and
POSTs the signature to the step's
check.endpoint
- EVM transaction step → sends via viem
- Polls with exponential backoff (1s → 10s, 5-min cap) until terminal status
GET /intents/status/v3
Returns .
{requestId, quote, txHashes, finalStatus}Use when the user confirms the quote or directly asks to bridge / swap /
execute. Solana-origin requires the user's Solana wallet to be delegated
(see step 2).
openfin-setup端到端流程。请求体与相同。后端会执行以下操作:
/quote- 获取报价
- 处理每一个:
step- EVM交易步骤 → 通过viem 在对应链发送交易,等待1次确认
walletClient.sendTransaction - Solana交易步骤 → 将+ ALTs编译为VersionedTransaction,由Privy签名(
instructions),通过我们的RPC广播并设置signTransaction,使用原始blockhash/lastValidBlockHeight确认skipPreflight: true - EIP-712签名步骤 → 使用用户的EVM账户签名,并将签名POST到步骤的
check.endpoint
- EVM交易步骤 → 通过viem
- 使用指数退避策略(1秒→10秒,上限5分钟)轮询,直到达到终端状态
GET /intents/status/v3
返回。
{requestId, quote, txHashes, finalStatus}当用户确认报价或直接要求桥接/兑换/执行时使用此接口。Solana发起的操作要求用户的Solana钱包已完成授权(详见步骤2)。
openfin-setupGET /agent/relay/status?requestId=<id>
— manual status lookup
GET /agent/relay/status?requestId=<id>GET /agent/relay/status?requestId=<id>
— 手动查询状态
GET /agent/relay/status?requestId=<id>Get the current status of a Relay intent by its . Use for
manual polling from the frontend when wasn't awaited, or for
audit lookups.
requestId/executeStatus values:
- — awaiting deposit confirmation
waiting - — origin deposit confirmed, pending fill
depositing - — deposit confirmed, awaiting destination submission
pending - — destination transaction submitted
submitted - — destination fill still processing
delayed - — successful fill on destination (terminal)
success - — successfully refunded (terminal)
refunded - — unsuccessful fill (terminal)
failure
Response also includes (free-form text), , ,
(ms), , .
detailsinTxHashestxHashesupdatedAtoriginChainIddestinationChainId通过获取Relay意向的当前状态。用于前端未等待返回时的手动轮询,或审计查询。
requestId/execute状态值:
- — 等待存款确认
waiting - — 源链存款已确认,等待填充
depositing - — 存款已确认,等待目标链提交
pending - — 目标链交易已提交
submitted - — 目标链填充仍在处理中
delayed - — 目标链填充成功(终端状态)
success - — 退款成功(终端状态)
refunded - — 填充失败(终端状态)
failure
响应还包含(自由格式文本)、、、(毫秒)、、。
detailsinTxHashestxHashesupdatedAtoriginChainIddestinationChainIdRequired inputs
必填输入参数
| Field | Type | Notes |
|---|---|---|
| number | Source chain |
| number | Destination chain |
| string | Token contract on origin (or |
| string | Token contract on destination |
| string | Smallest unit as a STRING (wei for 18-dec, |
| string | |
useroriginChainIdrecipient| 字段 | 类型 | 说明 |
|---|---|---|
| 数字 | 源链ID |
| 数字 | 目标链ID |
| 字符串 | 源链上的代币合约地址(EVM原生代币填 |
| 字符串 | 目标链上的代币合约地址 |
| 字符串 | 最小单位的字符串形式(18位小数代币用wei, |
| 字符串 | |
useroriginChainIdrecipientChain ID cheatsheet
Chain ID速查表
| Chain | ID |
|---|---|
| Ethereum | |
| Polygon | |
| Base | |
| Optimism | |
| Arbitrum | |
| BSC | |
| Linea | |
| Blast | |
| Scroll | |
| zkSync Era | |
| Hyperliquid | |
| Solana | |
| Bitcoin | |
| Tron | |
Live list: .
Treat that endpoint as source of truth for supported origin chains.
GET https://api.relay.link/chains| 链名称 | ID |
|---|---|
| 以太坊 | |
| Polygon | |
| Base | |
| Optimism | |
| Arbitrum | |
| BSC | |
| Linea | |
| Blast | |
| Scroll | |
| zkSync Era | |
| Hyperliquid | |
| Solana | |
| Bitcoin | |
| Tron | |
实时列表:。请将该接口作为支持的源链的权威数据源。
GET https://api.relay.link/chainsNative-token sentinel
原生代币标记
Use for the EVM native token
on any EVM chain (ETH / MATIC / BNB / etc.).
0x0000000000000000000000000000000000000000For Solana, use for wrapped
SOL, or the SPL mint address for tokens (e.g.
for USDC).
So11111111111111111111111111111111111111112EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v任何EVM链上的原生代币(ETH/MATIC/BNB等)都使用表示。
0x0000000000000000000000000000000000000000Solana链上,包装SOL使用,代币使用SPL铸币地址(例如USDC的地址为)。
So11111111111111111111111111111111111111112EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1vTrade types
交易类型
| Type | Meaning | Example |
|---|---|---|
| Send exactly | "Bridge 10 USDC" |
| Send variable, receive exactly | "Get me exactly 1 ETH on Base" |
| Alternate routing | Rarely needed |
Most prompts are . If user says "I want to receive X", use .
EXACT_INPUTEXACT_OUTPUT| 类型 | 含义 | 示例 |
|---|---|---|
| 发送固定 | "桥接10 USDC" |
| 发送数量可变,接收固定 | "给我在Base上转1 ETH" |
| 备选路由 | 极少使用 |
大多数场景使用。如果用户说“我想收到X”,则使用。
EXACT_INPUTEXACT_OUTPUTGas topup defaults
Gas充值默认设置
Backend behavior:
- EVM ↔ EVM: default,
topupGas: true($0.10). Relay only applies it if the recipient needs gas.topupGasAmount: "100000" - Any route with Solana (chainId ):
792703809forcedtopupGas.false - Ethereum L1 destination: bump to
topupGasAmount($0.50)."500000"
Override per-call via body fields and .
topupGastopupGasAmount后端行为:
- EVM ↔ EVM:默认,
topupGas: true(0.10美元)。仅当接收方需要Gas时,Relay才会执行充值。topupGasAmount: "100000" - 涉及Solana的路由(chainId ):
792703809强制设为topupGas。false - 目标链为以太坊L1:将提高到
topupGasAmount(0.50美元)。"500000"
可通过请求体字段和覆盖默认设置。
topupGastopupGasAmountSolana-origin example
Solana源链示例
Bridge the user's USDC from Solana back to USDC.e on Polygon:
json
{
"originChainId": 792703809,
"destinationChainId": 137,
"originCurrency": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
"destinationCurrency": "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
"amount": "1000000",
"tradeType": "EXACT_INPUT"
}userrecipientopenfin-setup将用户的USDC从Solana桥接到Polygon上的USDC.e:
json
{
"originChainId": 792703809,
"destinationChainId": 137,
"originCurrency": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
"destinationCurrency": "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
"amount": "1000000",
"tradeType": "EXACT_INPUT"
}userrecipientopenfin-setupBridge+call example
桥接并调用示例
Bridge USDC.e Polygon → USDC Base, then call a contract on Base:
json
{
"originChainId": 137,
"destinationChainId": 8453,
"originCurrency": "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
"destinationCurrency": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"amount": "10000000",
"tradeType": "EXACT_INPUT",
"txs": [
{ "to": "0x…target…", "data": "0x…calldata…", "value": "0" }
]
}将Polygon上的USDC.e桥接到Base上的USDC,然后在Base上调用合约:
json
{
"originChainId": 137,
"destinationChainId": 8453,
"originCurrency": "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
"destinationCurrency": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"amount": "10000000",
"tradeType": "EXACT_INPUT",
"txs": [
{ "to": "0x…target…", "data": "0x…calldata…", "value": "0" }
]
}Status values
状态值说明
- Terminal success: ,
successrefunded - Terminal failure:
failure - In-flight: ,
waiting,depositing,pending,submitteddelayed
If returns non-terminal , keep polling
with the .
/executefinalStatus/statusrequestId- 终端成功状态:、
successrefunded - 终端失败状态:
failure - 进行中状态:、
waiting、depositing、pending、submitteddelayed
如果返回非终端状态,请使用持续轮询。
/executefinalStatusrequestId/statusDon't
注意事项
- Don't use human-readable amounts. = 1 USDC, not
"1000000"."1" - Don't pass or
user— server injects.userId - Don't retry a without checking
failure— refund may be automatic (detailswill follow), or the route may be unsupported.status: refunded - Don't assume Solana delegation carries over from EVM. Each chain type delegates separately in Privy.
- 请勿使用人类可读的金额。= 1 USDC,而非
"1000000"。"1" - 请勿传入或
user——由服务器自动注入。userId - 失败状态请勿直接重试,需先查看
failure——退款可能自动完成(后续状态会变为details),或该路由不被支持。refunded - 请勿假设Solana授权与EVM授权互通。Privy中不同链类型的授权是独立的。
MCP note
MCP说明
Tool names match: , , .
relay_get_quoterelay_executerelay_get_status工具名称对应:、、。
relay_get_quoterelay_executerelay_get_status