This is the repository for the mobile React Native SDK for Wallet-as-a-Service APIs. It exposes a subset of the WaaS APIs to the mobile developer and, in particular, is required for the completion of MPC operations such as Seed generation and Transaction signing.
For iOS development:
- Xcode 14.0+
- iOS15.2+ simulator (iPhone 14 recommended)
- CocoaPods
For Android development:
- Android Studio
- x86_64 Android emulator running Android 30+ (Pixel 5 running S recommended)
- Android NDK
- Java 8
- Java JDK 17 (JDK 19 will not work with React Native)
With npm
:
npm install --save @coinbase/waas-sdk-react-native
With yarn
:
yarn add @coinbase/waas-sdk-react-native
See index.tsx for the list of supported APIs.
This repository provides an example app that demonstrates how the APIs should be used.
NOTE: An example Cloud API Key json file is at
example/src/.coinbase_cloud_api_key.json
To run the example app, populate, or replace, this file with the Cloud API Key file provided to you by Coinbase.
Ensure you have XCode open and run the following from the root directory of the repository:
yarn bootstrap # Install packages for the root and /example directories
yarn example start # Start the Metro server
yarn example ios --simulator "iPhone 14" # Build and start the app on iOS simulator
Ensure you have the following Android environment variables set correctly:
ANDROID_HOME
ANDROID_SDK_ROOT="${ANDROID_HOME}"
ANDROID_NDK_HOME="${ANDROID_HOME}/ndk/<insert ndk version>"
ANDROID_NDK_ROOT="${ANDROID_NDK_HOME}"
And then export the following to your PATH
:
export PATH="${ANDROID_HOME}/emulator:${ANDROID_HOME}/cmdline-tools/latest/bin:${ANDROID_HOME}/tools:${ANDROID_HOME}/tools/bin:${ANDROID_HOME}/platform-tools:${PATH}"
Run the following from the root directory of the repository:
yarn install # Install packages for the root directory
emulator -avd Pixel_5_API_31 # Use any x86_64 emulator with min SDK version: 30.
yarn example start # Start the Metro server
yarn example android # Build and start the app on Android emulator
Broadly speaking, there are two possible approaches to using the WaaS SDK:
- Use the WaaS backends directly for all calls.
- Use the WaaS backends directly only for MPC operations; proxy all other calls through an intermediate server.
Of these two approaches, we recommend approach #2, as outlined in the following diagram:
The motivation for placing a proxy server in between your application and the WaaS backends are as follows:
- Your proxy server can log API calls and collect metrics.
- Your proxy server can filter results as it sees fit (e.g. policy enforcement).
- Your proxy server can perform end user authentication.
- Your proxy server can store the Coinbase API Key / Secret, rather than it being exposed to the client.
- Your proxy server can throttle traffic.
In short, having a proxy server that you control in between your application and the WaaS backends will afford you significantly more control than using the WaaS backends directly in most cases.
The methods from the WaaS SDK which are required to be used for participation in MPC are:
initMPCSdk
bootstrapDevice
getRegistrationData
computeMPCOperation