Creating a wallet with the SDK
Creating a wallet on an existing account
To create a wallet, simply invoke the function and pass the required parameters. Executing this function will handle signup, if the function is called for the first time. We determine whether it is the first time based on if the user has any Wallaby related data stored in local storage.
If you want to create a wallet with a new account every time, you can utilize createWithNewAccount
function. It takes the same parameters as create
but always calls signup and returns a new user account and its wallet.
If Wallaby data is detected, then the function will sign the user in, then handle creating a second wallet using the same Wallaby userId
.
TODO: Add note about creating a wallet with a new user every time.
If it is a returning user, but simply using another device, then you simply need to call recover
function instead.
See Recovering a wallet with the SDK
After wallet creation, the API will return the user's seedphrase, encrypted using the client's public key, then it will get stored in localstorage on that user's device.
The client's public key is part of a key pair used when signing the user up in Wallaby system. In the signup step, the client's private key gets encrypted and stored in localstorage using the user's provided password and the public key gets sent to Wallaby.
The same private key will be able to decrypt the seedphrase if the user needs to view it on the client's side.
The function makes multiple API calls to Wallaby
Function Parameters
firstName
string
This param is only needed if you are creating a wallet for the first time, since this function handles creating an account as well behind the scene.
lastName
string
Similar to firstName
, it is only needed when first creating an account.
password
string
A new unique password.
Function Response:
assets
Array<UserAsset>
List of all assets in the user's wallet.
wallet
Wallet
Wallet object.
Example:
Last updated