Authentication
Request Signing
Testnet 122606
Section
Authentication
Documentation category
Type
Guide
Technical reference
Summary
EIP-712 structured data signing and personal sign for wallet-based authentication.
Article Content
Authentication Headers
All authenticated requests to the SWSS Chain API must include the X-SWSS-API-Key header:
X-SWSS-API-Key: swss_pk_test_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Content-Type: application/json
EIP-712 Typed Data Signing
For on-chain operations requiring wallet signatures, SWSS Chain supports EIP-712 structured data signing.
Domain separator:
{
"name": "SWSS Chain",
"version": "1",
"chainId": 122606,
"verifyingContract": "0x0000000000000000000000000000000000000000"
}
Example with ethers.js:
import { ethers } from 'ethers'
const domain = {
name: 'SWSS Chain',
version: '1',
chainId: 122606,
verifyingContract: '0x0000000000000000000000000000000000000000',
}
const types = {
Message: [
{ name: 'sender', type: 'address' },
{ name: 'content', type: 'string' },
{ name: 'nonce', type: 'uint256' },
],
}
const value = {
sender: wallet.address,
content: 'Hello SWSS',
nonce: 1n,
}
const signature = await wallet.signTypedData(domain, types, value)
Personal Sign
For simpler message signing:
const message = 'Authenticate with SWSS DevHub'
const signature = await wallet.signMessage(message)
Recover the signer with ethers.verifyMessage(message, signature).
