Skip to content

Documentation / @frak-labs/core-sdk / actions / siweAuthenticate

Function: siweAuthenticate()

siweAuthenticate(client, args): Promise<{ message: string; signature: `0x${string}`; }>

Defined in: actions/wrapper/siweAuthenticate.ts:62

Function used to launch a siwe authentication

Parameters

client

FrakClient

The current Frak Client

args

The parameters

metadata?

ModalRpcMetadata

Custom metadata to be passed to the modal

siwe?

Partial<SiweAuthenticationParams>

Partial SIWE params, since we can rebuild them from the SDK if they are empty

If no parameters provider, some fields will be recomputed from the current configuration and environment.

  • statement will be set to a default value
  • nonce will be generated
  • uri will be set to the current domain
  • version will be set to "1"
  • domain will be set to the current window domain
Default
{}

Returns

Promise<{ message: string; signature: `0x${string}`; }>

The SIWE authentication result (message + signature) in a promise

Example

import { siweAuthenticate } from "@frak-labs/core-sdk/actions";
import { parseSiweMessage } from "viem/siwe";
 
const { signature, message } = await siweAuthenticate(frakConfig, {
    siwe: {
        statement: "Sign in to My App",
        domain: "my-app.com",
        expirationTimeTimestamp: Date.now() + 1000 * 60 * 5,
    },
    metadata: {
        header: {
            title: "Sign in",
        },
        context: "Sign in to My App",
    },
});
console.log("Parsed final message:", parseSiweMessage(message));
console.log("Siwe signature:", signature);