A privacy-preserving ERC20 token vault system using zero-knowledge proofs for confidential transactions on Ethereum and compatible blockchains.
ZeroLedger enables private ERC20 token transfers by using cryptographic commitments and zero-knowledge proofs. Users can deposit, spend, and withdraw tokens while maintaining transaction privacy through the use of Circom circuits and PLONK proving system.
- π Private Deposits: Deposit tokens with cryptographic commitments using Poseidon hashes
- π Confidential Spends: Transfer tokens between commitments using ZK proofs without revealing amounts
- π Multiple Input/Output Support: Flexible transaction structures supporting various combinations (1-1, 1-2, 1-3, 2-1, 2-2, 2-3, 3-1, 3-2, 3-3, 8-1, 16-1)
- π° Fee Support: Configurable fees for transactions with dedicated fee recipients
- π Metadata Encryption: Optional encrypted metadata for commitments
- β‘ PLONK Proving System: Efficient zero-knowledge proof generation and verification
- π Multi-Network Support: Deployable on Ethereum and compatible L2 networks
- π‘οΈ Security: Built with OpenZeppelin contracts and comprehensive testing
The ZeroLedger system consists of three main contracts designed for modularity and security:
-
Vault: Core contract that stores and manages cryptographic commitments. Handles deposits, spends, and withdrawals while maintaining privacy through zero-knowledge proofs.
-
Forwarder: Supports meta-transactions and batching operations. This contract is permissionless and enables users to execute transactions without paying gas fees directly, improving user experience and enabling complex transaction batching.
-
ProtocolManager: Manages protocol-level parameters like fees and max protocol tvl.
-
Administrator: Manages protocol contracts administrative functions like upgrades or emergency pausing
Multisig Governance: All administrative functions, including fee updates, contract upgrades, and security measures, are managed through multisig wallets. This ensures that no single entity can make critical changes to the protocol.
- Admin Multisig: Controls protocol roles management
- Maintainer Multisig: Controls protocol contracts upgrades
- Security Council Multisig: Manages emergency pauses and security functions
- Treasury Manager Multisig: Controls fee parameters and treasury operations
- Deposit Circuit: Validates 3 input commitments sum to total deposit amount
- Spend Circuits: Multiple variants supporting different input/output combinations:
spend_11: 1 input, 1 outputspend_12: 1 input, 2 outputsspend_13: 1 input, 3 outputsspend_21: 2 inputs, 1 outputspend_22: 2 inputs, 2 outputsspend_23: 2 inputs, 3 outputsspend_31: 3 inputs, 1 outputspend_32: 3 inputs, 2 outputsspend_33: 3 inputs, 3 outputsspend_82: 8 inputs, 1 outputsspend_161: 16 inputs, 1 output
- Git
- Node.js (v18 or higher)
- Foundry for unit testing and development
- Hardhat for integration tests & deployment
1.Clone and install dependencies:
git clone https://github.com/zeroledger/contracts.git
cd contracts
npm install
npx husky install2.Install Foundry dependencies:
forge install foundry-rs/forge-std3.Set up environment variables:
cp .env.example .env
# Edit .env with your configurationnpm run compile- Compile contracts with Hardhatnpm run format- Format Solidity code with Forgenpm run lint- Lint Solidity code with Solhintnpm run gas- Generate gas report
npm run test- Run all tests (Foundry + Hardhat)npm run unit- Run all Foundry unit testsnpm run int- Run Hardhat integration tests
npm run deploy:initial {network}- Initial deploy to specified network
npm run clean- Clean all build artifacts and dependenciesVERSION_TAG={Version} npx hardhat ignition deploy ./ignition/modules/{Vault|Forwarder|ProtocolManager}.module.ts --network {network}- Deploy new module versionTOKEN_ADDRESS={address} MAX_TVL={amount} npm run tvl:config- Generate TVL config payload for ProtocolManagerTOKEN_ADDRESS={address} SPEND_FEE={amount} DEPOSIT_FEE={bps} WITHDRAW_FEE={bps} npm run fee:config- Generate fee config payload for ProtocolManager
contracts/
βββ src/ # Smart contract source files
β βββ Administrator.sol # Contract to admin roles for Forwarder, Vault, ProtocolManager contract administration
β βββ Forwarder.sol # Forwarder contract with ERC6492 support
β βββ ProtocolManager.sol # Contract to manage protocol parameters
β βββ Vault.sol # Main vault contract
β βββ Vault.types.sol # Vault types & interfaces
β βββ Verifiers.sol # ZK proof verifiers umbrella contract
β βββ Roles.lib.sol # Roles constants
β βββ Inputs.lib.sol # Input utilities
βββ helpers/ # Helpers contracts
β βββ MockERC20.sol # Test token
β βββ Proxy.sol/ # ERC1967Proxy import
βββ ignition/ # Zero-knowledge circuits
β βββ modules/ # hardhat ignition deployment modules
β βββ deployments/ # deployments artifacts
βββ test/ # Foundry unit tests
βββ integration/ # Hardhat integration tests
βββ circuits/ # Zero-knowledge circuits (git module)
βββ lib/ # Foundry dependencies (git module)
βββ abi/ # Contract ABIsCreate a .env based on .env.example
- Local Development: Hardhat, Localhost
- Testnets: BaseSepolia
Networks are configurable via hardhat.config.js
- Audited Dependencies: Uses OpenZeppelin & solady contracts
- Reentrancy Protection: Built-in guards against reentrancy attacks
- Access Control: Proper authorization mechanisms with multisig governance
- Zero-Knowledge Proofs: Cryptographic privacy guarantees
- Comprehensive Testing: Extensive test coverage: In progress
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- ZeroLedger Protocol Documentation
- Foundry Documentation
- Hardhat Documentation
- Circom Documentation
- OpenZeppelin Contracts
- Solady Documentation
- Solidity Documentation
This project is licensed under the GNU v3.0 License - see the LICENSE file for details.
If you encounter any issues or have questions:
- Open an issue
- Check the documentation
- Join our community discussions telegram
Note: This is experimental software. Always audit your smart contracts before deploying to production networks.