Transaction signing creates a signed transaction that can be broadcast to the blockchain. This is different from Send Transaction, which both signs and broadcasts the transaction automatically.
How it works
When your application requests a transaction signature:- Your app calls the sign transaction method from the MoonKey SDK
- The Sign Transaction screen appears, displaying transaction details
- User reviews the transaction information (recipient, amount, gas, etc.)
- User approves or rejects the signature request
- If approved, the signed transaction is returned to your application
- Your application can then broadcast the signed transaction to the blockchain
Triggering the Sign Transaction screen
Use theuseSignTransaction hook from the MoonKey SDK to trigger the Sign Transaction screen:
- Ethereum
- Solana
Customizing the Sign Transaction screen
You can customize the Sign Transaction screen by passing UI options in theoptions.uiOptions object:
Configuration options
Basic UI Options
string
Custom title text displayed at the top of the Sign Transaction screen.Example:
string
Custom description text displayed below the title, providing context for the transaction.Example:
string
Custom text for the confirmation button.Default:
'Sign'Example:boolean
Whether to show wallet information (address, balance) in the Sign Transaction screen.Default:
trueExample:Success Screen Options
string
Header text displayed on the success screen after the transaction is signed.Example:
string
Description text displayed on the success screen after the transaction is signed.Example:
Behavior Options
boolean
Whether the user can cancel the transaction signing request.Default:
trueExample:TransactionUIOptions
Custom options for displaying transaction information in the UI.This allows you to customize how transaction details are presented to the user.Example:
Common use cases
Token transfer transaction
Sign a transaction to transfer ERC-20 tokens:Smart contract interaction
Sign a transaction to interact with a smart contract:NFT minting transaction
Sign a transaction to mint an NFT:Batch signing multiple transactions
Sign multiple transactions in sequence:Complete example
Here’s a complete example with full transaction signing flow:User experience flow
1
Trigger transaction signing
Your application calls
signTransaction() with transaction data, wallet, and optional UI options.2
Sign Transaction screen appears
The customized Sign Transaction screen is displayed with transaction details.
3
Review transaction details
User reviews the transaction information including recipient, amount, gas fees, and any contract interactions.
4
Approve or reject
User clicks the confirm button to sign, or cancels (if
isCancellable: true) to reject.5
Transaction signed
If approved, MoonKey signs the transaction with the user’s wallet private key.
6
Success screen
The success screen appears with the configured
successHeader and successDescription.7
Return signed transaction
The signed transaction is returned to your application for broadcasting.
Sign Transaction vs. Send Transaction
Understanding the difference between these two operations:Sign Transaction (this screen)
Sign Transaction (this screen)
- Only signs the transaction
- Does not broadcast to the blockchain
- Returns a signed transaction that you must broadcast manually
- Useful when you need control over broadcasting timing
- Can sign transactions offline
- Good for batch operations or complex flows
- Example: Sign now, broadcast later when conditions are met
Send Transaction
Send Transaction
- Signs and broadcasts in one step
- Automatically submits the transaction to the blockchain
- Returns the transaction hash after broadcasting
- Simpler for basic send operations
- Requires active network connection
- Best for immediate transactions
- Example: Send ETH/tokens directly to a recipient
Broadcasting signed transactions
After signing a transaction, you need to broadcast it to the blockchain:- Ethereum
- Solana
Best practices
Provide clear transaction context
Provide clear transaction context
Always explain what the transaction does in the
description:Show wallet UI for transactions
Show wallet UI for transactions
Enable
showWalletUI so users can verify they have sufficient balance:Use descriptive success messages
Use descriptive success messages
Inform users about next steps after signing:
Handle errors gracefully
Handle errors gracefully
Users may reject transactions or encounter errors:
Validate before signing
Validate before signing
Check transaction validity before prompting the user:
Allow cancellation for non-critical transactions
Allow cancellation for non-critical transactions
Set Only set
isCancellable: true for most transactions:isCancellable: false for critical flows where cancellation would break your app state.Store and verify transaction data
Store and verify transaction data
Before broadcasting, verify the signed transaction matches your intent:
Security considerations
For developers:- Display full transaction details - Show recipient, amount, gas fees, and any contract interactions
- Validate transaction data - Verify the transaction is well-formed before requesting signature
- Check balances - Ensure users have sufficient funds before signing
- Rate limit signing - Prevent abuse by limiting how many transactions can be signed
- Log signed transactions - Keep records for debugging and user support
- Use secure RPC endpoints - Broadcast to trusted nodes only
- Displaying transaction details (recipient, amount, gas)
- Showing their wallet balance
- Providing clear context via title and description
- Allowing them to cancel if
isCancellableis true - Showing success confirmation before closing
Next steps
Send Transaction
Sign and send transactions in one step
Sign Message
Sign messages for authentication
UI Components Overview
Explore all UI components
Configure Appearance
Global appearance settings