Skip to main content

WalletAuthenticator class

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Wallet Authenticator

Example

// We specify the domain of the application to authenticate to
const domain = "thirdweb.com";

// On the client side, we can generate a payload for the connected wallet to login
const loginPayload = await sdk.auth.login(domain);

// Then on the server side, we can securely verify the connected client-side address
const address = sdk.auth.verify(domain, loginPayload);

// And we can also generate an authentication token to send to the client
const token = sdk.auth.generate(domain, loginPayload);

// Finally, the token can be send from the client to the server to make authenticated requests
// And the server can use the following function to authenticate a token and verify the associated address
const address = sdk.auth.authenticate(domain, token);

Constructors

ConstructorModifiersDescription
(constructor)(network, wallet, options)(BETA) Constructs a new instance of the WalletAuthenticator class

Methods

MethodModifiersDescription
authenticate(domain, token)(BETA) Authenticate With Token
generateAuthToken(domain, payload, options)(BETA) Generate Authentication Token
login(domain, options)(BETA) Login With Connected Wallet
verify(domain, payload, options)(BETA) Verify Logged In Address

Signature:

export declare class WalletAuthenticator extends RPCConnectionHandler

Extends: RPCConnectionHandler

Remarks

The wallet authenticator enables server-side applications to securely identify the connected wallet address of users on the client-side, and also enables users to authenticate to any backend using just their wallet. It implements the JSON Web Token (JWT) authentication standard.