This method is used to create the Relay client globally in your application. The client can then be retrieved with the getClient method.

Options

PropertyDescriptionRequired
baseApiUrlThe base api url to use when making requests, you can use the MAINNET_RELAY_API or the TESTNET_RELAY_API constants exported by the package.
chainsA list of Relay Chains, by default a list of backup chains is configured
sourceThe source to associate your onchain activity with, should make to a domain
logLevelThe level at which to log, refer to the LogLevel enum exported by the package
pollingIntervalHow often to poll status and check apis, this value is in milliseconds
maxPollingAttemptsBeforeTimeoutThe source to associate your onchain activity with, should be set to a domain
import {
  createClient,
  convertViemChainToRelayChain,
  MAINNET_RELAY_API,
} from "@reservoir0x/relay-sdk";
import { mainnet } from "viem/chains";

createClient({
  baseApiUrl: MAINNET_RELAY_API,
  source: "YOUR.SOURCE",
  chains: [convertViemChainToRelayChain(mainnet)],
});