Creating Custodial Wallets with JWT
If your app uses JWTs for authentication, you can use ZeroDev to seamlessly create a smart wallet for each user. Follow these steps:
- Visit the Dashboard.
- Click on the
Auth0 / JWT
tab in the lower left corner. - Enter your JWKS credentials in the
JWT Wallet
section and clickSave
.
JWKS stands for JSON Web Key Set. It is a standard for representing a set of cryptographic keys, specifically public keys, in a JSON format. These public keys are used to verify the signatures of JWTs in various security and identity protocols, such as OAuth 2.0 and OpenID Connect. If you are unsure how to retrieve your JWKS endpoint, join our Discord and ask.
Currently, integrating with JWTs involves some manual setup on our side. Upon saving your JWKS credentials, we will set up the integration within 24 business hours and email you to confirm. If in doubt, you can get in touch with us on Discord or email support@zerodev.app.
Wagmi
import { JWTWalletConnector } from '@zerodev/wagmi'
const jwtConnector = new JWTWalletConnector({options: {
projectId: '<your-project-id>',
jwt: "<your user's JWT token>"
}})
Example:
For each connection, we assign a new userID, which in turn creates a new wallet or address. In a real-life scenario, the userID would remain constant, ensuring that the wallet and address also remain constant.
Full Code (Editable)
Ethers
import { ZeroDevWeb3Auth } from '@zerodev/web3auth'
let ecdsaProvider: ECDSAProvider
const instance = new ZeroDevWeb3Auth([defaultProjectId])
instance.initialize({onConnect: async () => {
ecdsaProvider = await ECDSAProvider.init({
projectId: defaultProjectId,
owner: getRPCProviderOwner(provider),
});
}}, 'jwt')
instance.login('jwt', {jwt: '<your-jwt>'})
Example:
For each connection, we assign a new userID, which in turn creates a new wallet or address. In a real-life scenario, the userID would remain constant, ensuring that the wallet and address also remain constant.