Creating SIWE Messages
This section describes how to generate Sign-In with Ethereum messages and print them to the console.
A completed version of this part can be found in the example repository (00_print
).
Creating SIWE messages in JavaScript is straightforward when using the siwe
library in npm. To begin, create a new project called siwe-print
.
We can then write the following into ./src/index.js
:
Now run the example:
You should see output similar to the following message, with different values for the Nonce and Issued At fields:
To learn about all the available fields in a SiweMessage
, check out the information in EIP-4361
The fields we are most interested in for the purposes of this guide are address
and statement
. address
is the Ethereum address which the user is signing in with, and the statement
as this will describe to the user what action we wish to perform on their behalf.
Often, as in this example, we don't need to do any manipulation of the message, so we can immediately convert it into the textual representation that the user will sign.
Last updated