Smart Contract Guide

πŸš€ Quick Start

To run the smart contract, you need run the following command

1. Clone and Install

git clone https://github.com/your-org/gelap-contracts
cd gelap-contracts
forge install

2. Run Tests

forge test

3. Deploy

# Set up environment
cp .env.example .env
# Edit .env with your configuration

# Deploy to testnet
forge script script/DeployGelap.s.sol --rpc-url $RPC_URL --broadcast

πŸ—οΈ Project Structure

gelap-contracts/
β”œβ”€β”€ src/
β”‚   └── GelapShieldedAccount.sol    # Main contract
β”œβ”€β”€ test/
β”‚   β”œβ”€β”€ Deposit.t.sol               # Deposit tests
β”‚   β”œβ”€β”€ Transact.t.sol              # Transaction tests
β”‚   β”œβ”€β”€ Withdraw.t.sol              # Withdrawal tests
β”‚   └── mocks/
β”‚       └── MockSP1Verifier.sol     # Mock verifier
β”œβ”€β”€ script/
β”‚   └── DeployGelap.s.sol           # Deployment script
β”œβ”€β”€ docs/                           # Documentation
└── lib/                            # Dependencies

πŸ”‘ Key Features

  • Privacy: Hide transaction amounts and participants

  • Zero-Knowledge Proofs: Powered by SP1 zkVM

  • ERC20 Support: Works with any ERC20 token

  • Merkle Tree: Efficient state management

  • Double-Spend Protection: Nullifier tracking

πŸ“– Core Concepts

Commitments

Private notes representing token ownership. Each commitment contains:

  • Token address

  • Amount

  • Owner's public key

  • Blinding factor (randomness)

Nullifiers

Unique identifiers that prevent double-spending without revealing which note was spent.

Merkle Tree

A 32-level tree storing all commitments. The root represents the current state.

SP1 zkVM

Zero-knowledge virtual machine that proves correct state transitions off-chain.

🀝 Contributing

Contributions are welcome! Please read our contributing guidelines before submitting PRs.

πŸ“„ License

MIT License - see LICENSE file for details

πŸ†˜ Support

⚠️ Disclaimer

This software is in active development and has not been audited. Use at your own risk. Do not use in production without a professional security audit.

Last updated