To sponsor gas fees for transactions on Solana, see our guide here.
To rely on Privy’s API to fill in the recentBlockhash field of the Solana transaction, pass in the dummy value 11111111111111111111111111111111 for the recentBlockhash field.
To send a transaction from a wallet using the React SDK, use the signAndSendTransaction method from the useSignAndSendTransaction hook:
signAndSendTransaction: (input: {
  transaction: Uint8Array<ArrayBufferLike>;
  wallet: ConnectedStandardSolanaWallet;
  chain?: SolanaChain;
  options?: (SolanaSignTransactionOptions & {
    mode?: SolanaSignAndSendTransactionMode;
    commitment?: SolanaTransactionCommitment;
    skipPreflight?: boolean;
    maxRetries?: number;
  } & {
    uiOptions?: SendTransactionModalUIOptions;
  })
}) => Promise<SolanaTransactionReceipt>

Usage

import {useSignAndSendTransaction, useWallets} from '@privy-io/react-auth/solana';
import {
  pipe,
  createSolanaRpc,
  getTransactionEncoder,
  createTransactionMessage,
  setTransactionMessageFeePayer,
  setTransactionMessageLifetimeUsingBlockhash,
  appendTransactionMessageInstructions,
  compileTransaction,
  address,
  createNoopSigner
} from '@solana/kit';
import {getTransferSolInstruction} from '@solana-program/system';

// Inside your component
const {signAndSendTransaction} = useSignAndSendTransaction();
const {wallets} = useWallets();

const selectedWallet = wallets[0];

const amount = 1;

const transferInstruction = getTransferSolInstruction({
  amount: BigInt(parseFloat(amount) * 1_000_000_000), // Convert SOL to lamports
  destination: address('RecipientAddressHere'),
  source: createNoopSigner(address(selectedWallet.address))
});

// Configure your RPC connection to point to the correct Solana network
const {getLatestBlockhash} = createSolanaRpc('https://api.mainnet-beta.solana.com'); // Replace with your Solana RPC endpoint
const {value: latestBlockhash} = await getLatestBlockhash().send();

// Create a transaction using @solana/kit
const transaction = pipe(
  createTransactionMessage({version: 0}),
  (tx) => setTransactionMessageFeePayer(address(selectedWallet.address), tx), // Set the message fee payer
  (tx) => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, tx), // Set recent blockhash
  (tx) => appendTransactionMessageInstructions([transferInstruction], tx), // Add your instructions to the transaction
  (tx) => compileTransaction(tx), // Compile the transaction
  (tx) => new Uint8Array(getTransactionEncoder().encode(tx)) // Finally encode the transaction
);

// Send the transaction
const receipt = await signAndSendTransaction({
  transaction: transaction,
  wallet: selectedWallet
});

console.log('Transaction sent with signature:', receipt.signature);

Parameters

Returns

signature
string
The signature of the transaction.

Sign and send all transactions

To sign and send multiple transactions in a single call, use the signAndSendAllTransactions method from the ConnectedStandardSolanaWallet object:
signAndSendAllTransactions(inputs: SolanaSignAndSendTransactionInput[]): Promise<SolanaSignAndSendTransactionOutput[]>

Usage

import {useWallets} from '@privy-io/react-auth/solana';
import {
  pipe,
  createSolanaRpc,
  getTransactionEncoder,
  createTransactionMessage,
  setTransactionMessageFeePayer,
  setTransactionMessageLifetimeUsingBlockhash,
  appendTransactionMessageInstructions,
  compileTransaction,
  address,
  createNoopSigner
} from '@solana/kit';
import {getTransferSolInstruction} from '@solana-program/system';

// Inside your component
const {wallets} = useWallets();

const selectedWallet = wallets[0];

const amount = 1;

const transferInstruction = getTransferSolInstruction({
  amount: BigInt(parseFloat(amount) * 1_000_000_000), // Convert SOL to lamports
  destination: address('RecipientAddressHere'),
  source: createNoopSigner(address(selectedWallet.address))
});

// Configure your RPC connection to point to the correct Solana network
const {getLatestBlockhash} = createSolanaRpc('https://api.mainnet-beta.solana.com'); // Replace with your Solana RPC endpoint
const {value: latestBlockhash} = await getLatestBlockhash().send();

// Create transactions using @solana/kit
const transactions = [
  pipe(
    createTransactionMessage({version: 0}),
    (tx) => setTransactionMessageFeePayer(address(selectedWallet.address), tx), // Set the message fee payer
    (tx) => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, tx), // Set recent blockhash
    (tx) => appendTransactionMessageInstructions([transferInstruction], tx), // Add your instructions to the transaction
    (tx) => compileTransaction(tx), // Compile the transaction
    (tx) => new Uint8Array(getTransactionEncoder().encode(tx)) // Finally encode the transaction
  ),
  pipe(
    createTransactionMessage({version: 0}),
    (tx) => setTransactionMessageFeePayer(address(selectedWallet.address), tx),
    (tx) => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, tx),
    (tx) => appendTransactionMessageInstructions([transferInstruction], tx),
    (tx) => compileTransaction(tx),
    (tx) => new Uint8Array(getTransactionEncoder().encode(tx))
  )
];

// Send the transaction
const receipts = await wallet.signAndSendAllTransactions(
  transactions.map((transaction) => ({
    chain: 'solana:mainnet',
    transaction
  }))
);

console.log(
  'Transaction sent with signature:',
  receipts.map((receipt) => receipt.signature.toString()).join(',')
);

Parameters

For complete examples of sending SOL and SPL tokens using Privy’s SDKs, check out the sending a SOL transaction recipe and the sending SPL tokens recipe.