Skip to main content
The useStellarSigner hook provides a Stellar signer for a Para wallet.

Import

import { useStellarSigner } from "@getpara/react-sdk/stellar";

Usage

import { useStellarSigner } from "@getpara/react-sdk/stellar";
import { Networks, TransactionBuilder, Operation, Asset, BASE_FEE, Horizon } from "@stellar/stellar-sdk";

const server = new Horizon.Server("https://horizon.stellar.org");

function StellarSigner() {
  const { stellarSigner, isLoading } = useStellarSigner({
    networkPassphrase: Networks.PUBLIC,
  });

  const handleSign = async () => {
    if (!stellarSigner) {
      return;
    }

    const account = await server.loadAccount(stellarSigner.address);

    const transaction = new TransactionBuilder(account, {
      fee: BASE_FEE,
      networkPassphrase: Networks.PUBLIC,
    })
      .addOperation(
        Operation.payment({
          destination: "GRECIPI...",
          asset: Asset.native(),
          amount: "10",
        })
      )
      .setTimeout(180)
      .build();

    const { signedTxXdr } = await stellarSigner.signTransaction(transaction.toXDR());
    console.log("Signed XDR:", signedTxXdr);
  };

  if (isLoading) return <div>Loading Stellar signer...</div>;

  return (
    <div>
      <p>Address: {stellarSigner?.address}</p>
      <button onClick={handleSign}>Sign Transaction</button>
    </div>
  );
}

Network Passphrase Override

The signTransaction method accepts an optional second argument to override the network passphrase per-call. This is useful when signing transactions for a different network than the one configured in the hook:
// Override passphrase for a single call
const { signedTxXdr } = await stellarSigner.signTransaction(transaction.toXDR(), {
  networkPassphrase: Networks.TESTNET,
});
This matches the Stellar SDK’s contract.SignTransaction interface, making ParaStellarSigner directly compatible with contract.Client.

Return Type

The hook returns a UseStellarSignerReturn object with the following properties: