Privy’s ConnectedSolanaWallet object is fully compatible with popular web3 libraries for interfacing wallets, such as @solana/web3js and solana/kit.

Read below to learn how to best integrate Privy alongside these libraries.

@solana/web3.js

First find your desired wallet from the wallets array:

import {PublicKey, Transaction, Connection, SystemProgram} from '@solana/web3.js';

const {wallets} = useSolanaWallets();
const wallet = wallets[0]; // Replace this with your desired wallet

Then, use this wallet to then send Transactions using the @solana/web3.js Transaction and Connection classes:

// 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();

// Send transaction
console.log(await wallet.sendTransaction!(transaction, connection));