new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Better Auth · Plugins · all subjects

siwe/installation

3 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

SIWE plugin server installation

To add the SIWE plugin to your auth configuration, import siwe from 'better-auth/plugins' and add it to the plugins array in betterAuth configuration.

SIWE client plugin installation

To add the SIWE client plugin, import siweClient from 'better-auth/client/plugins' and add it to the plugins array in createAuthClient configuration.

SIWE complete implementation example

Here is a complete example implementation of SIWE authentication: ```ts import { betterAuth } from "better-auth"; import { siwe } from "better-auth/plugins"; import { generateRandomString } from "better-auth/crypto"; import { verifyMessage, createPublicClient, http } from "viem"; import { mainnet } from "viem/chains"; export const auth = betterAuth({ database: { // your database configuration }, plugins: [ siwe({ domain: "myapp.com", emailDomainName: "myapp.com", anonymous: false, getNonce: async () => { // Generate a cryptographically secure random nonce return generateRandomString(32, "a-z", "A-Z", "0-9"); }, verifyMessage: async ({ message, signature, address }) => { try { // Verify the signature using viem (recommended) const isValid = await verifyMessage({ address: address as `0x${string}`, message, signature: signature as `0x${string}`, }); return isValid; } catch (error) { console.error("SIWE verification failed:", error); return false; } }, ensLookup: async ({ walletAddress }) => { try { // Optional: lookup ENS name and avatar using viem // You can use viem's ENS utilities here const client = createPublicClient({ chain: mainnet, transport: http(), }); const ensName = await client.getEnsName({ address: walletAddress as `0x${string}`, }); const ensAvatar = ensName ? await client.getEnsAvatar({ name: ensName, }) : null; return { name: ensName || walletAddress, avatar: ensAvatar || "", }; } catch { return { name: walletAddress, avatar: "", }; } }, }), ], }); ``` This example demonstrates: using generateRandomString from better-auth/crypto for nonce generation, using viem's verifyMessage for signature verification, optional ENS lookup implementation using viem's publicClient with mainnet chain configuration.

Give your agent this brain