@orderly.network/react-app
is an application layer of the Orderly API. It is mainly responsible for rendering the UI, handling user interaction events, and completing trading actions. Therefore, it does not include built-in wallet connection functionality.
In places where wallet connection needs to be handled, @orderly.network/react-app
utilizes React’s context mechanism to obtain information about the currently connected wallet or call wallet connection functions provided by the context. To facilitate this, @orderly.network/react-app
defines a context named WalletConnectorContext
. Any component that implements the WalletConnectorContext.Provider
defined in WalletConnectorContextState
can serve as the wallet connection component for the app. Please refer to this link for more details.
Using the wallet connection component provided by Orderly
Orderly SDK provides a built-in wallet connection component supporting both EVM and Solana. Here’s how to integrate it:Install Wallet Connector Dependencies
Add the WalletConnectorProvider Component
Wrap your application with theWalletConnectorProvider
for wallet connection functionality:
Wallet Connector Privy
The Privy wallet connector consists of three parts:- Privy: Provides social login, featuring an injected wallet, EVM wallets, and Solana wallets.
- Wagmi: Offers connectivity for EVM wallets, such as MetaMask and WalletConnect.
- Solana: Provides connectivity for Solana wallets, such as Phantom and Ledger.
Configuration options
network
(required) – e.g.,mainnet
ortestnet
. This determines the network used by wallets like Solana and Abstract.customChains
(optional) – Brokers can define which chains to display.termsOfUse
(optional) – URL for Terms of Use; if not provided, terms section won’t be shown.
- If
privyConfig
is not configured, the Privy connector will be disabled. - If
wagmiConfig
is not configured, the Wagmi connector will be disabled. - If
solanaConfig
is not configured, the Solana connector will be disabled. - If
abstractConfig
is not configured, the Abstract Global Wallet connector will be disabled. - At least one of
privyConfig
,wagmiConfig
, orsolanaConfig
must be provided.
Behavior based on customChains
:
- If only Solana chains are included, Privy will show only the Solana injected wallet and disable the Wagmi connector.
- If only EVM chains are included, Privy will show only the EVM injected wallet and disable the Solana connector.
Example
Custom wallet connection provider
You can also customize wallet connections by implementing all the properties defined inWalletConnectorContextState
. Define the component in the following format:
OrderlyAppProvider
.
Interface & Context
Implementation
The following example demonstrates a wallet connection component implemented usingweb3modal
. You can use this example as a reference to implement your own wallet connection component.