When signing a transaction from an embedded wallet, you can use Privy’s native signTransaction method to customize the signature prompt.

You can sign transactions on the Solana blockchain without sending them. Privy supports both legacy and v0 (versioned) transactions.

signTransaction(transaction: Transaction): Promise<Transaction>;

Here’s an example of how to sign a transaction on Solana with connected Solana external and embedded wallets:

import {PublicKey, Transaction, Connection, SystemProgram} from '@solana/web3.js';
import {useSolanaWallets} from '@privy-io/react-auth';

// The rest of this code must be placed within a React component
// Get Solana wallet
const {ready, wallets} = useSolanaWallets();
const wallet = wallets[0];

// Build transaction request. You should adapt this logic for the particular
// type of transaction you need.
if (!ready || !wallet) return;

// Configure your connection to point to the correct Solana network
let connection = new Connection(clusterApiUrl('devnet'));

// Build out the transaction object for your desired program
// https://solana-labs.github.io/solana-web3.js/classes/Transaction.html
let transaction = new Transaction();

// Sign transaction
const signedTransaction = await wallet.signTransaction!(transaction);
console.log('Signed transaction:', signedTransaction);