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.
The Para Solana Web3 Signer works seamlessly with the Solana Web3.js library:
Copy
Ask AI
import { Para as ParaServer, Environment } from "@getpara/server-sdk";import { ParaSolanaWeb3Signer } from "@getpara/solana-web3.js-v1-integration";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 connectionconst solanaConnection = new Connection(clusterApiUrl("testnet"));// Create the Para Solana Signerconst solanaSigner = new ParaSolanaWeb3Signer(paraServer, solanaConnection);// Get the wallet addressconst walletAddress = solanaSigner.sender.toBase58();console.log(`Wallet address: ${walletAddress}`);// Create and send a transactionconst 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}`);
Para can be used with Anchor by creating an Anchor-compatible wallet wrapper:
Copy
Ask AI
import { Para as ParaServer, Environment } from "@getpara/server-sdk";import { ParaSolanaWeb3Signer } from "@getpara/solana-web3.js-v1-integration";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 connectionconst solanaConnection = new Connection(clusterApiUrl("testnet"));const solanaSigner = new ParaSolanaWeb3Signer(paraServer, solanaConnection);// Create an Anchor-compatible walletconst 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 providerconst provider = new anchor.AnchorProvider( solanaConnection, anchorWallet, { commitment: "confirmed" });// Now you can use this provider with any Anchor programconst program = new anchor.Program( YOUR_IDL, "PROGRAM_ID_HERE", provider);// Interact with your programawait program.methods .yourProgramMethod() .accounts({ // Your accounts here }) .rpc();