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[], customMetadata?: CustomMetadataType, wallets?: WalletCreateRequestType[]}) => Promise<User>

Usage

const user = await privy.importUser({
    linkedAccounts: [
        {
        type: 'email',
        address: '[email protected]',
        },
    ],
    customMetadata: {
        username: 'name',
        isVerified: true,
        age: 23,
    },
    wallets: [
        {
            chainType: 'ethereum',
            createSmartWallet: true,
            additionalSigners: [
                {
                    signerId: '<signer-id>',
                    policyIds: ['<policy-id>']
                }
            ]
        },
        {
            chainType: 'solana',
            additionalSigners: [
                {
                    signerId: '<signer-id>',
                    policyIds: ['<policy-id>']
                }
            ]
        }
    ]
});

Params

linkedAccounts
LinkedAccountType[]
required

An array of linked accounts to associate with the user.

customMetadata
CustomMetadataType

(Optional) Custom metadata to associate with the user.

wallets
WalletCreateRequestType[]

(Optional) An array of wallets to create for the user.

Returns

user
User

The user with the newly created wallets.

Creating wallets for existing users

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

createWallets: ({userId: string, wallets?: WalletCreateRequestType[]}) => Promise<User>

Usage

const user = await privy.createWallets({
    userId: 'did:privy:clddy332f002tyqpq3b3lv327',
    wallets: [
        {
            chainType: 'ethereum',
            createSmartWallet: true,
        },
        {
            chainType: 'solana',
        }
    ]
});

Params

userId
string
required

The Privy user ID to create wallets for.

wallets
WalletCreateRequestType[]

(Optional) An array of wallets to create for the user.

Returns

user
User

The user with the newly created wallets.