- Multi-Operation
- Fee Bump
- Sign XDR
- Change Trust
- Soroban Auth
Combine multiple operations into a single atomic transaction:
import { useParaStellar } from "./hooks/useParaStellar";
import { TransactionBuilder, Operation, Asset, BASE_FEE, Networks } from "@stellar/stellar-sdk";
function MultiOpTransaction() {
const { server, signer } = useParaStellar();
const execute = async () => {
if (!signer) return;
const sourceAccount = await server.loadAccount(signer.address);
const transaction = new TransactionBuilder(sourceAccount, {
fee: BASE_FEE,
networkPassphrase: Networks.PUBLIC,
})
.addOperation(
Operation.payment({
destination: "GRECIPI...",
asset: Asset.native(),
amount: "10",
})
)
.addOperation(
Operation.manageData({
name: "memo",
value: "payment-ref-123",
})
)
.setTimeout(180)
.build();
const { signedTxXdr } = await signer.signTransaction(transaction.toXDR());
const tx = TransactionBuilder.fromXDR(signedTxXdr, Networks.PUBLIC);
const result = await server.submitTransaction(tx);
console.log("Transaction hash:", result.hash);
};
return <button onClick={execute}>Execute Multi-Op</button>;
}
Wrap an existing transaction with a higher fee to prioritize it during network congestion:
import { useParaStellar } from "./hooks/useParaStellar";
import { TransactionBuilder, Operation, Asset, Networks } from "@stellar/stellar-sdk";
function FeeBumpTransaction() {
const { server, signer } = useParaStellar();
const execute = async () => {
if (!signer) return;
const sourceAccount = await server.loadAccount(signer.address);
// Build the inner transaction with a low base fee
const innerTx = new TransactionBuilder(sourceAccount, {
fee: "100",
networkPassphrase: Networks.PUBLIC,
})
.addOperation(
Operation.payment({
destination: "GRECIPI...",
asset: Asset.native(),
amount: "10",
})
)
.setTimeout(180)
.build();
// Sign the inner transaction
const { signedTxXdr: signedInnerXdr } = await signer.signTransaction(innerTx.toXDR());
const signedInner = TransactionBuilder.fromXDR(signedInnerXdr, Networks.PUBLIC);
// Wrap with a fee bump
const feeBumpTx = TransactionBuilder.buildFeeBumpTransaction(
signer.address,
"500", // higher fee
signedInner,
Networks.PUBLIC
);
// Sign the fee bump transaction
const { signedTxXdr } = await signer.signTransaction(feeBumpTx.toXDR());
const tx = TransactionBuilder.fromXDR(signedTxXdr, Networks.PUBLIC);
const result = await server.submitTransaction(tx);
console.log("Fee bump transaction hash:", result.hash);
};
return <button onClick={execute}>Submit Fee Bump</button>;
}
Sign a pre-built transaction provided as an XDR string (e.g., from a server or dApp):
import { ParaStellarSigner } from "@getpara/stellar-sdk-v14-integration";
import { TransactionBuilder, Networks, Horizon } from "@stellar/stellar-sdk";
import { useClient } from "@getpara/react-sdk";
function SignXDR() {
const para = useClient();
const signAndSubmit = async (xdrString: string) => {
if (!para) return;
const signer = new ParaStellarSigner(para, Networks.PUBLIC);
// Sign the XDR directly
const signedXdr = await signer.signTransactionXDR(
xdrString,
Networks.PUBLIC
);
// Submit to the network
const server = new Horizon.Server("https://horizon.stellar.org");
const tx = TransactionBuilder.fromXDR(signedXdr, Networks.PUBLIC);
const result = await server.submitTransaction(tx);
console.log("Transaction hash:", result.hash);
};
return <button onClick={() => signAndSubmit("AAAA...")}>Sign XDR</button>;
}
Create a trustline to hold a custom asset (required before receiving non-XLM tokens):
import { useParaStellar } from "./hooks/useParaStellar";
import { TransactionBuilder, Operation, Asset, BASE_FEE, Networks } from "@stellar/stellar-sdk";
function ChangeTrust() {
const { server, signer } = useParaStellar();
const addTrustline = async (assetCode: string, issuer: string) => {
if (!signer) return;
const sourceAccount = await server.loadAccount(signer.address);
const asset = new Asset(assetCode, issuer);
const transaction = new TransactionBuilder(sourceAccount, {
fee: BASE_FEE,
networkPassphrase: Networks.PUBLIC,
})
.addOperation(Operation.changeTrust({ asset }))
.setTimeout(180)
.build();
const { signedTxXdr } = await signer.signTransaction(transaction.toXDR());
const tx = TransactionBuilder.fromXDR(signedTxXdr, Networks.PUBLIC);
const result = await server.submitTransaction(tx);
console.log("Trustline added:", result.hash);
};
return (
<button
onClick={() =>
addTrustline(
"USDC",
"GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN"
)
}
>
Add USDC Trustline
</button>
);
}
Sign authorization entries for Soroban smart contract interactions:
import { useStellarSigner } from "@getpara/react-sdk/stellar";
import { Networks } from "@stellar/stellar-sdk";
function SorobanAuth() {
const { stellarSigner } = useStellarSigner({
networkPassphrase: Networks.PUBLIC,
});
const signAuth = async (authEntryXdr: string) => {
if (!stellarSigner) return;
// Sign the authorization entry
const { signedAuthEntry, signerAddress } =
await stellarSigner.signAuthEntry(authEntryXdr);
console.log("Signed auth entry:", signedAuthEntry);
console.log("Signer:", signerAddress);
return signedAuthEntry;
};
return (
<button onClick={() => signAuth("AAAA...")}>
Authorize Contract Call
</button>
);
}
The
signAuthEntry method is compatible with Stellar SDK’s contract.Client, allowing Para wallets to authorize Soroban smart contract invocations. The auth entry XDR is typically provided by the contract client during simulation.