Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/account-modules-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Account Modules CI

on:
pull_request:
paths:
- 'solidity/account-modules/**'
- '.github/workflows/account-modules-ci.yml'
workflow_dispatch:

env:
FOUNDRY_PROFILE: ci

jobs:
check:
name: Account Modules Foundry project
runs-on: ubuntu-latest
defaults:
run:
working-directory: solidity/account-modules
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Show Forge version
run: |
forge --version

- name: Install Node dependencies
run: |
cd lib/modulekit && npm install

- name: Run Forge fmt
run: |
forge fmt --check
id: fmt

- name: Run Forge build
run: |
forge build --sizes src/
id: build

- name: Run Forge tests
run: |
ACCOUNT_TYPE=SAFE forge test -vvv
id: test
15 changes: 15 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[submodule "solidity/account-modules/lib/forge-std"]
path = solidity/account-modules/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "solidity/account-modules/lib/modulekit"]
path = solidity/account-modules/lib/modulekit
url = https://github.com/pcarranzav/modulekit
[submodule "solidity/account-modules/lib/openzeppelin-contracts"]
path = solidity/account-modules/lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
[submodule "solidity/account-modules/lib/BokkyPooBahsDateTimeLibrary"]
path = solidity/account-modules/lib/BokkyPooBahsDateTimeLibrary
url = https://github.com/bokkypoobah/BokkyPooBahsDateTimeLibrary
[submodule "solidity/account-modules/lib/safe-singleton-deployer-sol"]
path = solidity/account-modules/lib/safe-singleton-deployer-sol
url = https://github.com/wilsoncusack/safe-singleton-deployer-sol
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ tmp/
# Lock files
pnpm-lock.yaml
uv.lock

# Solidity submodules (have their own prettier configs)
solidity/**/lib/
11 changes: 11 additions & 0 deletions solidity/account-modules/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Compiler files
cache/
out/

# Ignores development broadcast logs
!/broadcast
/broadcast/*/31337/
/broadcast/**/dry-run/

# Dotenv file
.env
74 changes: 74 additions & 0 deletions solidity/account-modules/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Account Modules

ERC-7579 compliant executor modules for smart account automation in the x402 payments system.

## Modules

### AutoTopUpModule

- Automatically tops up agent accounts when balance falls below threshold
- Configurable per-agent limits (daily, monthly)
- Permissionless triggering with proper checks
- Used by: Main accounts to fund agent accounts

### AutoCollectModule

- Automatically collects payments from service accounts
- Configurable collection thresholds (amount and time)
- Batch collection optimization
- Used by: Service accounts to collect to main accounts

## Architecture

All modules implement the ERC-7579 executor module interface:

- `onInstall(bytes calldata data)` - Module installation
- `onUninstall(bytes calldata data)` - Module removal
- `isModuleType(uint256 typeID)` - Returns true for executor type (0x01)
- `isInitialized(address account)` - Check if module is initialized for account

## Deployment

The modules are deployed as immutable singletons using Safe's Singleton Factory, ensuring the same addresses across all
chains:

- **AutoTopUpExecutor**: `0x16f13052FbFFfcE34E5752b7F4CFF881a030F40B`
- **AutoCollectExecutor**: `0x29864bd91370886c38dE9Fe95F5589E7EbE15130`

These addresses are deterministic and will remain consistent on all supported chains (Base, Base Sepolia, etc.).

## Development

### Prerequisites

- [Foundry](https://book.getfoundry.sh/getting-started/installation)
- [pnpm](https://pnpm.io/installation) (for ModuleKit dependencies)

### Setup

```bash
# Install Forge dependencies
forge install

# Install ModuleKit node dependencies (required for compilation)
cd lib/modulekit && npm install && cd ../..

# Build contracts
forge build

# Run tests
forge test

# Deploy
forge script script/Deploy.s.sol --rpc-url $RPC_URL --broadcast
```

**Important**: ModuleKit requires its node modules to be installed for proper compilation. This step (`pnpm install` in
the modulekit directory) must be performed after cloning the repository and before building.

## Security

- Non-custodial design - modules only execute based on user-defined rules
- Access control via ERC-7579 standards
- Immutable singleton contracts - no upgradeability, no owner
- Comprehensive event logging
Loading