Skip to content

Coinbase Wallet as a Service (WaaS) SDK for React Native. Enables MPC Operations for iOS and Android Devices.

License

Notifications You must be signed in to change notification settings

Tkelley325/waas-sdk-react-native

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

React Native WaaS SDK

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.

Prerequisites:

For iOS development:

For Android development:

Installation

With npm:

npm install --save @coinbase/waas-sdk-react-native

With yarn:

yarn add @coinbase/waas-sdk-react-native

Android

In your Android application's settings.gradle file, make sure to add the following:

include(':go-internal-sdk')
project(':go-internal-sdk').projectDir = new File(settingsDir, '../node_modules/@coinbase/waas-sdk-react-native/android/go-internal-sdk')
include(':mpc-sdk')
project(':mpc-sdk').projectDir = new File(settingsDir, '../node_modules/@coinbase/waas-sdk-react-native/android/mpc-sdk')

Usage

See index.tsx for the list of supported APIs.

Example App

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.

iOS

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

NOTE: To build an app that depends on the WaaS SDK, you'll also need a compatible version of OpenSSL. You can build the OpenSSL framework by running the following on your Mac from the root of this repository:

yarn ssl-ios

You can alternatively depend on an open-compiled version of OpenSSL, like OpenSSL-Universal, by adding the following to your app's Podfile:

pod "OpenSSL-Universal"

Android

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

Recommended Architecture

Broadly speaking, there are two possible approaches to using the WaaS SDK:

  1. Use the WaaS backends directly for all calls.
  2. 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:

Recommended Set-up

The motivation for placing a proxy server in between your application and the WaaS backends are as follows:

  1. Your proxy server can log API calls and collect metrics.
  2. Your proxy server can filter results as it sees fit (e.g. policy enforcement).
  3. Your proxy server can perform end user authentication.
  4. Your proxy server can store the Coinbase API Key / Secret, rather than it being exposed to the client.
  5. 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:

  1. initMPCSdk
  2. bootstrapDevice
  3. getRegistrationData
  4. computeMPCOperation

About

Coinbase Wallet as a Service (WaaS) SDK for React Native. Enables MPC Operations for iOS and Android Devices.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 32.9%
  • Objective-C 30.9%
  • Java 18.1%
  • Swift 13.8%
  • Ruby 1.5%
  • Shell 1.4%
  • Other 1.4%