Wallet connect
@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 the WalletConnectorProvider
for wallet connection functionality:
Alternatively, you can integrate third-party wallet libraries by implementing the WalletConnectorContextState
interface from @orderly.network/hooks
.
Custom wallet connection provider
You can also customize wallet connections by implementing all the properties defined in WalletConnectorContextState
. Define the component in the following format:
After defining the component, you also need to add this component to the parent of OrderlyAppProvider
.
Interface & Context
Implementation
The following example demonstrates a wallet connection component implemented using web3modal
. You can use this example as a reference to implement your own wallet connection component.