Concepts
Learn about the core concepts of the SDK.
Bridge & Chain configs
Rhino has one bridge configuration that lists all the chains and tokens that are available for bridging. You can get the bridge config through the following SDK call:
Assuming no error occurred, the result will look like this:
The whole object corrosponds to the BridgeConfig
type that is exported by the SDK.
Each key will be a chain while the value will represent the chain config (ChainConfig
type). Each value in the tokens
field of a chain config represents a TokenConfig
.
A lot of functions in the SDK will have the BridgeConfig
or a specific ChainConfig
/TokenConfig
as parameters. So for most advanced use cases you will most likely want to fetch the bridge config first.
Chain Adapters
The SDK follows a modular approach where all blockchain interactions are encapsulated in chain adapters. When using one of the provided bridge functions, you always need to explicitly pass in a chain adapter that matches the origin chain.
Chain adapters handle the following:
- 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
Since the bridge functions will often take chains or tokens as string
parameters, the SDK provides a list of supported chains and tokens to avoid the usage of magic strings. You can use them like this:
Those lists are generated at release time of the SDK and are not guaranteed to be always up to date. Therefore those lists might be out sync with the bridge config if Rhino adds a new supported chain/token or temporarily suspends one.
Always use a freshly fetched bridge config if you want to display a list of available chains or tokens to a user for example. Do not rely on hardcoded lists for such purposes.
Error handling
A lot of functions in the SDK will return an object with nullable data
and error
fields instead of throwing. Checking one for being defined will automatically narrow down the type of the other to non-nullable in the opposite code path. Errors are always a discriminated union type with a _tag
or type
field as discriminator. Some error types will also contain some additional fields with specific information about the error.
For example, an error that could occur when generating a user quote could be: