The frontend application provides a user interface for:
Shielded Deposits : Move tokens into the private pool
Private Transfers : Send tokens privately between shielded addresses
Withdrawals : Exit the shielded pool back to public addresses
Treasury Rates : Real-time yield data from DeFi protocols
Note : All private transactions use Pedersen commitments for amount hiding, stealth addresses for recipient hiding, and SP1 zkVM proofs for validity.
Getting Started
pnpm (recommended) or npm
Setting Up Mantle Sepolia Testnet
Before running the app, you need to add the Mantle Sepolia Testnet to your wallet:
Option 1: Automatic (via Chainlist)
Search for "Mantle Sepolia"
Click "Add to Wallet" and approve the request
Option 2: Manual Configuration
Add the network manually in your wallet (e.g., MetaMask) with these settings:
https://rpc.sepolia.mantle.xyz
https://explorer.sepolia.mantle.xyz
Getting Mock Tokens (mUSDT)
To test deposits, you'll need some mock USDT tokens on Mantle Sepolia. Follow these steps to mint mUSDT:
Click "Connect to Web3" to connect your wallet
Find the mint function and enter:
amount : The amount to mint (in wei). For example, 10000000000000000000000 for 10,000 mUSDT
Click "Write" and confirm the transaction in your wallet
Once the transaction is confirmed, the mUSDT tokens will appear in your wallet and can be used for testing deposits.
Open your browser at http://localhost:3000 and click Launch Now to access the shielded DEX.
Wallet SDK (/src/wallet-sdk/)
The wallet SDK provides all cryptographic and blockchain interactions:
Main PrivacyWallet class combining all functionality
Pedersen commitment generation and verification
View/spend key derivation from wallet signatures
Stealth address generation for private receiving
Client-side Merkle tree for tracking commitments
Smart contract interaction wrapper
Key Generation Flow
When a user connects their wallet, the following happens:
SP1 Environment Init : Initialize privacy context for ZK operations
Sign Message : User signs a message to derive privacy keys
Key Derivation : Extract view and spend keys from signature using keccak256
Stealth Address : Compute receiving address from public keys
Chain Sync : Fetch existing notes from contract events
Input : User selects token and amount
Approve : ERC20 approval for the Gelap contract
Deposit : Generate commitment, call contract
Success : Note stored locally, balance updated
Withdrawal Flow
Select Notes : Choose UTXOs to spend
Amount : Enter withdrawal amount
Confirm : Generate ZK proof (via prover service)
Success : Public funds received
Smart Contract Integration
Contract Address (Mantle Sepolia)
Events to Track
AccountUpdated(bytes32 commitment, bytes encryptedMemo)
Private transaction completed
WithdrawExecuted(address receiver, ...)
usePrivacyWallet
Main hook for privacy wallet state:
useTreasuryRates
Fetch live yield rates from DeFiLlama:
useContractEvents
Subscribe to contract events:
Environment Variables
Create a .env.local file in the project root:
Getting WalletConnect Project ID
Enter project name (e.g., "Gelap Privacy")
Select "App" as project type
Copy the Project ID from the dashboard
Paste it in your .env.local file
Prover Service Integration
Withdrawals and private transfers require ZK proofs from the SP1 prover service.
Expected API Endpoints
Merkle Tree Specification
The client-side Merkle tree must match the on-chain implementation:
keccak256(abi.encodePacked(uint256(0)))
Pedersen commitments are used for amount hiding:
Where:
H = Secondary generator point on secp256k1
G = Standard generator point
blinding = Random 32-byte scalar
The wallet persists state to localStorage:
Manual Testing Checklist
Build Verification
Troubleshooting
RPC Errors (503)
If you see "no backends available":
Check you're on the correct network (Mantle Sepolia for testnet)
Contract may not be deployed on mainnet yet
Signature Rejected
If wallet generation fails:
User rejected the signature request
Click "Retry Generation" button
Prover Unavailable
Withdrawals require a running prover service:
Set NEXT_PUBLIC_PROVER_API_URL in .env.local
Mock proofs are used in development
Last updated 2 months ago