๐Ÿ”Creating a wallet

The first step to the MPC process is generating key shares, or a wallet, for your users.

In the MPC wallet generation process, two sets of key shares are generated. The signing key shares are used for signing transactions, and the backup key shares are used for recovery if the device storing a signing key shares is lost.

The generate command initiates the MPC process to create a set of shares. The users share and the wallet address is automatically stored in the user's secure phone storage using your configured mobile storage adapter.

MyGenerateButton.tsx
import React, { useEffect, useState } from 'react'
import {Button, View} from 'react-native';
import { usePortal } from '@portal-hq/core'


const MyGenerateButton = () => {
  const portal = usePortal()
  const [share, setShare] = useState<string>()
  
  const handleGenerate = async () => {
    // Generate signing shares
    await portal.mpc.generate()
    // Read the share back from mobile storage
    const existingShare = await portal.mpc.getSigningShare()
    setShare(existingShare)
  }
  
  useEffect(() => {
    if (share) {
      // MPC share is generated!
    }
  }, [share])

  return (
    <>
      {portal && (
        <View>
          <Button
            disabled={!!share}
            onPress={handleGenerate}
            title="Generate Signing Shares"
          />
        </View>
      )}
    </>
  )
}

export default MyGenerateButton

Be sure to use a Production API key when creating clients for production. Read more details about going to production here.

Choosing an Implementation

Now that you've generated a wallet, it's time to choose a Portal implementation for your app!

We provide ready-to-use components that are able to be plugged in to your mobile app.

We also provide the functions that power those components for you to build your own experience powered by Portal.

WARNING: To create a wallet with the Portal SDK, your device must be configured to use passcode authentication. If you change your passcode, your Portal wallet will continue to operate as expected. However, if you disable passcode authentication after running the generate function, you will be required to execute the recover function before you can continue using your Portal wallet.

Next Steps

Choose either the components or native implementation as the next step!

Last updated