Getting Started
@skip-go/client is a TypeScript library that streamlines interaction with the Skip Go API, enabling cross-chain swaps and transfers across multiple ecosystems.
Install Library
Install the library using npm or yarn:
If you’re using yarn
(or another package manager that doesn’t install peer dependencies by default)
you may need to install these peer dependencies as well:
Initialize Library
To start integrating with the Skip Go API, you no longer initialize a SkipClient
instance. Instead, you configure the library once and then import and use individual functions directly.
Initialization Options
The library can be initialized using setClientOptions
or setApiOptions
. Both functions accept apiUrl
and apiKey
.
setClientOptions(options)
: Use this if you plan to useexecuteRoute
. It configures your API credentials and lets you provide chain-specific settings like endpoints, Amino types, and registry types.setApiOptions(options)
: Use this if you primarily need to configure API interaction (apiUrl
,apiKey
) or set up affiliate fees (chainIdsToAffiliates
). This option does not configureendpointOptions
,aminoTypes
, orregistryTypes
.
You typically call one of these functions once at application startup.
Configuration Parameters
Below are the common configuration parameters. Refer to the specific options
type for setClientOptions
or setApiOptions
for full details.
apiUrl?: string
: Override the default API URL. Can be passed tosetClientOptions
orsetApiOptions
, or directly to individual API functions if neither initialization function is called.apiKey?: string
: Your Skip API key. Can be passed tosetClientOptions
orsetApiOptions
, or directly to individual API functions if neither initialization function is called. Required for certain features.endpointOptions?: EndpointOptions
: Provide RPC and REST endpoints for specific chains (used bysetClientOptions
).aminoTypes?: AminoConverters
: Additional amino types for message encoding (used bysetClientOptions
).registryTypes?: Iterable<[string, GeneratedType]>
: Additional registry types (used bysetClientOptions
).cacheDurationMs?: number
: Duration in milliseconds to cache responses for functions likechains
andassets
(used bysetClientOptions
).
Setup Signers
To execute transactions, you need to set up signers for the ecosystems you plan to interact with. Below are examples for Cosmos SDK, EVM, and Solana (SVM). Note that for EVM and SVM, you’ll need to install additional libraries.
Signer Setup
Query Basic Info
With the library initialized, you can query balances, supported chains and assets using the imported functions.
Query Examples
Get a Route
Once you’ve selected your source and destination chains and tokens, you can generate a route and get a quote using the route
function. See it in context here.
Route Examples
Read more about affiliate fees, Smart Relay and EVM Swaps.
Get Required Addresses
After generating a route, you need to provide user addresses for the required chains. The route.requiredChainAddresses
array lists the chain IDs for which addresses are needed.
Only use addresses your user can sign for. Funds could get stuck in any address you provide, including intermediate chains in certain failure conditions. Ensure your user can sign for each address you provide. See Cross-chain Failure Cases for more details.
We recommend storing the user’s addresses and creating a function like getAddress
that retrieves the address based on the chain ID.
Execute the Route
Once you have a route, you can execute it in a single function call by passing in the route, the user addresses for at least the chains the route includes, and optional callback functions. This also registers the transaction for tracking.
For routes that consist of multiple transactions, executeRoute
will monitor each transaction until it completes, then generate the transaction for the next step and prompt the user to sign it using the appropriate signer.
Alternatively, you can handle message generation, signing, and submission manually using the individual functions:
messages
: Generate transaction messages.messagesDirect
: A convenience function that combines the functionality of/route
and/msgs
into a single call. It returns the minimal number of messages required to execute a multi-chain swap or transfer.broadcastTx
: Broadcast transactions to the network.submitTransaction
: Submit and track transactions. Refer to the API documentation for details on these lower-level functions.
Transaction Tracking
After a transaction is registered for tracking (either via executeRoute
, submitTransaction
, or trackTransaction
), you can poll for its status:
- Check Status:
transactionStatus
- Takes atxHash
andchainId
and returns the current cross-chain status.
Remember, if you use executeRoute
(Step 7), it automatically handles the transaction lifecycle, including waiting for completion. The manual tracking functions (submitTransaction
, trackTransaction
, transactionStatus
) are primarily for scenarios where you are not using executeRoute
for full execution (e.g., if you use submitTransaction
directly) or if you need more granular control over the tracking and status polling process.
Have questions or feedback? Help us get better!
Join our Discord and select the “Skip Go Developer” role to share your questions and feedback.