Appearance
Creating the wallet
To create an embedded wallet for your user, call the createWallet
method on your Privy client's embeddedWallet
class.
Privy embedded wallets are hierarchical deterministic (HD) wallets, and a user's seed entropy can support multiple separate embedded wallets. If a user already has a wallet and you'd like to create additional HD wallets for them, pass in true
for the allowAdditional
parameter.
swift
// ensure user is authenticated first
guard case .authenticated = authManager.authState else { return }
_ = try? await privy.embeddedWallet.createWallet(allowAdditional: false)
If a wallet is successfully created for the user, privy.embeddedWallet.embeddedWalletState
will update.
This method will throw an error if:
- There is no authenticated user
- Embedded wallet state is not "connected"
- If an embedded wallet already exists and
allowAdditional
was set to false - If a user already has 9 or more wallets
- If the network call to create the wallet fails