🔴stx_signStructuredMessage
You can request your user to sign a message with structured data, using their wallet's Stacks address, by invoking the stx_signStructuredMessage
method.
The structured data implementation makes the message easier to read and allows you facilitates the interaction with ClarityValue in your application. It follows the SIP-018 Signed Structured Data specification, a standard way to represent information in human-readable format in applications and smart contracts in order to produce signatures that are straightforward and inexpensive to verify. For developers familiar with Ethereum, this design is similar to EIP-712.
Request parameters | Description |
---|---|
| |
|
To convert Clarity values to their hex representation, you can use the { cvToHex, stringAsciiCV, tupleCV, uintCV } helpers from @stacks/transactions
package.
The user will see a Stacks structured message signing request prompt in the wallet.
The stx_signStructuredMessage
method returns a Promise that resolves if the user approves the request. The message is then hashed using sha256 before being signed with secp256k1, and the method returns the SignStxStructuredMessageResult
object:
Property | Description |
---|---|
| a string representing the signed message |
| a string representing the public key of the address used for signing, as a hex-encoded string |
Last updated