Skip to main content

Install the package

npm install @rhino.fi/sdk

Initialize the SDK

rhino-sdk.ts
import { RhinoSdk } from '@rhino.fi/sdk'

export const rhinoSdk = RhinoSdk({
  apiKey: 'YOUR_API_KEY',
})

Visit the Rhino Developer Portal

You can create a project and manage API keys there.

Make a bridge

bridge.ts
import { SupportedChains, SupportedTokens } from '@rhino.fi/sdk'
import { getEvmChainAdapterFromPrivateKey } from '@rhino.fi/sdk/adapters/evm'
import { rhinoSdk } from './rhino-sdk'

const bridgeResult = await rhinoSdk.bridge({
  type: 'bridge',
  amount: '100',
  token: SupportedTokens.USDT,
  chainIn: SupportedChains.ARBITRUM_ONE,
  chainOut: SupportedChains.SOLANA,
  depositor: 'DEPOSITOR_ADDRESS',
  recipient: 'RECIPIENT_ADDRESS',
  mode: 'receive',
  gasBoost: {
    amountNative: '4'
  }
}, {
  getChainAdapter: chainConfig =>
    getEvmChainAdapterFromPrivateKey(
      'YOUR_PRIVATE_KEY',
      chainConfig,
    ),
    hooks: {
      checkQuote: quote => quote.fees.feeUsd < 5,
      onBridgeStatusChange: status => console.log('Bridge status changed', status),
    },
})

if (bridgeResult.data) {
  console.log('Bridge successful', bridgeResult.data.withdrawTxHash)
} else {
  console.log('Bridge error', bridgeResult.error)
}
This would bridge 100 USDT from Arbitrum to Base while also receiving 4 SOL tokens at the recipient address. Through the checkQuote hook a bridge that would cost over $5 in fees would be aborted.

Resources

SDK concepts

Learn about the core concepts of the SDK

Rhino architecture

Learn about the overall architecture of the Rhino bridge

Bridge functions

Learn more on how to use the bridge functions

Chain adapters

Learn how to use chain adapters to connect to all supported chains