Add to Existing React Native App
This guide helps you add support for Smart Wallet into a React Native app by integrating the Mobile Wallet Protocol Client.
This doc is updated for Mobile Wallet Protocol Client v1.0.0
Deep Link Handling
Breaking change in v1.0.0: Universal Links and App Links requirements are
removed in favor of custom schemes (e.g. myapp://
).
Before You Start
This guide walks you through adding support for Smart Wallet into an existing React Native app or starter project.
If you prefer to skip ahead and start with a working example, navigate to the repository or run the following command to clone it locally:
If you are looking to integrate Smart Wallet into an existing React Native app or starter project, follow the instructions below.
Step 1: Install Mobile Wallet Protocol Client
Add the latest version of Mobile Wallet Protocol Client to your project.
Step 2: Add Polyfills
Install peer dependencies
The Mobile Wallet Protocol Client library requires the Expo WebBrowser and Async Storage packages to be installed. Follow the instructions on the respective pages for any additional setup.
Polyfills
Mobile Wallet Protocol Client requires crypto.randomUUID
, crypto.getRandomValues
, and URL
to be polyfilled globally since they are not available in the React Native environment.
Below is an example of how to polyfill these functions in your app using the expo-crypto and expo-standard-web-crypto packages.
Step 3: Usage
Mobile Wallet Protocol Client provides 2 interfaces for mobile app to interact with the Smart Wallet, an EIP-1193 compliant provider interface and a wagmi connector.
If your app is using wallet aggregator, go straight to Option 2: Wagmi Connector for 1-line integration.
Option 1: EIP-1193 Provider
The app
prefix in SDK config params is removed in v1.0.0.
Create a new EIP1193Provider
instance, which is EIP-1193 compliant.
Option 2: Wagmi Connector
Add the latest version of Mobile Wallet Protocol wagmi-connectors to your project.
Simply import the createConnectorFromWallet
function and pass in the wallet you want to use to wagmi config.
Then you can use wagmi’s react interface to interact with the Smart Wallet.
Give feedback!
Send us feedback on the Coinbase Developer Platform Discord or create a new issue on the MobileWalletProtocol/react-native-client repository.