Para Server SDK provides seamless integration with Solana blockchain through both Solana Web3.js and Anchor frameworks. Once you’ve set up and authenticated your Para Server client, the Solana integration works identically to the client-side implementation.

Before using these integrations, ensure you’ve completed the server setup by importing a client session or creating a pregenerated wallet. See the Server Setup Guide for details.

Installation

Install the required dependencies for your preferred Solana library:

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

Implementation

Solana Web3.js Integration

The Para Solana Web3 Signer works seamlessly with the Solana Web3.js library:

import { Para as ParaServer, Environment } from "@getpara/server-sdk@alpha";
import { ParaSolanaWeb3Signer } from "@getpara/solana-web3.js-v1-integration@alpha";
import { Connection, clusterApiUrl, SystemProgram, LAMPORTS_PER_SOL, PublicKey } from "@solana/web3.js";

// Para server client (already authenticated)
const paraServer = new ParaServer(Environment.BETA, "YOUR_API_KEY");

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

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

// Get the wallet address
const walletAddress = solanaSigner.sender.toBase58();
console.log(`Wallet address: ${walletAddress}`);

// Create and send a transaction
const transaction = await solanaSigner.createTransaction({
  instructions: [
    SystemProgram.transfer({
      fromPubkey: solanaSigner.sender,
      toPubkey: new PublicKey("RecipientPublicKeyHere"),
      lamports: 0.01 * LAMPORTS_PER_SOL,
    }),
  ],
});

const signature = await solanaSigner.sendTransaction(transaction);
console.log(`Transaction signature: ${signature}`);

Anchor Integration

Para can be used with Anchor by creating an Anchor-compatible wallet wrapper:

import { Para as ParaServer, Environment } from "@getpara/server-sdk@alpha";
import { ParaSolanaWeb3Signer } from "@getpara/solana-web3.js-v1-integration@alpha";
import { Connection, clusterApiUrl, Transaction, VersionedTransaction } from "@solana/web3.js";
import * as anchor from "@coral-xyz/anchor";

// Para server client (already authenticated)
const paraServer = new ParaServer(Environment.BETA, "YOUR_API_KEY");

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

// Create an Anchor-compatible wallet
const anchorWallet = {
  publicKey: solanaSigner.sender,
  signTransaction: async <T extends Transaction | VersionedTransaction>(tx: T): Promise<T> => {
    return await solanaSigner.signTransaction(tx);
  },
  signAllTransactions: async <T extends Transaction | VersionedTransaction>(txs: T[]): Promise<T[]> => {
    return await Promise.all(txs.map((tx) => solanaSigner.signTransaction(tx)));
  },
};

// Create the Anchor provider
const provider = new anchor.AnchorProvider(
  solanaConnection, 
  anchorWallet, 
  { commitment: "confirmed" }
);

// Now you can use this provider with any Anchor program
const program = new anchor.Program(
  YOUR_IDL, 
  "PROGRAM_ID_HERE", 
  provider
);

// Interact with your program
await program.methods
  .yourProgramMethod()
  .accounts({
    // Your accounts here
  })
  .rpc();

Best Practices

  • Use higher commitment levels (confirmed or finalized) for critical transactions
  • Implement proper error handling for network failures
  • Consider retry logic for Solana RPC endpoints, which can occasionally be unreliable
  • Cache account data where appropriate to reduce RPC usage

Learn More

For detailed examples of using Para with Solana, including SPL token transfers, NFT interactions, and more, refer to our web documentation:

Examples

Explore our server-side Solana integration examples: