CreateWallet (JS SDK)

Integration

Call initialiseCreateWallet to set up handlers.

Then provide the user's email address to createWallet. When this component is rendered, an email is sent to the user prompting them to verify it. Once verified, a Paper Wallet address on the specified chain is returned.

The same email address will always resolve to the same wallet address on a given blockchain so it is safe to verify email addresses that already have a Paper Wallet.

Code Example

import {
  createWallet,
  initialiseCreateWallet,
} from '@paperxyz/js-client-sdk';

// On page load...
await initialiseCreateWallet({
  onSuccess,
  onEmailVerificationInitiated,
  onError
});

// When you are ready to prompt the user...
await createWallet({
  chainName = "Polygon",
  emailAddress,
  clientId,
  redirectUrl,
});

initialiseCreateWallet Props

PropsTypeDescription
onSuccess
Required
(user: { emailAddress: string; walletAddress: string; accessCode?: string; }) => voidA callback called when the email is verified and wallet address is created.

The user's email address and wallet address are returned.
accessCode will be present if clientId is provided (see below).
onEmailVerificationInitiated() => voidA callback called after Paper sends an email for the user to verify.

If not provided, Paper provides a UI to tell the user to check their inbox.
onError (error: PaperSDKError) => voidA callback called if there is an error sending the email or creating a wallet address.

createWallet Props

PropsTypeDescription
chainName
Required
SupportedChainNameThe wallet will be created on that specified chain. A user will have the same address on all EVM blockchains.
emailAddress
Required
stringThe user's email address that needs to be verified.
redirectUrl
Required
stringA URL to redirect the user once they click the link in their email.

If not provided, the email link prompts the user to close the tab and return to your app.
clientId
Required
stringIf provided, an accessCode is provided in the onSuccess callback. This accessCode is used to query the user's wallet information later.