Skip to main content

Sign In With Web3

You can use the authentication SDK to verify the address of a client-side user on the backend.

The process involves two key steps:

  1. The client-side user uses the login function to generate a login payload where they sign a login request message compliant with the Sign-in with Ethereum (EIP-4361) standard. They can then send this payload to the backend.
  2. The server-side uses the verify function to securely verify the wallet address of the client-side user.

Making a Login Request

This function allows the connected client-side user to sign an EIP-4361 compliant message and generate a payload that can be sent to the backend.

const sdk = useSDK();

// Add the domain of the application users will login to, this will be used throughout the login process
const domain = "thirdweb.com";
// Generate a signed login payload for the connected wallet to authenticate with
const loginPayload = await sdk.auth.login(domain);

Verifying the User Address

Then on the server-side, you can use the payload generated with the login method to extract the users' wallet address.

const sdk = useSDK();

const domain = "thirdweb.com";
const loginPayload = await sdk.auth.login(domain);

// Verify the login request
const address = sdk.auth.verify(domain, loginPayload);