createSiweMessage
Creates EIP-4361 formatted message.
Import
import { } from 'viem/siwe'Usage
import { } from 'viem/siwe'
const = ({
: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
: 1,
: 'example.com',
: 'foobarbaz',
: 'https://example.com/path',
: '1',
})Returns
string
EIP-4361 formatted message.
Parameters
address
- Type:
Address
The Ethereum address performing the signing.
import { } from 'viem/siwe'
const = ({
: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
: 1,
: 'example.com',
: 'foobarbaz',
: 'https://example.com/path',
: '1',
})chainId
- Type:
number
The EIP-155 Chain ID to which the session is bound.
import { } from 'viem/siwe'
const = ({
: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
: 1,
: 'example.com',
: 'foobarbaz',
: 'https://example.com/path',
: '1',
})domain
- Type:
string
RFC 3986 authority that is requesting the signing.
import { } from 'viem/siwe'
const = ({
: '0xa0cf798816d4b9b9866b5330eea46a18382f251e',
: 1,
: 'example.com',
: 'foobarbaz',
: 'https://example.com/path',
: '1',
})nonce
- Type:
string
A random string typically chosen by the relying party and used to prevent replay attacks.
import { } from 'viem/siwe'
const = ({
: '0xa0cf798816d4b9b9866b5330eea46a18382f251e',
: 1,
: 'example.com',
: 'foobarbaz',
: 'https://example.com/path',
: '1',
})uri
- Type:
string
RFC 3986 URI referring to the resource that is the subject of the signing (as in the subject of a claim).
import { } from 'viem/siwe'
const = ({
: '0xa0cf798816d4b9b9866b5330eea46a18382f251e',
: 1,
: 'example.com',
: 'foobarbaz',
: 'https://example.com/path',
: '1',
})version
- Type:
'1'
The current version of the SIWE Message.
import { } from 'viem/siwe'
const = ({
: '0xa0cf798816d4b9b9866b5330eea46a18382f251e',
: 1,
: 'example.com',
: 'foobarbaz',
: 'https://example.com/path',
: '1',
})expirationTime (optional)
- Type:
Date
Time when the signed authentication message is no longer valid.
import { } from 'viem/siwe'
const = ({
: '0xa0cf798816d4b9b9866b5330eea46a18382f251e',
: 1,
: 'example.com',
: 'foobarbaz',
: 'https://example.com/path',
: '1',
: new (),
})issuedAt (optional)
- Type:
Date
Time when the message was generated, typically the current time.
import { } from 'viem/siwe'
const = ({
: '0xa0cf798816d4b9b9866b5330eea46a18382f251e',
: 1,
: 'example.com',
: 'foobarbaz',
: 'https://example.com/path',
: '1',
: new (),
})notBefore (optional)
- Type:
Date
Time when the signed authentication message will become valid.
import { } from 'viem/siwe'
const = ({
: '0xa0cf798816d4b9b9866b5330eea46a18382f251e',
: 1,
: 'example.com',
: 'foobarbaz',
: 'https://example.com/path',
: '1',
: new (),
})requestId (optional)
- Type:
string
A system-specific identifier that may be used to uniquely refer to the sign-in request.
import { } from 'viem/siwe'
const = ({
: '0xa0cf798816d4b9b9866b5330eea46a18382f251e',
: 1,
: 'example.com',
: 'foobarbaz',
: 'https://example.com/path',
: '1',
: '123e4567-e89b-12d3-a456-426614174000',
})resources (optional)
- Type:
string[]
A list of information or references to information the user wishes to have resolved as part of authentication by the relying party.
import { } from 'viem/siwe'
const = ({
: '0xa0cf798816d4b9b9866b5330eea46a18382f251e',
: 1,
: 'example.com',
: 'foobarbaz',
: 'https://example.com/path',
: '1',
: [
'https://example.com/foo',
'https://example.com/bar',
'https://example.com/baz',
],
})scheme (optional)
- Type:
string
RFC 3986 URI scheme of the origin of the request.
import { } from 'viem/siwe'
const = ({
: '0xa0cf798816d4b9b9866b5330eea46a18382f251e',
: 1,
: 'example.com',
: 'foobarbaz',
: 'https://example.com/path',
: '1',
: 'https',
})statement (optional)
- Type:
string
A human-readable ASCII assertion that the user will sign.
import { } from 'viem/siwe'
const = ({
: '0xa0cf798816d4b9b9866b5330eea46a18382f251e',
: 1,
: 'example.com',
: 'foobarbaz',
: 'https://example.com/path',
: '1',
: 'I accept the ExampleOrg Terms of Service: https://example.com/tos',
})