Getting Started
Setup the Relay SDK in your application
Installation
Install the Relay SDK and its peer dependency viem
Environment Requirements:
node 18+ typescript ^5.0.4 (if using typescript)
Configuration
To configure the SDK we first need to create a global instance of a RelayClient:
You can replace the baseApiUrl
with TESTNET_RELAY_API
when testing with testnets. In the example above we also pass in an array of RelayChains converted from a viem chain, the sdk exports a function (convertViemChainToRelayChain
) to easily do this. Learn more about the createClient
options.
(Optional) Dynamically Configure Chains:
The sdk provides a utility function for fetching the supported chains dynamically and configuring the SDK. Below is an example of how you could set that up:
The above example demonstrates how to setup dynamic chains in a react application. At the start of your application you would basically configure the dynamic chains in the SDK by using the configureDynamicChains
method. Then with the new chains in the promise you would use the viemChain
property to create the wagmi config (refer to the wagmi docs for this). Finally take the resulting chains and configure the RainbowKitProvider
. Although in this example we used RainbowKit + Wagmi, you’re free to choose whatever libraries you’d like to connect a users wallet. You can call this method as often as you like to refresh the SDK’s chains.