Skip to content

Siwe.parseMessage

EIP-4361 formatted message into message fields object.

The message can be the prefix (up to the statement), the suffix (from URI), or both. Returns an empty object when the message has any other text, such as fields that are out of order or text after the last field.

Imports

Named
import { Siwe } from 'ox'

Examples

import { Siwe } from 'ox'
 
Siwe.parseMessage(`example.com wants you to sign in with your Ethereum account:
0xA0Cf798816D4b9b9866b5330EEa46a18382f251e
 
I accept the ExampleOrg Terms of Service: https://example.com/tos
 
URI: https://example.com/path
Version: 1
Chain ID: 1
Nonce: foobarbaz
Issued At: 2023-02-01T00:00:00.000Z`)
{
address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
chainId: 1,
domain: 'example.com',
issuedAt: '2023-02-01T00:00:00.000Z',
nonce: 'foobarbaz',
statement: 'I accept the ExampleOrg Terms of Service: https://example.com/tos',
uri: 'https://example.com/path',
version: '1',
}

Definition

function parseMessage(
  message: string,
): ExactPartial<Message>

Source: src/core/Siwe.ts

Parameters

message

  • Type: string

EIP-4361 formatted message.

Return Type

Message fields object.

ExactPartial<Message>