|
| 1 | +# Account Modules |
| 2 | + |
| 3 | +ERC-7579 compliant executor modules for smart account automation in the x402 payments system. |
| 4 | + |
| 5 | +## Modules |
| 6 | + |
| 7 | +### AutoTopUpModule |
| 8 | + |
| 9 | +- Automatically tops up agent accounts when balance falls below threshold |
| 10 | +- Configurable per-agent limits (daily, monthly) |
| 11 | +- Permissionless triggering with proper checks |
| 12 | +- Used by: Main accounts to fund agent accounts |
| 13 | + |
| 14 | +### AutoCollectModule |
| 15 | + |
| 16 | +- Automatically collects payments from service accounts |
| 17 | +- Configurable collection thresholds (amount and time) |
| 18 | +- Batch collection optimization |
| 19 | +- Used by: Service accounts to collect to main accounts |
| 20 | + |
| 21 | +## Architecture |
| 22 | + |
| 23 | +All modules implement the ERC-7579 executor module interface: |
| 24 | + |
| 25 | +- `onInstall(bytes calldata data)` - Module installation |
| 26 | +- `onUninstall(bytes calldata data)` - Module removal |
| 27 | +- `isModuleType(uint256 typeID)` - Returns true for executor type (0x01) |
| 28 | +- `isInitialized(address account)` - Check if module is initialized for account |
| 29 | + |
| 30 | +## Deployment |
| 31 | + |
| 32 | +The modules are deployed as immutable singletons using Safe's Singleton Factory, ensuring the same addresses across all |
| 33 | +chains: |
| 34 | + |
| 35 | +- **AutoTopUpExecutor**: `0x16f13052FbFFfcE34E5752b7F4CFF881a030F40B` |
| 36 | +- **AutoCollectExecutor**: `0x29864bd91370886c38dE9Fe95F5589E7EbE15130` |
| 37 | + |
| 38 | +These addresses are deterministic and will remain consistent on all supported chains (Base, Base Sepolia, etc.). |
| 39 | + |
| 40 | +## Development |
| 41 | + |
| 42 | +### Prerequisites |
| 43 | + |
| 44 | +- [Foundry](https://book.getfoundry.sh/getting-started/installation) |
| 45 | +- [pnpm](https://pnpm.io/installation) (for ModuleKit dependencies) |
| 46 | + |
| 47 | +### Setup |
| 48 | + |
| 49 | +```bash |
| 50 | +# Install Forge dependencies |
| 51 | +forge install |
| 52 | + |
| 53 | +# Install ModuleKit node dependencies (required for compilation) |
| 54 | +cd lib/modulekit && npm install && cd ../.. |
| 55 | + |
| 56 | +# Build contracts |
| 57 | +forge build |
| 58 | + |
| 59 | +# Run tests |
| 60 | +forge test |
| 61 | + |
| 62 | +# Deploy |
| 63 | +forge script script/Deploy.s.sol --rpc-url $RPC_URL --broadcast |
| 64 | +``` |
| 65 | + |
| 66 | +**Important**: ModuleKit requires its node modules to be installed for proper compilation. This step (`pnpm install` in |
| 67 | +the modulekit directory) must be performed after cloning the repository and before building. |
| 68 | + |
| 69 | +## Security |
| 70 | + |
| 71 | +- Non-custodial design - modules only execute based on user-defined rules |
| 72 | +- Access control via ERC-7579 standards |
| 73 | +- Immutable singleton contracts - no upgradeability, no owner |
| 74 | +- Comprehensive event logging |
0 commit comments