SIWE 以太坊登录 Link to heading

  1. 钱包向用户提供结构化的明文消息或等效接口,以便使用 EIP-191 签名方案进行签名(以 \x19Ethereum Signed Message:\n< length of message> 为前缀的字符串)。该 message 必须包含以太坊 address 、请求签名的 domain 、消息 version 、链标识符 chain-id 、用于限定范围的 uri 、服务器可接受的 nonce 以及 issued-at 时间戳。

  2. 然后将签名提交给服务器,服务器检查签名的有效性和消息内容。

  3. 附加字段(包括 expiration-time 、 not-before 、 request-id 、 chain-id 和 resources 可作为会话身份验证的一部分纳入其中。

  4. 服务器可以进一步获取与以太坊地址相关的数据,例如来自以太坊区块链(例如,ENS、账户余额、ERC-20 / ERC-721 / ERC-1155 资产所有权)或其他可能获得或未获得许可的数据源。

待签名消息示例 Link to heading

service.org wants you to sign in with your Ethereum account:
0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2

I accept the ServiceOrg Terms of Service: https://service.org/tos

URI: https://service.org/login
Version: 1
Chain ID: 1
Nonce: 32891756
Issued At: 2021-09-30T16:25:24Z
Resources:
- ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/
- https://example.com/my-web2-claim.json

详细 https://docs.login.xyz/general-information/siwe-overview/eip-4361