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.When using Privy’s server-side SDKs to send transactions, you can use the authorization context to
automatically sign requests. Learn more about signing on the
server.
To send a transaction from a wallet using the React SDK, use the
signAndSendTransaction method from the useSignAndSendTransaction hook:signAndSendTransaction: (input: {
transaction: Uint8Array;
wallet: ConnectedStandardSolanaWallet;
chain?: SolanaChain;
options?: SolanaSignAndSendTransactionOptions & {
uiOptions?: SendTransactionModalUIOptions;
sponsor?: boolean;
optimisticBroadcast?: boolean;
skipSimulation?: boolean;
};
}) => Promise<{ signature: Uint8Array }>
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 result = await signAndSendTransaction({
transaction: transaction,
wallet: selectedWallet
});
console.log('Transaction sent with signature:', result.signature);
Parameters
Hide parameters
Hide parameters
Uint8Array
required
The encoded transaction to be sent.
ConnectedStandardSolanaWallet
required
The Solana wallet to use for sending the transaction.
SolanaChain
Type of all Solana chains supported by Privy.
SolanaSignAndSendTransactionOptions & {uiOptions?: SendTransactionModalUIOptions; sponsor?: boolean; optimisticBroadcast?: boolean; skipSimulation?: boolean}
Additional options for sending the transaction.
Show child attributes
Show child attributes
boolean
Optional parameter to enable gas sponsorship for this transaction. Learn
more.
boolean
When true, returns the signed transaction hash without waiting for on-chain confirmation.
For sponsored transactions, Privy handles this server-side. For non-sponsored transactions,
the send is still awaited but confirmation polling is skipped.
boolean
When true, skips preflight simulation before broadcasting. For sponsored transactions, Privy
forwards this as the
x-privy-skip-simulation header. For non-sponsored transactions, this
maps to skipPreflight on the local RPC send call.Returns
Uint8Array
The signature of the transaction.
Sign and send all transactions
To sign and send multiple transactions in a single call, use thesignAndSendTransaction method with multiple inputs:signAndSendTransaction(...inputs: SignAndSendTransactionInput[]): Promise<SignAndSendTransactionOutput[]>
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; // Amount of SOL to send
const transferInstruction = getTransferSolInstruction({
amount: BigInt(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 multiple transactions
const results = await signAndSendTransaction(
{
transaction: transactions[0],
wallet: selectedWallet
},
{
transaction: transactions[1],
wallet: selectedWallet
}
);
console.log(
'Transactions sent with signatures:',
results.map((result) => result.signature.toString()).join(',')
);
Parameters
Hide parameters
Hide parameters
SignAndSendTransactionInput[]
required
Uint8Array
required
The encoded transaction to be sent.
ConnectedStandardSolanaWallet
required
The Solana wallet to use for sending the transaction.
SolanaChain
Type of all Solana chains supported by Privy.
SolanaSignAndSendTransactionOptions & {uiOptions?: SendTransactionModalUIOptions; sponsor?: boolean; optimisticBroadcast?: boolean; skipSimulation?: boolean}
Additional options for sending the transaction.
Show child attributes
Show child attributes
boolean
Optional parameter to enable gas sponsorship for this transaction. Learn
more.
boolean
When true, returns the signed transaction hash without waiting for on-chain confirmation.
For sponsored transactions, Privy handles this server-side. For non-sponsored
transactions, the send is still awaited but confirmation polling is skipped.
boolean
When true, skips preflight simulation before broadcasting. For sponsored transactions,
Privy forwards this as the
x-privy-skip-simulation header. For non-sponsored
transactions, this maps to skipPreflight on the local RPC send call.SendTransactionModalUIOptions
UI options to customize the transaction request modal.
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.
The wallet RPC endpoint is a synchronous endpoint, and a successful response indicates that the
transaction has been broadcasted to the network. Transactions may get broadcasted but still fail
to be confirmed by the network. The endpoint does not wait for confirmation or retry if the
transaction fails to be confirmed. To handle these scenarios, see our guide on speeding up
transactions.

