With Privy, you can pregenerate self-custodial Ethereum and Solana embedded wallets for existing users, or create a new user with other login methods, like an email address or phone number, without requiring the user to login. You can even send assets to the wallet before the user logs in to your app for the first time.

Once the user associated with the account logs in, they will be able to access the pregenerated wallet and any assets sent to them.

Pregenerating wallets for new users

To pregenerate embedded wallets for a given user, use the importUser method from PrivyClient.

importUser: ({linkedAccounts: LinkedAccountType[], createEthereumWallet?: boolean, createSolanaWallet?: boolean, createEthereumSmartWallet?: boolean, customMetadata?: CustomMetadataType}) => Promise<User>

Usage

const user = await privy.importUser({
    linkedAccounts: [
        {
        type: 'email',
        address: '[email protected]',
        },
    ],
    createEthereumWallet: true,
    createSolanaWallet: true,
    createEthereumSmartWallet: true,
    customMetadata: {
        username: 'name',
        isVerified: true,
        age: 23,
    },
});

Params

linkedAccounts
LinkedAccountType[]
required

An array of linked accounts to associate with the user.

createEthereumWallet
boolean

(Optional) Whether to create an Ethereum wallet for the user.

createSolanaWallet
boolean

(Optional) Whether to create a Solana wallet for the user.

createEthereumSmartWallet
boolean

(Optional) Whether to create an Ethereum smart wallet for the user.

customMetadata
CustomMetadataType

(Optional) Custom metadata to associate with the user.

Returns

user
User

Pregenerating wallets for existing users

To create embedded wallets for an existing user, use the createWallets method from PrivyClient.

createWallets: ({userId: string, createEthereumWallet?: boolean, createSolanaWallet?: boolean, createEthereumSmartWallet?: boolean, numberOfEthereumWalletsToCreate?: number}) => Promise<User>

Usage

const user = await privy.createWallets({
    userId: 'did:privy:clddy332f002tyqpq3b3lv327',
    createEthereumWallet: true,
    createSolanaWallet: true,
    createEthereumSmartWallet: true,
    numberOfEthereumWalletsToCreate: 2,
});

Params

userId
string
required

The Privy user ID to create wallets for.

createEthereumWallet
boolean

(Optional) Whether to create an Ethereum wallet for the user.

createSolanaWallet
boolean

(Optional) Whether to create a Solana wallet for the user.

createEthereumSmartWallet
boolean

(Optional) Whether to create an Ethereum smart wallet for the user.

numberOfEthereumWalletsToCreate
number

(Optional) The number of Ethereum wallets to pregenerate for the user. Defaults to 1.

Returns

user
User