buildMessage()
buildMessage(
fields):string
Defined in: buildMessage.ts:38
Formats CAIP-122 message fields into the plain-text message that the wallet signs (the EIP-4361 layout used by CAIP-122). Optional fields are omitted when empty.
Pure function. It only checks that the message can be built: every required field is a non-empty string and no field contains a line break (which would add or change lines of the signed message). It does not check formats or timing: run validateMessage for that, as verifiers do.
Parameters
fields
The message fields to format.
Returns
string
The message lines joined with \n, ready to be signed and parseable by parseMessage.
Throws
SiwxValidationError When a required field is missing or empty, or a field contains a line break.
Example
const message = buildMessage({
domain: 'app.tuwa.io',
address: 'eip155:1:0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B',
uri: 'https://app.tuwa.io',
version: '1',
chainId: 'eip155:1',
nonce: 'abc123xyz',
issuedAt: new Date().toISOString(),
statement: 'Sign in to TUWA.',
});Last updated on