For the complete documentation index, see llms.txt. This page is also available as Markdown.

mega.signMessage()

Sign an arbitrary text payload (EIP-191) — for auth challenges, attestations, or action confirmation. The user sees the message in the wallet UI before signing. User rejection resolves with status: 'cancelled', not a thrown error.

Use this when you control the message and want the raw signature back to verify yourself. If you just want login and would rather MOSS own the challenge and hand you a verifiable JWT, use authenticate() instead. For structured (EIP-712) typed data, use signData().

Signature

mega.signMessage(message: string): Promise<SignMessageResponse>

Parameters

Field
Type
Required
Notes

message

string

required

The string the user signs. Shown verbatim in the wallet UI.

Example

const signed = await mega.signMessage('Sign in to MOSS');

if (signed.status === 'success') {
  console.log(signed.signature);
} else if (signed.status === 'cancelled') {
  console.log('User cancelled message signing');
} else {
  console.error(signed.error);
}

Response

Notes

  • Don't auto-trigger signing after page load. Always follow a user action with context on why.

  • Verify the signature server-side before issuing app sessions — see Server Verify.

  • If the wallet is disconnected, call connect() first.

Last updated