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:
- 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. - 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.
- React
- Javascript
- Python
- Go
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);
// 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);
# Add the domain of the application that you want to log in to
domain = "thirdweb.com"
# Generate a signed login payload for the connected wallet to authenticate with
payload = sdk.auth.login(domain)
// Add the domain of the application that you want to log in to
domain := "thirdweb.com"
// Generate a signed login payload for the connected wallet to authenticate with
payload, err := sdk.Auth.Login(domain, nil)
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.
- React
- Javascript
- Python
- Go
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);
const domain = "thirdweb.com";
const loginPayload = await sdk.auth.login(domain);
// Verify the login request
const address = sdk.auth.verify(domain, loginPayload);
domain = "thirdweb.com"
payload = sdk.auth.login(domain)
# Verify the login request
address = sdk.auth.verify(domain, payload)
domain := "thirdweb.com"
payload, err := sdk.Auth.Login(domain, nil)
// Verify the login request
address, err := sdk.Auth.Verify(domain, payload, nil)