Create a React Native App
To make these instructions concrete, we have created a sample ecosystem wallet called Rapidfire ID. To interact with it, you can find its SDK in the NPM package directory: @rapidfire/id.
You can check out the GitHub repository for Rapidfire Wallet to learn how to create your own wallet.
This guide will walk you through adding support for any ecosystem wallet into a React Native app by integrating the Mobile Wallet Protocol Client.
If you need a template or scaffold to start with, you can check out the Ecosystem Wallet Expo Example.
Prerequisites#
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.
Setup#
Install Mobile Wallet Protocol Client#
Add the latest version of Mobile Wallet Protocol Client to your project.
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#
Create a new EIP1193Provider
instance, which is EIP-1193 compliant.
Option 2: Wagmi Connector#
Add the latest verion 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.
Gas Sponsorship#
If you want to sponsor transactions, you need to add #policy=POLICY_ID
to the wallet scheme.
_10#policy=POLICY_ID
For example: