Skip to main content
The Sign Message screen is displayed when your application requests a wallet signature for an arbitrary message. This screen shows users the message content and allows them to approve or reject the signature request.
Message signing is commonly used for authentication, proving wallet ownership, or authorizing actions without sending a blockchain transaction.

How it works

When your application requests a message signature:
  1. Your app calls the sign message method from the MoonKey SDK
  2. The Sign Message screen appears, displaying the message content
  3. User reviews the message details
  4. User approves or rejects the signature request
  5. If approved, the signed message is returned to your application

Triggering the Sign Message screen

Use the useSignMessage hook from the MoonKey SDK to trigger the Sign Message screen:

Customizing the Sign Message screen

You can customize the Sign Message screen by passing UI options in the options.uiOptions object when calling signMessage:

Configuration options

Basic UI Options

string
Custom title text displayed at the top of the Sign Message screen.Example:
string
Custom description text displayed below the title, providing context for the signature request.Example:
string
Custom text for the confirmation button.Default: 'Sign'Example:
boolean
Whether to show wallet information (address, balance) in the Sign Message screen.Default: trueExample:

Solana-specific Options

TransactionCommitment
The commitment level to use for Solana transactions.Available values: 'processed', 'confirmed', 'finalized'Example:
TransactionEncoding
The encoding format for the Solana transaction.Available values: 'base58', 'base64'Example:

Common use cases

Authentication verification

Prove wallet ownership for authentication:

Third-party service login

Sign in to external services with wallet signature:

Action authorization

Authorize specific actions without gas fees:

Terms and conditions acceptance

Cryptographically sign terms acceptance:

Complete example

Here’s a complete example with custom UI configuration:

User experience flow

1

Trigger signature request

Your application calls signMessage() with a message, wallet, and optional UI options.
2

Sign Message screen appears

The customized Sign Message screen is displayed to the user.
3

Review message

User reviews the message content, title, and description.
4

Approve or reject

User clicks the confirm button to sign, or cancels/closes the modal to reject.
5

Signature created

If approved, MoonKey signs the message with the user’s wallet private key.
6

Return to application

The signature is returned to your application as an object containing the signature string (Ethereum) or Uint8Array (Solana).

Message signing vs. transaction signing

It’s important to understand the difference:
  • Signs arbitrary text or data
  • Does not cost gas fees
  • Does not modify blockchain state
  • Used for authentication, verification, or authorization
  • Instant and free
  • Example: “Sign this message to log in”
  • Signs blockchain transactions
  • Costs gas fees (requires native currency)
  • Modifies blockchain state (transfers tokens, calls contracts, etc.)
  • Used for actual blockchain operations
  • Requires network confirmation
  • Example: “Sign this transaction to send 1 ETH”

Best practices

Always include a clear description explaining why the user needs to sign:
Prevent replay attacks by including unique data:
Make it clear what the user is signing:
Users may decline to sign. Always handle errors:
Use showWalletUI: true when wallet context is important:
Set to false for a cleaner UI when wallet details aren’t relevant.
Users are more likely to read and understand shorter messages:
  • Use clear, simple language
  • Break long messages into lines with \n
  • Highlight important information
Always verify the user has a wallet before attempting to sign:

Global appearance settings

The Sign Message screen also respects global appearance settings from MoonKeyProvider:
Learn more about configuring appearance.

Security considerations

Never sign messages without reviewing their content. Malicious applications could trick users into signing messages that authorize unwanted actions.
For developers:
  1. Verify signatures server-side - Always validate signatures on your backend before trusting them
  2. Use nonces - Include unique identifiers to prevent replay attacks
  3. Include context - Clearly state what the signature authorizes
  4. Set expiration - Include timestamps and reject old signatures
  5. Validate message format - Ensure the signed message matches your expected format
For users: The Sign Message screen helps users by:
  • Displaying the full message content
  • Showing their wallet address
  • Providing clear context via title and description
  • Allowing them to reject the request

Verifying signatures

After obtaining a signature, you typically want to verify it on your backend:

Next steps

Sign Transaction

Sign blockchain transactions

Send Transaction

Send transactions with UI

UI Components Overview

Explore all UI components

Configure Appearance

Global appearance settings