You’re viewing the 2.0 (LTS) docs. View the current 3.0 version of this page.
useSignTransaction hook provides functionality to sign blockchain transactions with the user’s wallet.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Hook for signing blockchain transactions
useSignTransaction hook provides functionality to sign blockchain transactions with the user’s wallet.
import { useSignTransaction } from "@getpara/react-sdk";
function TransactionSigner() {
const { signTransactionAsync, isPending, error } = useSignTransaction();
const handleSignTransaction = async () => {
try {
const tx = {
to: "0x742d35Cc6634C0532925a3b844Bc9e7595f6E123",
value: "0x2386f26fc10000", // 0.01 ETH in wei
gasLimit: "0x5208", // 21000
gasPrice: "0x09184e72a000", // 10000000000000
};
const rlpEncoded = encodeTransaction(tx); // Your encoding logic
const result = await signTransactionAsync({
rlpEncodedTxBase64: Buffer.from(rlpEncoded).toString("base64"),
});
if ("signature" in result) {
console.log("Transaction signed:", result.signature);
}
} catch (err) {
console.error("Failed to sign transaction:", err);
}
};
return (
<button
onClick={handleSignTransaction}
disabled={isPending}
>
{isPending ? "Signing..." : "Sign Transaction"}
</button>
);
}