Solana Web3.js is the official Solana JavaScript API for interacting with the Solana network. This guide will show you how to integrate Para’s wallet and signing capabilities with Solana using our integration package.

Prerequisites

Before integrating Para with Solana, ensure you have:

  • Set up authentication with Para. See our Getting Started guides for details.
  • Configured the Para client in your application
  • Enabled Solana wallet support in the Para Developer Portal

If you haven’t set up Para authentication yet, complete one of our authentication tutorials first and return to this guide when you’re ready to implement Solana integration.

Installation

Choose your preferred package manager to install the required dependencies:

Setting Up the Signer

Initialize the Para Solana signer:

import { ParaSolanaWeb3Signer } from "@getpara/solana-web3.js-v1-integration";
import { Connection, clusterApiUrl } from "@solana/web3.js";
import { para } from "./para"; // Your Para client initialization

// Set up Solana connection
const solanaConnection = new Connection(clusterApiUrl("testnet"));

// Create the Para Solana Signer
const solanaSigner = new ParaSolanaWeb3Signer(para, solanaConnection);

Transaction Signing

Signing Transactions

import { Transaction, SystemProgram, LAMPORTS_PER_SOL, PublicKey } from "@solana/web3.js";

// Create transaction
const transaction = new Transaction().add(
  SystemProgram.transfer({
    fromPubkey: solanaSigner.sender,
    toPubkey: new PublicKey("RECIPIENT_ADDRESS"),
    lamports: LAMPORTS_PER_SOL * 0.1, // 0.1 SOL
  })
);

// Sign the transaction
try {
  const signedTx = await solanaSigner.signTransaction(transaction);
  console.log("Signed transaction:", signedTx);
} catch (error) {
  console.error("Error signing transaction:", error);
}

Sending Transactions

try {
  const signature = await solanaSigner.sendTransaction(transaction, {
    skipPreflight: false,
    preflightCommitment: "confirmed",
  });
  console.log("Transaction signature:", signature);
} catch (error) {
  console.error("Error sending transaction:", error);
}

Additional Methods

The ParaSolanaWeb3Signer provides several additional methods and properties:

  • signBytes(bytes: Buffer): Sign arbitrary bytes directly
  • signVersionedTransaction(transaction: VersionedTransaction): Sign a versioned transaction
  • address: Get the wallet address as a string
  • sender: Get the wallet public key as a solana.PublicKey object

Server-Side Usage

For server-side signing operations with Solana, please refer to our Server-Side Signing Guide for specific instructions.

When using Solana Web3.js server-side, ensure you’re following proper security practices and handling authentication appropriately.

Additional Resources