Skip to content

parseSiweMessage

Parses EIP-4361 formatted message into message fields object.

Import

import { parseSiweMessage } from 'viem/siwe'

Usage

import { parseSiweMessage } from 'viem/siwe'
 
const message = `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`
const fields = parseSiweMessage(message)
fields.
address?: `0x${string}` | undefined

The Ethereum address performing the signing.

address

Returns

SiweMessage

EIP-4361 fields object

Parameters

message

  • Type: string

EIP-4361 formatted message