Sign Transaction
Sign Solana transactions without broadcasting them to the network. This is useful for advanced use cases like off-chain transaction batching, meta-transactions, or custom transaction submission workflows.Overview
Signing transactions without sending allows you to:- Batch transactions: Collect multiple signed transactions before submitting
- Off-chain processing: Sign now, broadcast later
- Custom submission: Use custom RPC logic or transaction relayers
- Transaction inspection: Review signed transaction data before broadcasting
Unlike
sendTransaction which signs and broadcasts immediately, signTransaction only signs the transaction and returns it for you to broadcast separately.Signing vs Sending
React SDK
- Basic Usage
- With UI Customization
- With Callbacks
To sign a transaction, use the
signTransaction method from the useSignTransaction hook:Parameters
Transaction | VersionedTransaction
required
The Solana transaction to sign. Can be either a legacy
Transaction or VersionedTransaction from @solana/web3.js.Example:Options Object
The second parameter is an optional configuration object:object
Configuration for the signing confirmation modal.
Hook Callbacks
(result: { signedTransaction: Uint8Array }) => void
Callback executed after successful signing. Receives the signed transaction as Uint8Array.
(error: Error) => void
Callback executed if signing fails or user cancels.
Returns
Uint8Array
The signed transaction as a Uint8Array. This can be serialized and broadcast to the network.
Complete Examples
Sign and Broadcast Later
Batch Transaction Signing
Broadcasting Signed Transactions
After signing a transaction, you can broadcast it using Solana’s connection:With Custom Commitment
Transaction Serialization
Serialize to Base64
Deserialize from Base64
UI Customization
Customize the signing modal:Hide Modal
Best Practices
Use fresh blockhashes
Use fresh blockhashes
Always fetch a recent blockhash before signing:
Set fee payer
Set fee payer
Always specify the fee payer:
Store signed transactions securely
Store signed transactions securely
If storing signed transactions, use secure storage:
Handle expiration
Handle expiration
Signed transactions can expire if blockhash is old:
Validate before signing
Validate before signing
Check transaction validity before signing:
Confirm after broadcasting
Confirm after broadcasting
Always wait for confirmation after broadcasting:
Troubleshooting
Blockhash expired error
Blockhash expired error
Signed transactions expire if blockhash is too old:
Signature verification failed
Signature verification failed
Ensure transaction is properly constructed:
Cannot deserialize signed transaction
Cannot deserialize signed transaction
Use proper serialization/deserialization:
User cancelled signing
User cancelled signing
Handle cancellations gracefully:
Related Documentation
Send Transaction
Sign and broadcast transactions
Sign Message
Sign messages with Solana wallet
Solana Web3.js
Official Solana JavaScript library
Transaction Format
Solana transaction structure
Next Steps
- Learn about sending transactions
- Understand Solana’s transaction lifecycle
- Explore transaction confirmation strategies
- Implement transaction retry logic for reliability