Skip to content

Siwe.createMessage

Creates EIP-4361 formatted message.

Imports

Named
import { Siwe } from 'ox'

Examples

import { Siwe } from 'ox'
 
Siwe.createMessage({
  address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
  chainId: 1,
  domain: 'example.com',
  nonce: 'foobarbaz',
  uri: 'https://example.com/path',
  version: '1',
})
"example.com wants you to sign in with your Ethereum account:
0xA0Cf798816D4b9b9866b5330EEa46a18382f251e
// @log:
URI: https://example.com/path
Version: 1
Chain ID: 1
Nonce: foobarbaz
Issued At: 2023-02-01T00:00:00.000Z"

Definition

function createMessage(
  value: Siwe.Message,
): string

Source: src/core/Siwe.ts

Parameters

value

Values to use when creating EIP-4361 formatted message.

value.address

  • Type: abitype_Address

The Ethereum address performing the signing.

value.chainId

  • Type: number

The EIP-155 Chain ID to which the session is bound,

value.domain

  • Type: string

RFC 3986 authority that is requesting the signing.

value.expirationTime

  • Type: Date
  • Optional

Time when the signed authentication message is no longer valid.

value.issuedAt

  • Type: Date
  • Optional

Time when the message was generated, typically the current time.

value.nonce

  • Type: string

A random string typically chosen by the relying party and used to prevent replay attacks.

value.notBefore

  • Type: Date
  • Optional

Time when the signed authentication message will become valid.

value.requestId

  • Type: string
  • Optional

A system-specific identifier that may be used to uniquely refer to the sign-in request.

value.resources

  • Type: string[]
  • Optional

A list of information or references to information the user wishes to have resolved as part of authentication by the relying party.

value.scheme

  • Type: string
  • Optional

RFC 3986 URI scheme of the origin of the request.

value.statement

  • Type: string
  • Optional

A human-readable ASCII assertion that the user will sign.

value.uri

  • Type: string

RFC 3986 URI referring to the resource that is the subject of the signing (as in the subject of a claim).

value.version

  • Type: "1"

The current version of the SIWE Message.

Return Type

EIP-4361 formatted message.

string