stx_signMessage

Requests the connected wallet to sign a plaintext message with the user's Stacks private key.


Usage

import { request } from '@stacks/connect';

const result = await request('stx_signMessage', {
  message: 'Hello, Stacks!',
});

console.log('Signature:', result.signature);
console.log('Public Key:', result.publicKey);

Notes

  • The wallet displays the message to the user for review before signing.

  • The resulting signature can be verified using the returned publicKey.

  • For signing structured data (SIP-018 compliant), use stx_signStructuredMessage instead.

Reference Linkarrow-up-right


Signature


Returns

SignMessageResult

Property
Type
Description

signature

string

The hex-encoded DER signature.

publicKey

string

The hex-encoded public key used for signing.


Parameters

message (required)

  • Type: string

The plaintext message string to sign.

publicKey (optional, experimental)

  • Type: string

A non-standard parameter to specify which public key to use for signing. Its usage is not recommended as it may not be supported by all wallets. This parameter may be removed in future versions.

Last updated

Was this helpful?