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 install
2.Install Foundry dependencies:
forge install foundry-rs/forge-std
3.Set up environment variables:
cp .env.example .env
# Edit .env with your configuration
npm 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 {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 versionFEES_CONFIG="{deposit};{spend};{withdraw}" TOKEN={token} npm run prepareFeesParams {network}
- create ready-to-set fees config for erc20 token
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 ABIs
Create 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.