|
| 1 | +# Fishnet Contracts |
| 2 | + |
| 3 | +Smart contracts for the Fishnet permit-based wallet system. |
| 4 | + |
| 5 | +## FishnetWallet |
| 6 | + |
| 7 | +EIP-712 permit-gated smart wallet. The Fishnet backend signs permits authorizing on-chain actions, and any relayer can submit them. |
| 8 | + |
| 9 | +### Build & Test |
| 10 | + |
| 11 | +```bash |
| 12 | +cd contracts |
| 13 | +forge build |
| 14 | +forge test -vvv |
| 15 | +``` |
| 16 | + |
| 17 | +### EIP712 Compatibility Tests |
| 18 | + |
| 19 | +The `EIP712Compatibility.t.sol` test suite proves encoding compatibility between the Rust backend signer (`crates/server/src/signer.rs`) and the Solidity contract: |
| 20 | + |
| 21 | +- **Typehash match**: Raw keccak256 of the type string matches `PERMIT_TYPEHASH` |
| 22 | +- **Domain separator**: Field-by-field construction matches `DOMAIN_SEPARATOR()` |
| 23 | +- **Struct hash**: `abi.encode` padding for `uint64`/`uint48` matches Rust's manual padding |
| 24 | +- **End-to-end**: Full EIP-712 hash → sign → execute flow succeeds |
| 25 | +- **Signature format**: `r || s || v` (65 bytes) unpacking matches contract expectations |
| 26 | + |
| 27 | +```bash |
| 28 | +forge test --match-contract EIP712Compatibility -vvv |
| 29 | +``` |
| 30 | + |
| 31 | +### Deployment |
| 32 | + |
| 33 | +#### Local (Anvil) |
| 34 | + |
| 35 | +```bash |
| 36 | +# Terminal 1 |
| 37 | +anvil |
| 38 | + |
| 39 | +# Terminal 2 |
| 40 | +cd contracts |
| 41 | +SIGNER_ADDRESS=0x70997970C51812dc3A010C7d01b50e0d17dc79C8 \ |
| 42 | + forge script script/Deploy.s.sol:DeployFishnetWallet \ |
| 43 | + --rpc-url http://127.0.0.1:8545 \ |
| 44 | + --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 \ |
| 45 | + --broadcast |
| 46 | +``` |
| 47 | + |
| 48 | +#### Base Sepolia |
| 49 | + |
| 50 | +```bash |
| 51 | +cd contracts |
| 52 | +export BASE_SEPOLIA_RPC_URL="https://sepolia.base.org" |
| 53 | +export SIGNER_ADDRESS="<your-signer-address>" |
| 54 | +export BASESCAN_API_KEY="<your-api-key>" |
| 55 | + |
| 56 | +forge script script/Deploy.s.sol:DeployFishnetWallet \ |
| 57 | + --rpc-url base_sepolia \ |
| 58 | + --private-key $DEPLOYER_PRIVATE_KEY \ |
| 59 | + --broadcast \ |
| 60 | + --verify |
| 61 | +``` |
| 62 | + |
| 63 | +### Environment Variables |
| 64 | + |
| 65 | +| Variable | Required | Description | |
| 66 | +|----------|----------|-------------| |
| 67 | +| `SIGNER_ADDRESS` | Yes | Address of the Fishnet backend signer | |
| 68 | +| `OWNER_ADDRESS` | No | Wallet owner (defaults to deployer) | |
| 69 | +| `BASE_SEPOLIA_RPC_URL` | For testnet | Base Sepolia RPC endpoint | |
| 70 | +| `BASE_MAINNET_RPC_URL` | For mainnet | Base mainnet RPC endpoint | |
| 71 | +| `BASESCAN_API_KEY` | For verification | Basescan API key | |
| 72 | + |
| 73 | +### Integration Test |
| 74 | + |
| 75 | +Run the full Anvil-based E2E test (deploys, signs permit with `cast`, executes on-chain): |
| 76 | + |
| 77 | +```bash |
| 78 | +bash scripts/sc3-integration-test.sh |
| 79 | +``` |
| 80 | + |
| 81 | +### Multi-Chain Deployments |
| 82 | + |
| 83 | +Deployment artifacts are stored in `contracts/deployments/`: |
| 84 | + |
| 85 | +``` |
| 86 | +deployments/ |
| 87 | + base-sepolia.json # Base Sepolia testnet |
| 88 | + base-mainnet.json # Base mainnet (future) |
| 89 | + arbitrum-sepolia.json # Arbitrum Sepolia (future) |
| 90 | +``` |
| 91 | + |
| 92 | +Each file contains: `wallet`, `signer`, `owner`, `chainId`, `deployBlock`, `timestamp`. |
| 93 | + |
| 94 | +### EIP712 Encoding Notes |
| 95 | + |
| 96 | +The permit typehash uses `uint64 chainId` and `uint48 expiry` (not `uint256`). Both Solidity's `abi.encode` and Rust's manual big-endian padding produce identical 32-byte left-padded values for these smaller types, ensuring cross-stack compatibility. |
| 97 | + |
| 98 | +Domain name is `"Fishnet"` (not `"FishnetPermit"`), version is `"1"`. |
0 commit comments