Skip to content

Multiple embedded wallets

Privy embedded wallets are hierarchical deterministic (HD) wallets, and a user's seed entropy can support multiple separate embedded wallets.

Read below to learn how to create and use multiple HD wallets for the same user.

Create the new wallet

swift
let response = try await privy.embeddedWallet.createWallet(allowAdditional: true)

response.address // address of the new wallet

Send a request with the new wallet

To send a request to an embedded wallet not at the 0-index, pass the desired wallet address as an optional second parameter to provider.request.

swift
guard case .connected(let wallets) = privy.embeddedWallet.embeddedWalletState else {
    print("Wallet not connected")
    return
}

// the target wallet here is looked up by it's position in the list,
// but you may choose to have some application state that includes
// it's address, and look it up that way
let wallet = wallets[1]

// Get RPC provider for wallet
let provider = try privy.embeddedWallet.getProvider(for: wallet.address)

let response = try await provider.request(
    RpcRequest(
        method: "personal_sign",
        params: ["The message that is being signed", wallet.address]
    )
)