@towns-labs/contracts 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +133 -0
- package/dist/abis/index.d.ts +2769 -0
- package/dist/abis/index.d.ts.map +1 -0
- package/dist/abis/index.js +1857 -0
- package/dist/abis/index.js.map +1 -0
- package/dist/addresses.json +30 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +76 -0
- package/dist/index.js.map +1 -0
- package/package.json +62 -0
package/README.md
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# Towns Protocol Contracts
|
|
2
|
+
|
|
3
|
+
Solidity smart contracts for EIP-7702 account abstraction, intent-based execution, and cross-chain settlement.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Install dependencies
|
|
9
|
+
bun install
|
|
10
|
+
|
|
11
|
+
# Copy environment variables
|
|
12
|
+
cp .env.example .env
|
|
13
|
+
|
|
14
|
+
# Start local development (Anvil + deploy + generate config)
|
|
15
|
+
bun run dev
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Scripts
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
bun run dev # Start Anvil, deploy contracts, generate config
|
|
22
|
+
bun run build # Compile contracts and generate TypeScript ABIs
|
|
23
|
+
bun run generate # Generate TypeScript ABIs only
|
|
24
|
+
bun run test # Run tests with verbose output
|
|
25
|
+
bun run test:gas # Run tests with gas report
|
|
26
|
+
bun run coverage # Generate coverage report
|
|
27
|
+
bun run fmt # Format Solidity code
|
|
28
|
+
bun run lint # Check formatting
|
|
29
|
+
bun run deploy:local # Deploy to local Anvil (for CI)
|
|
30
|
+
bun run make-config # Generate deployment config
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Configuration
|
|
34
|
+
|
|
35
|
+
### Environment Variables
|
|
36
|
+
|
|
37
|
+
Set in `.env` (copy from `.env.example`):
|
|
38
|
+
|
|
39
|
+
| Name | Description |
|
|
40
|
+
|------|-------------|
|
|
41
|
+
| `ANVIL_RPC_URL` | Local Anvil endpoint |
|
|
42
|
+
| `LOCAL_PRIVATE_KEY` | Deployment key (first Anvil account) |
|
|
43
|
+
| `RPC_84532` | Base Sepolia RPC (for bytecode copying) |
|
|
44
|
+
| `RELAYER_MNEMONIC` | Mnemonic for relayer signer generation |
|
|
45
|
+
| `RELAYER_COUNT` | Number of relayer signers |
|
|
46
|
+
|
|
47
|
+
### Deployment Config
|
|
48
|
+
|
|
49
|
+
Chain-specific settings live in `deployments/config.toml`:
|
|
50
|
+
|
|
51
|
+
| Context | Chain | Description |
|
|
52
|
+
|---------|-------|-------------|
|
|
53
|
+
| `local` | anvil (31337) | Local Anvil development |
|
|
54
|
+
| `stage` | base-sepolia (84532) | Base Sepolia testnet |
|
|
55
|
+
| `prod` | base (8453) | Base Mainnet |
|
|
56
|
+
|
|
57
|
+
Each chain section includes:
|
|
58
|
+
- RPC endpoint URL
|
|
59
|
+
- Constructor arguments for contracts
|
|
60
|
+
- Relayer mnemonic and count
|
|
61
|
+
|
|
62
|
+
## Architecture
|
|
63
|
+
|
|
64
|
+
| Contract | Purpose |
|
|
65
|
+
|----------|---------|
|
|
66
|
+
| **TownsAccount** | EIP-7702 account with key management |
|
|
67
|
+
| **Orchestrator** | Intent verification, gas compensation, execution |
|
|
68
|
+
| **GuardedExecutor** | Execution guards and spend limits |
|
|
69
|
+
| **Escrow** | Token escrow with cross-chain settlement |
|
|
70
|
+
| **SimpleFunder** | Relayer funding mechanism |
|
|
71
|
+
| **LayerZeroSettler** | Cross-chain settlement via LayerZero v2 |
|
|
72
|
+
| **Simulator** | Gas simulation for orchestrator calls |
|
|
73
|
+
|
|
74
|
+
## Deployment
|
|
75
|
+
|
|
76
|
+
### First-time Setup
|
|
77
|
+
|
|
78
|
+
1. Configure environment:
|
|
79
|
+
```bash
|
|
80
|
+
cp .env.example .env
|
|
81
|
+
# Edit .env with your RPC URLs and private keys
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
2. Configure deployment in `deployments/config.toml`:
|
|
85
|
+
- Set constructor arguments per chain
|
|
86
|
+
- Configure relayer mnemonic and count
|
|
87
|
+
|
|
88
|
+
3. Deploy:
|
|
89
|
+
```bash
|
|
90
|
+
# Local development
|
|
91
|
+
make deploy-local-unified
|
|
92
|
+
|
|
93
|
+
# Stage (Base Sepolia)
|
|
94
|
+
make deploy-stage-unified
|
|
95
|
+
|
|
96
|
+
# Production (Base Mainnet)
|
|
97
|
+
make deploy-unified CHAINS=8453 CONTEXT=prod
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
4. Generate TypeScript ABIs:
|
|
101
|
+
```bash
|
|
102
|
+
bun run build
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Updating Contracts
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
make deploy-stage-unified # Redeploy to stage
|
|
109
|
+
make deploy-unified CHAINS=8453 CONTEXT=prod # Redeploy to prod
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Selective Deployment
|
|
113
|
+
|
|
114
|
+
Deploy specific contracts only:
|
|
115
|
+
```bash
|
|
116
|
+
make deploy-unified CHAINS=84532 CONTRACTS=SimpleFunder,SimpleSettler
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Deployment Artifacts
|
|
120
|
+
|
|
121
|
+
- `deployments/envs/<context>/<chainId>/` - Contract addresses
|
|
122
|
+
- `broadcast/` - Transaction records
|
|
123
|
+
- `deployments/addresses.json` - Address mappings
|
|
124
|
+
|
|
125
|
+
## Testing
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
bun run test # All tests
|
|
129
|
+
bun run test:gas # With gas report
|
|
130
|
+
bun run coverage # Coverage summary
|
|
131
|
+
forge test --match-test testName # Specific test
|
|
132
|
+
forge test --match-contract Contract # Specific contract
|
|
133
|
+
```
|