A user & developer friendly modular smart account implementation on ZKsync; simplifying user authentication, session management, and transaction processing.
Forked from Clave.
Caution
The factory and module interfaces are not yet stable! Any modules created against the IModuleValidator interface will likely need to be updated in the final version. The code is currently under audit and the latest may contain security vulnerabilities.
See the ZKsync SSO project for a complete developer solution, this project is just the smart contract components.
- Install workspace dependencies with
pnpm install. - Install the latest release of Era Test Node.
- Run
pnpm buildto build the contracts. - Run
era_test_node runandpnpm testin separate terminals to run the tests. - Run
pnpm lintto lint the project. - Run
pnpm fmtto format the project.
This module allows for recovering an account with a Guardian, which helps users regain access to their SSO accounts if their primary authentication method (such as a passkey) is lost.
Users can initiate the recovery process to update their passkey authentication, with the Guardian serving as both verifier and facilitator.
A Guardian is a trusted entity designated to assist in recovering access to a smart account by signing to verify the legitimacy of the recovery process.
- Proposing a guardian
TheproposeGuardianmethod handles the initial registration of external accounts by:- Taking an external account address and storing it as a pending guardian.
- Enabling
addGuardianto confirm and activate this guardian.
- Confirming guardian
TheaddGuardianmethod handles the registration of external accounts by:- Verifying that the guardian was previously proposed by the account.
- Marking the guardian as active and ready.
- Recording the guardian-to-account relationship for future recovery and validation.
- Removing guardian
TheremoveGuardianmethod handles guardian removal by:- Accepting the guardian’s address as input.
- Removing the guardian from the account’s list.
- Cleaning up associated metadata (e.g., removing the account from the guardian’s guarded list).
- Initiating recovery
A verified guardian can initiate account recovery using theinitRecoverymethod, which:- Verifies the caller is an active guardian of the account.
- Verifies that account does not have non-expired pending recovery
- Records a recovery request with:
- Hashed credential ID
- Raw public key
- Timestamp
- Executing recovery
Account recovery is completed by submitting a specific transaction validated viavalidateTransaction, which:- Ensures the transaction calls
WebAuthValidator.addValidationKey. - Confirm the credential ID and public key match the recovery request.
- Verifies that 24 hours have passed since initiation and the request is within the 72-hour validity window.
- Ensures the transaction calls
- Cancelling recovery
A pending recovery can be discarded usingdiscardRecovery, which:- Removes the recovery request from storage.
Chain operators can use the deploy script to initially deploy the contracts,
ensuring that the proxy addresses are added to the storage slot exception allow
list. (api_web3_json_rpc: whitelisted_tokens_for_aa)
pnpm run deploy --file chainname.jsonThis list of contracts can be included into the parent SSO-SDK project for
automatic chain support. Then subsquent updates can be made using the upgrade
script, which will use the deployed proxies:
pnpm run upgrade --proxyfile chainname.jsonNon-chain operators should use the deploy script with the no proxy flag to avoid the storage slot validation errors.
pnpm run deploy --file chainname.json --direct