Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.getpara.com/llms.txt

Use this file to discover all available pages before exploring further.

Execute transactions on the Solana blockchain using Para’s integrated signers. This includes signing and broadcasting transactions to the network.

Setup Solana Libraries First

import { useParaSolanaSigner, useParaSolanaSignAndSend } from '@getpara/react-sdk';
import { Address } from '@solana/addresses';
import {
  createSolanaRpc,
  createTransactionMessage,
  setTransactionMessageFeePayer,
  setTransactionMessageLifetimeUsingBlockhash,
  appendTransactionMessageInstruction,
  lamports,
  pipe,
} from '@solana/kit';
import { getTransferSolInstruction } from '@solana-program/system';

const rpc = createSolanaRpc("https://api.mainnet-beta.solana.com");
const LAMPORTS_PER_SOL = BigInt(1000000000);

function SendTransaction() {
  const { solanaSigner, isLoading } = useParaSolanaSigner({ rpc });
  const { signAndSendAsync, isPending } = useParaSolanaSignAndSend(solanaSigner);

  const sendSOL = async () => {
    if (!solanaSigner) return;

    const recipient = "RECIPIENT_ADDRESS_HERE" as Address;
    const response = await rpc.getLatestBlockhash().send();
    const { blockhash, lastValidBlockHeight } = response.value;

    const transferInstruction = getTransferSolInstruction({
      source: solanaSigner,
      destination: recipient,
      amount: lamports(LAMPORTS_PER_SOL / 10n),
    });

    const transaction = pipe(
      createTransactionMessage({ version: "legacy" }),
      (tx) => setTransactionMessageFeePayer(solanaSigner.address, tx),
      (tx) => setTransactionMessageLifetimeUsingBlockhash({ blockhash, lastValidBlockHeight }, tx),
      (tx) => appendTransactionMessageInstruction(transferInstruction, tx)
    );

    await signAndSendAsync({ transactions: [transaction] });
  };

  return <button onClick={sendSOL}>Send 0.1 SOL</button>;
}

Next Steps

Get Transaction Status

Send Tokens

Compute Units