Skip to main content

Bridge and chain configs

Rhino.fi has two configurations:
  • The bridge config lists every chain and token available for bridging.
  • The swap tokens config lists the tokens available for bridge and swap, by chain.
You can fetch them with these SDK calls:
Learn about the bridge API. If no error occurs, the bridge config looks like this:
The whole object corresponds to the BridgeConfig type exported by the SDK. Each key is a chain, and each value is that chain’s config (the ChainConfig type). Each entry in a chain config’s tokens field is a TokenConfig. Many SDK functions take the BridgeConfig, or a specific ChainConfig or TokenConfig, as parameters. For most advanced use cases, fetch the bridge config first.

Chain adapters

The SDK takes a modular approach: all blockchain interactions are handled by chain adapters. When you use one of the bridge functions, you always pass in a chain adapter that matches the origin chain. Chain adapters handle:
  • Fetching balances
  • Checking and setting token allowances
  • Making a deposit to a bridge contract
  • Estimating the gas fees for a bridge transaction (optional)
Resources:

Supported chains and tokens

Bridge functions often take chains or tokens as string parameters, so the SDK provides lists of supported chains and tokens to avoid magic strings:
These lists are generated when the SDK is released, so they can fall out of sync with the bridge config if Rhino.fi adds a chain or token, or temporarily suspends one.
To show users a list of available chains or tokens, always use a freshly fetched bridge config. Don’t rely on these hard-coded lists for that.
SupportedTokens doesn’t include swap tokens, as they change too often for a static list. See Supported chains and tokens for the chains and tokens available for Smart Deposit Addresses.

Error handling

Many SDK functions return an object with nullable data and error fields instead of throwing. Checking that one is defined narrows the other to non-nullable in the opposite code path. Errors are always a discriminated union with a _tag or type field as the discriminator. Some error types include extra fields with details about the error. For example, an error when generating a user quote could be:
Amounts in errors are decimal strings in whole token units, as everywhere in the API. See Errors for the common error names and what to do about them.