Lux Skills Reference
Lux Safe Multisig Smart Accounts + Wallet UI
Lux Safe is a multisig smart account platform combining Safe v1.5.0 contracts (fork of safe-global/safe-smart-account) with a legacy React wallet UI and a Next.js static docs/landing site. Supports ERC-4337 account abstraction, EIP-7702 delegation detection, and secp256r1 signature verification via EIP-7951/RIP-7212 precompiles.
Item Value Repo github.com/luxfi/safePackage @luxfi/safeVersion v0.0.7 Contract Version Safe v1.5.0 Solidity >=0.7.0 <0.9.0 Framework Hardhat 2.27+ / hardhat-deploy Compiler solc 0.7.6 (default) Upstream safe-global/safe-smart-account License BSD-3-Clause
safe/
contracts/ # Solidity source (Safe v1.5.0)
src/
app/ # Next.js 15 landing/docs site (static export)
deploy/ # Hardhat deployment scripts (7 scripts)
tasks/ # Custom Hardhat tasks
utils/ # TypeScript utilities
react/ # Legacy Safe React wallet UI (v3.32.1, React 17)
app/ # Legacy CRA app shell (service worker, mocks)
test/ # Hardhat test suite (10 categories)
benchmark/ # Gas benchmarks (6 specs)
certora/ # Certora formal verification (14 specs)
modules/ # Safe module stubs (dutchx_seller, recurring_transfers)
modules-deployments/ # Module deployment artifacts
docs/ # Audit reports (PDFs), docs site (Next.js/MDX)
types/ # TypeScript type definitions
Contract File Purpose SafeSafe.solCore multisig (1487 LOC). EIP-712 typed data signing, M-of-N threshold, gas refund, module/guard system. Inherits EIP7951 for secp256r1 SafeL2SafeL2.solL2-optimized variant that emits events for indexing (mainnet Safe does not emit for gas savings) SafeProxyproxies/SafeProxy.solMinimal proxy (EIP-1167 style) delegating to singleton SafeProxyFactoryproxies/SafeProxyFactory.solDeterministic proxy deployment via CREATE2
Contract Purpose ExecutorLow-level CALL/DELEGATECALL execution FallbackManagerConfigurable fallback handler routing GuardManagerPre/post transaction guard hooks ModuleManagerModule registration and execution (linked list) OwnerManagerOwner add/remove/swap with threshold management
Contract Standard Purpose EIP7702EIP-7702 Detects EOA delegation context via EXTCODECOPY (0xef0100 prefix) EIP7951EIP-7951/RIP-7212 secp256r1 (P-256) signature verification via precompile at 0x100
Contract Purpose CompatibilityFallbackHandlerERC-1271 signature validation + ERC-721/ERC-1155 token receiver ExtensibleFallbackHandlerFully extensible fallback with pluggable sub-handlers TokenCallbackHandlerERC-721 + ERC-1155 receiver callbacks HandlerContextProvides msg.sender context for fallback handler calls
Contract Purpose ERC165HandlerERC-165 interface detection with per-Safe overrides FallbackHandlerCustom method routing per Safe SignatureVerifierMuxerDomain-specific ERC-1271 signature verification TokenCallbacksToken receive hooks MarshalLibABI encoding utilities for handler data
Contract Purpose CreateCallCREATE/CREATE2 from Safe context MultiSendBatch multiple transactions in one call MultiSendCallOnlyBatch CALL-only transactions (no DELEGATECALL) SafeMigrationSingleton upgrade with optional fallback handler update SafeStorageStorage slot layout (singleton at slot 0) SafeToL2SetupSetup helper for L2 Safe initialization SignMessageLibEIP-191/EIP-712 message signing from Safe SimulateTxAccessorSimulate transaction for gas estimation
Guard Purpose DebugTransactionGuardLogs all transaction details for debugging DelegateCallTransactionGuardBlocks DELEGATECALL operations OnlyOwnersGuardRestricts execution to Safe owners only ReentrancyTransactionGuardPrevents reentrancy during execution
7 Hardhat deploy scripts in src/deploy/:
Script Tags Deploys deploy_safe_singleton.tssingleton, main-suiteSafe implementation deploy_safe_l2.tsl2, main-suiteSafeL2 implementation deploy_factories.tsfactory, main-suiteSafeProxyFactory deploy_handlers.tshandlers, main-suiteFallback handlers deploy_libraries.tslibraries, main-suiteMultiSend, CreateCall, etc. deploy_accessors.tsaccessors, main-suiteSimulateTxAccessor deploy_migrations.tsmigrations, main-suiteSafeMigration
All deployments use deterministic deployment (safe-singleton-factory) for identical addresses cross-chain.
Task Purpose deploy_contractsDeploy all contracts to a network local_verifyVerify contract source on local explorer show_codesizeDisplay contract bytecode sizes
Tests organized in test/ with 10+ categories:
Directory Coverage core/Execution, signatures, storage, setup, owner/module/guard/fallback management factory/Proxy creation, deterministic deployment guards/Guard hook behavior handlers/Fallback handler routing, extensible handlers integration/End-to-end workflows l2/SafeL2 event emission libraries/MultiSend, CreateCall, migration migration/Singleton upgrade paths json/ABI/JSON compatibility utils/Test utilities
Benchmark specs in benchmark/: Creation, ERC1155, ERC20, Ether, MultiSend, Proxy.
Test commands:
npm run test:hardhat # All Hardhat tests
npm run test:L1 # L1-specific tests (chainId=1)
npm run test:L2 # L2 tests (SafeL2)
npm run test:secp256r1 # EIP-7951 P-256 precompile tests
npm run benchmark # Gas benchmarks
npm run coverage # Coverage report
14 CVL specs in certora/specs/:
Spec Verifies Execute.specTransaction execution invariants Signatures.specSignature validation correctness Setup.specInitialization safety Safe.specCore Safe properties SafeMigration.specMigration correctness OwnerReach.specOwner linked list reachability ModuleReach.specModule linked list reachability Guards.specGuard hook execution Fallback.specFallback routing Hash.specEIP-712 hash computation NativeTokenRefund.specGas refund in native token SafeToL2Setup.specL2 setup correctness Extensible.specExtensible handler properties
Audit reports in docs/ covering versions 1.0.0 through 1.5.0:
Version Auditor Type 1.0.0 G0 Group Security audit 1.0.0 Runtime Verification Formal verification 1.1.0 G0 Group Security audit 1.1.1 G0 Group Security audit 1.2.0 G0 Group Security audit 1.3.0 G0 Group Security audit (initial + final) 1.4.0 Certora Formal verification 1.4.1 Ackee Blockchain Library contracts 1.5.0 Ackee Blockchain Security audit 1.5.0 Certora Formal verification
Located in react/, version 3.32.1. React 17 + Redux + Material-UI application.
Item Value Framework CRA (rescripts) State Redux + redux-thunk Web3 web3.js 1.7, @gnosis.pm/safe-core-sdk UI Material-UI v4 Testing Jest, Cypress Node 16 (.nvmrc)
Located in src/app/, uses Next.js with static export (output: 'export').
Item Value Framework Next.js 15, React 18 Styling Tailwind CSS Dependencies @luxfi/ui, @luxfi/data, @luxfi/menu-icons, @hanzo/auth, @hanzo/commerceDeployment GitHub Pages (static)
Network URL hardhat Local (chainId configurable via HARDHAT_CHAIN_ID, default 31337) mainnet Infura (requires INFURA_KEY) sepolia Infura (requires INFURA_KEY) gnosis rpc.gnosischain.comzksync mainnet.era.zksync.iocustom Any URL via NODE_URL env var
RIP-7212 precompile enabled via HARDHAT_SECP256R1_PRECOMPILE=1.
git clone https://github.com/luxfi/safe.git
cd safe
npm install
npx hardhat compile # Compile contracts
npx hardhat test # Run all tests
npm run test:secp256r1 # Test P-256 verification
npm run coverage # Coverage report
npm run codesize # Check bytecode sizes
npm run deploy-all custom # Deploy to custom network (NODE_URL)
Interface Purpose ISafeFull Safe API (setup, execTransaction, checkSignatures, approveHash, nonce) IModuleManagerModule enable/disable/execute IOwnerManagerOwner add/remove/swap, threshold IGuardManagerGuard set/get IFallbackManagerFallback handler set ISignatureValidatorERC-1271 isValidSignature
lux/lux-wallet.md -- Wallet integration with Safe
lux/lux-crypto.md -- Cryptographic primitives
lux/lux-governance.md -- DAO treasury management via Safe