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

To use Para, you need an API key. This key authenticates your requests to Para services and is essential for integration. Before integrating Para with your application, ensure you have:

  • Completed Para authentication setup in your application (see one of our Setup Guides)
  • A valid Para API key
  • An RPC endpoint for your desired network

Need an API key? Visit the Developer Portal to create API keys, manage billing, teams, and more.

Installation

Choose your preferred package manager to install the required dependencies:

npm install @getpara/solana-web3.js-v1-integration @solana/web3.js

Setting Up the Signer

Initialize the Para Solana signer:

import { ParaSolanaWeb3Signer, createTestTransaction } from "@getpara/solana-web3.js-v1-integration";
import { Connection, clusterApiUrl, Transaction } 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);

// The test transaction sends 0.01 testnet SOL to your own address
const transaction: Transaction = await createTestTransaction(para);

const signedTx = await solanaSigner.signTransaction(transaction);

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 Signing

Para’s signers can also be used on the server-side using pregen wallets or an active client side session. To learn more about using para on the server, check out these guides:

Examples

If you’d like to learn more about how to use the ParaSolanaWeb3Signer for different transaction types, check out this example in our Examples Hub: