摘要
本文档对 Skip Go API 中提供的不同类型的方法进行高层概述,并说明集成方通常如何组合使用这些方法,以构建类似 go.skip.build 的跨链兑换前端。 有关各个端点的更多信息,请参阅 API reference。方法概览
/info 方法:用于获取通用信息的功能
/info 端点及其在 @skip-go/client 中对应的函数,提供了 Skip Go API 所支持的链和桥的通用元数据。
最重要的 info 方法包括:
/v2/info/chains(chains()): 获取所有受支持链的信息,包括能力、地址类型、Logo 等。/v2/info/bridges(bridges()): 获取所有受支持桥的基础信息,包括 Logo 和名称
/fungible 方法:用于同质化代币兑换与转账的功能
/v2/fungible 端点及其在 @skip-go/client 中对应的函数,提供了用于跨链同质化代币兑换和转账的 API。
在底层,API 会为所有操作自动提供 DEX 聚合、桥路由、denom 推荐以及中继能力。
最重要的 fungible 方法包括:
/v2/fungible/route(route()): 获取一对代币与链之间的兑换/转账路径和报价。你可以对该请求进行大量自定义,例如仅考虑特定 DEX、桥;通过拆分路径来获得更优价格;以及更多功能。/v2/fungible/msgs(messages()): 为用户生成执行指定路径所需签名的交易数据/v2/fungible/msgs_direct(messagesDirect()): 同时生成路径、报价以及对应的交易数据/v2/fungible/venues(venues()): 获取所有受支持兑换场所(DEX、流动性质押协议等)的元数据,包括名称和 Logo。
/tx 方法:用于跟踪进行中交易的功能
/v2/tx 端点及其在 @skip-go/client 中对应的函数,提供了提交交易和跟踪跨链交易状态的能力,并以统一接口覆盖所有底层跳转路径和桥类型。
最重要的 tx 方法包括:
/v2/tx/submit(submitTransaction()): 通过 Skip 的节点在链上提交交易,并将该交易注册到 Skip Go API 进行跟踪 (尤其推荐用于 Solana 和其他高拥堵网络,因为成功提交交易可能较为困难)/v2/tx/track(trackTransaction()): 将交易注册到 Skip Go API 进行跟踪(当集成方拥有自己的链节点用于提交时,通常会使用它而不是/submit)/v2/tx/status(transactionStatus()): 获取多跳交易的当前状态
/tx API reference
跨链兑换前端中的典型用法
在跨链兑换与转账前端中,集成方通常会:-
使用
info方法来填充可选的起始链、目标链和资产列表
-
当用户选择好链与代币,并输入其中一个金额后,使用
/fungible/route(route()) 获取报价
-
当用户确认路径并开始创建交易后,使用
/fungible/msgs(messages()) 获取供用户签名的交易
-
使用
/tx/track(trackTransaction()) 将交易注册为可跟踪状态(或使用/tx/submit进行注册并提交到链上) -
使用
/tx/status(transactionStatus()) 获取交易在桥和/或链之间推进时的实时状态。
Summary
This doc provides a high-level overview of the different kinds of methods available in the Skip Go API & describes how integrators typically use them in combination to create a cross-chain swapping frontend like go.skip.build. See the API reference for more information on each endpoint.Overview of Methods
/info methods: Functionality for Retrieving General Purpose Info
The /info endpoints & their corresponding functions in @skip-go/client provide general purpose metadata about the chains and bridges that the Skip Go API supports.
The most important info methods include:
/v2/info/chains(chains()): Get info about all supported chains, including capabilities, address type, logo, etc…/v2/info/bridges(bridges()): Get basic info about all supported bridges, including logo and name
/fungible methods: Functionality for fungible token swaps and transfers
The /v2/fungible endpoints & their corresponding functions in @skip-go/client provide APIs for cross-chain swaps and transfers of fungible tokens.
In the background, the API provides automatic DEX aggregation, bridge routing, denom recommendation, and relaying for all actions.
The most important fungible methods include :
/v2/fungible/route(route()): Get a swap/transfer route and quote between a pair of tokens & chains. You can customize this request significantly to only consider particular DEXes, bridges; to add route splitting for better prices; and much more./v2/fungible/msgs(messages()): Generates the transaction data for the transaction(s) the user must sign to execute a given route/v2/fungible/msgs_direct(messagesDirect()): Generates a route, quote, and associated transaction data at the same time/v2/fungible/venues(venues()): Get metadata for all supported swapping venues (DEXes, liquid staking protocols, etc…), including name and logo.
/tx methods: Functionality for Tracking Inflight transactions
The /v2/tx endpoints & their corresponding functions in @skip-go/client provide functionality for submitting transactions and tracking the status of cross-chain transactions with a unified interface across all underlying hops & bridge types.
The most important tx methods include:
/v2/tx/submit(submitTransaction()): Submits a transaction on chain through Skip’s nodes and registers the transaction for tracking with Skip Go API (Recommended especially for Solana and other high congestion networks where successfully submitting a transaction can be tricky)/v2/tx/track(trackTransaction()): Registers a transaction for tracking with Skip Go API (Often used instead of/submitwhen an integrator has their own chain nodes for submitting)/v2/tx/status(transactionStatus()): Get the current status of a multi-hop transaction
/tx API reference
Typical Usage in Cross-chain Swapping Frontend
On a cross-chain swapping and transferring frontend, integrators typically:-
Use the
infomethods to populate the list of potential starting & ending chains & assets
-
Use
/fungible/route(route()) to get a quote when the user selects all their chains & tokens and inputs one of their amounts
-
Use
/fungible/msgs(messages()) to get a transaction for the user to sign after they’ve locked in the route & begun the transaction creation process
-
Use
/tx/track(trackTransaction()) to register the transaction for tracking (or/tx/submitto register and submit it on-chain) -
Use
/tx/status(transactionStatus()) to get the real-time status of the transaction as it progresses across bridges and/or chains.