Skip to main content

Quickstart (iOS)

The tutorial explains how to run the Sample App on iOS with the WaaS React Native SDK.

Successfully building the sample 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 prerequisites, iOS dependencies, and the SDK.
  2. Created an API key, and ideally tested it against the client libraries.
info

To simply run the demos below, you can clone the SDK rather than install:

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

Authenticate

To run the SDK demos, you can authenticate as follows:

  1. Navigate into the waas-sdk-react-native repo:

    cd {path_to}/waas-sdk-react-native
  2. Edit the hidden file /example/src/.coinbase_cloud_api_key.json with your API credentials:

    tip

    To see hidden files in your Mac Finder, press Command+Shift+Dot.

    a. Analyze your keypair which looks like this (with the actual values replaced by {variableNames} here).

    {
    "name": "organizations/{organizationID}/apiKeys/{apiKeyId}",
    "principal": "{principalID}",
    "principalType": "USER",
    "publicKey": "-----BEGIN EC PUBLIC KEY-----\n{PUBLIC_KEY}\n-----END EC PUBLIC KEY-----\n",
    "privateKey": "-----BEGIN EC PRIVATE KEY-----\n{PRIVATE_KEY}\n-----END EC PRIVATE KEY-----\n",
    "createTime": "2023-03-21T02:02:45.362863508Z"
    }

    b. Open /example/src/.coinbase_cloud_api_key.json

    {
    "name": "organizations/organizationID/apiKeys/apiKeyName",
    "privateKey": "-----BEGIN EC PRIVATE KEY-----ExamplePrivateKey-----END EC PRIVATE KEY-----\n"
    }

    c. Replace and save:

    • organizationID with the your organizationID
    • apiKeyName with your apiKeyId
    • ExamplePrivateKey with your actual PRIVATE_KEY between the \n bookends.

Launch Simulator

  1. Navigate to the root directory of the 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 iOS or Android simulator
    yarn example ios --simulator "iPhone 14"

    The iOS simulator launches and you are ready to run the Sample App demos.

    info

    To test against Android, install the Android dependencies and run yarn example android from the root directory in a separate terminal window.

    WaaS SDK simulator with API demos

Run Sample App

In this tutorial, you are going to:

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

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

1. 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.

2. 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.

3. 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.

4. 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?