Skip to main content

WaaS Quickstart (iOS)

This tutorial explains how to run the Demo App on iOS with the WaaS React Native SDK.

Successfully building the demo app proves that you have the development environment to do multi-party computation (MPC), and demonstrates how the WaaS APIs work.

info

The WaaS SDK supports both iOS and Android.

Prerequisites

This tutorial assumes that you:

  1. Installed the WaaS React Native SDK and its dependencies.
  2. Created an API key.

Getting Started

Clone the Demo App

The demo application is hosted within the GitHub repo for the WaaS React Native SDK.

To get started, clone the WaaS React Native SDK repo:

git clone git@github.com:coinbase/waas-sdk-react-native.git

Run a Proxy Server

As a security best practice, it is recommended that you use a proxy server to prevent your API keys from being compromised when making requests to the WaaS API.

We provide an open source proxy server for the WaaS API.

To setup, build, and run the proxy server, follow the Proxy Server Setup instructions.

Launch the Simulator

  1. Navigate to the root directory of the WaaS SDK repo: waas-sdk-react-native

  2. Open Xcode and from a terminal run:

    # Install packages for the root and /example directories
    yarn bootstrap

    # Start the Metro server
    yarn example start
  3. In a separate terminal window, navigate to waas-sdk-react-native and run:

    # Build and start the app on the iOS simulator
    yarn example ios --simulator "iPhone 14"

    The iOS simulator will launch and you are ready to run the Demo App demos.

    WaaS SDK simulator with API demos

Run Demo App

In this tutorial, you are going to:

  1. Select a WaaS SDK Mode.
  2. Create a Pool to group your resources.
  3. Register your Device (a simulated iPhone) and put it into a DeviceGroup.
  4. Create a Goerli Testnet Ethereum address.
  5. Create and sign an MPCTransaction.
tip

To scroll down when using the Demo App, left-click your mouse, hold, and drag down. You can also clear the footer message.

1. Mode Selection

The WaaS React Native SDK contains two different modes:

  1. Proxy Mode (recommended): Allows an app to connect to the Coinbase WaaS API through a proxy server.
  2. Direct Mode: Enables an app to make requests directly to the Coinbase WaaS API.

This tutorial assumes you followed the steps to setup and run a proxy server keep your API key secure. Therefore, you should select Proxy Mode.

info

For more information on the differences between each SDK mode, see Proxy Mode vs. Direct Mode.

2. PoolService Demo

The PoolService or "Pool" Demo creates a Pool resource to contain other resources such as keys, addresses, and multiple wallets. For example, if you want to organize wallets by geography, you might have a US pool and an EMEA pool, etc.

  1. Go to the PoolService Demo and click Run.

  2. Input an arbitrary Pool name for display, e.g., US Pool, and click Continue.

    The API calls CreatePool and returns:

    • Pool Resource name, e.g., pools/bdfb2066-6ce1-4dcc-ba3d-f1db52c89c2a
    • Pool Display name, e.g.,: US Pool
    info

    Resource names follow Google standard, AIP-122.

  3. Copy and save the resource name of your Pool to use in the MPCWalletService Demo.

  4. Click Home.

Expand for image and click to enlarge
PoolService Demo
The PoolService lets you segregate funds into groups or pools. We create child resources in the following demos, viz., DeviceGroup and MPCWallet.

3. MPCKeyService

The MPCKeyService or "MPC Keys" Demo generates registration data for the Device and registers the Device on MPCKeyService.

  1. Go to the MPCKeyService Demo and click Run.

  2. Enter a passcode with 6 or more characters and click Continue.

  3. Copy and save the registration data.

  4. Click Copy and save the resource name of the Device to use in the following MPCWalletService demo.

Expand for image and click to enlarge
MPCKeyService Demo
The PoolService lets you segregate funds into groups or pools.

4. MPCWalletService Demo

The MPCWalletService or "GenerateAddress" Demo, creates an MPCWallet, computes the DeviceGroup associated with the MPCWallet, and generates a Goerli Ethereum Address in the MPCWallet.

  1. Go to the MPCWalletService Demo and click Run.

  2. Enter the Pool resource name from the PoolService Demo.

  3. Enter the Device resource name from the MPCKeyService Demo.

  4. Click Continue.

  5. Copy the three returned resources -- you need to clear the footer message and scroll down to see the Address resource:

    a. Copy the DeviceGroup resource name.

    b. Copy the MPCWallet resource name.

    c. Copy the Goerli Ethereum Address.

  6. Paste your new address in Etherscan.io to verify that it's real. It should exist with no transactions.

Expand for images and click to enlarge
MPWalletService Demo part 1
MPWalletService Demo part 2
Test your Goerli Ethereum address in Etherscan.io
In Etherscan.io, your address should be valid but have no transaction data.

5. MPCSignature Demo

The MPCSignature or "Tx Signing" Demo creates an Ethereum transaction with an Address in MPCWallet, computes an MPCSignature for it, and returns the signed transaction.

  1. Go to the MPCSignature Demo and click Run.

  2. Enter your Ethereum address in the "Address resource" field.

  3. Enter the DeviceGroup resource name.

  4. Click Continue.

    An EIP-1559 transaction is created and its data populates the window.

    {
    "ChainID": "0x5",
    "Nonce": 0,
    "MaxPriorityFeePerGas": "0x400",
    "MaxFeePerGas": "0x400",
    "Gas": 63000,
    "To": "0xd8ddbfd00b958e94a024fb8c116ae89c70c60257",
    "Value": "0x1000",
    "Data": ""
    }
    caution

    If you want to broadcast, replace this placeholder transaction with a valid transaction.

  5. Click Continue again (or if you want to sign some other transaction, you can replace the text).

    The hex-encoded payload of the Signature is returned.

  6. Copy and save the Signature.

  7. Copy and save the signed transaction.

Expand for images and click to enlarge
MPCSignature Demo part 1
MPCSignature Demo part 2

Was this helpful?