Skip to content

Creating Solana wallets

With Privy, you can create Solana wallets for your users manually from your frontend once are authenticated in your app, or via wallet pregeneration from your server before they have even logged in.

Manual creation

To create an embedded Solana wallet for your user, use the create method of the wallet interface returned by the useEmbeddedSolanaWallet hook. Do not pass any parameters to the method.

Users may only have one embedded Solana wallet currently. To check if your user already has an embedded Solana wallet, pass the wallet interface to Privy's isNotCreated method.

Below is an example of creating a wallet only for users who do not already have a wallet.

tsx
import {useEmbeddedSolanaWallet, isNotCreated} from '@privy-io/expo';

const WalletButton = () => {
  const wallet = useEmbeddedSolanaWallet();

  if (isNotCreated(wallet)) {
    return <Button onPress={() => wallet.create()}>Create Wallet</Button>;
  }

  return <p>{wallet.publicKey}</p>;
};

INFO

If your app uses both Ethereum and Solana embedded wallets, you must create the Ethereum embedded wallet first before creating a Solana embedded wallet. If you create a Solana embedded wallet first, you will not be able to create an Ethereum embedded wallet later. We are actively working on support for creating an Ethereum embedded wallet for a user with an existing Solana embedded wallet.

Pregenerating Solana wallets

With Privy, you can pregenerate self-custodial Solana embedded wallets associated with a given account, 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.

Follow the embedded wallet pregeneration guide to create Solana wallets for your users.

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