Skip to content

stackup-wallet/account-modules

Repository files navigation

Account Modules

A collection of ERC-7579 and smart session modules built by Stackup.

Summary of modules

All modules are deployed using the deterministic deployment proxy and have the same address on all chains.

v1.0.0
Contract Address Type
WebAuthnValidator.sol 0x6140DB7a66a18A7741ED2687409ef471235b4Df0 Stateless validator
SudoPolicy.sol 0x8032214D4082714742Ba137eBfbf05e3a9a5bCfC Policy
IntervalSpendingLimitPolicy.sol 0xAd8508E62BCf4bFBC6b092E5e9e54508c4936555 Policy

Modules

The remaining section will assume knowledge on ERC-4337 (Account Abstraction), ERC-7579 (Minimal Modular Smart Accounts), and Smart Sessions. If you are unfamiliar, we recommend the following resources to get started:

Stateless validators

A minimal wrapper around webauthn-sol to enable compatibility with smart sessions. This allows sessions to be authenticated directly with an end user's passkey.

Policies

A fork of the original SudoPolicy.sol, but with the added support for a IUserOpPolicy.

See here for details on why this is required.

A fork of SpendingLimitPolicy.sol. The difference is the inclusion of two additional features:

  1. Efficiently resetting the accrued spend at defined intervals set during initialization.
    • Daily: on midnight everyday.
    • Weekly: on Monday every week.
    • Monthly: on the first day of every month.
  2. Ability to track both native and ERC20 tokens.

Note that this policy relies on the TIMESTAMP opcode during validation and requires an alternative mempool. This is needed to ensure time intervals work as expected.

Contributing

This project requires Foundry to be installed. If you're developing with VSCode, we also recommend using the Solidity extension by Nomic Foundation.

Install dependencies

Install node_modules:

pnpm install

Install foundry submodules:

forge install

Building modules

All smart contracts live under the src directory.

forge build

Testing modules

All tests live under the test directory.

forge test

Deploying the module

  1. Import your modules into the script/DeployModule.s.sol file.
  2. Create a .env file in the root directory based on the .env.example file and fill in the variables.
  3. Run the following command:
source .env && forge script script/DeployModule.s.sol:DeployModuleScript --rpc-url $DEPLOYMENT_RPC --broadcast --sender $DEPLOYMENT_SENDER --verify

Your module is now deployed to the blockchain and verified on Etherscan.

If the verification fails, you can manually verify it on Etherscan using the following command:

source .env && forge verify-contract --chain-id [YOUR_CHAIN_ID] --watch --etherscan-api-key $ETHERSCAN_API_KEY [YOUR_MODULE_ADDRESS] src/[PATH_TO_MODULE].sol:[MODULE_CONTRACT_NAME]

Generating the module address

This is a read-only script to generate the counterfactual module addresses:

source .env && forge script script/GetModuleAddress.s.sol:GetModuleAddressScript --rpc-url $DEPLOYMENT_RPC

Module registry attestations

This command connects with a local wallet interface in order to submit and revoke module attestations.

Note that you will need to edit the CHAIN and module addresses in script/registry to their correct values.

yarn registry:attest

# If a revoke is necessary...
yarn registry:revoke

License

Distributed under the GPL-3.0 License. See LICENSE for more information.

About

A collection of ERC-7579 and smart session modules built by Stackup.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •