encodeStructuredData
Encodes a structured data message and domain into a SIP-018 encoded hex string. This is the data that gets hashed and signed by signStructuredData.
Usage
import { encodeStructuredData, Cl } from '@stacks/transactions';
const encoded = encodeStructuredData({
message: Cl.tuple({
amount: Cl.uint(1000),
}),
domain: Cl.tuple({
name: Cl.stringAscii('my-app'),
version: Cl.stringAscii('1.0.0'),
'chain-id': Cl.uint(1),
}),
});
// hex string: SIP018 prefix + domain hash + message hashNotes
The result is prefixed with the SIP-018 prefix bytes (
SIP018in ASCII).The domain must be a valid tuple with
name,version, andchain-idkeys.
Signature
Returns
string
A hex-encoded string containing the SIP-018 prefix, domain hash, and message hash.
Parameters
opts.message (required)
Type:
ClarityValue
The structured data message.
opts.domain (required)
Type:
ClarityValue
The domain tuple with name, version, and chain-id keys.
Last updated
Was this helpful?