A complete ZK-rollup implementation with Plonk verifier running on local Geth blockchain and Hardhat development environment.
- Node.js >= 18.x
- npm or yarn
- Go >= 1.19
- Geth (Ethereum client)
- abigen (Go Ethereum ABI generator)
git clone https://github.com/aakash4dev/rollup.git
cd rollup
npm installgo build -o bin/rollup main.go# Generate proving/verifying keys and setup directories
./bin/rollup setup --dir ./datacd hardhat
npx hardhat compile
jq .abi artifacts/contracts/PlonkVerifier.sol/PlonkVerifier.json > artifacts/contracts/PlonkVerifier.sol/PlonkVerifier.abi
jq .abi artifacts/contracts/MyZKApp.sol/MyZKApp.json > artifacts/contracts/MyZKApp.sol/MyZKApp.abi
abigen --abi artifacts/contracts/PlonkVerifier.sol/PlonkVerifier.abi --pkg plonkVerifier --out ../contracts_go/plonkVerifier/PlonkVerifier.go
abigen --abi artifacts/contracts/MyZKApp.sol/MyZKApp.abi --pkg myZKApp --out ../contracts_go/myZKApp/MyZKApp.go
cd ..# Rebuild binary with new Go contract bindings
go build -o bin/rollup main.go./bin/rollup generate-account --dir ./data --name testaccountThis creates:
./data/testaccount.key- Private key (keep secret!)./data/testaccount.addr- Public address
# Start Geth in development mode
geth --dev \
--http --http.api personal,eth,net,web3,miner,txpool \
--http.corsdomain "*" \
--datadir ./gethdata- connect to running blockchain
geth attach http://127.0.0.1:8545- replace
toaddress below with your create address,and send
eth.sendTransaction({
from: eth.accounts[0],
to: "0x87d94dc5d609d1d7a404D686E4B2AE164Fe1621d",
value: web3.toWei(10, "ether")
})sample output : transaction hash. you can verify it by using tx hash
"0xdfaadb9b7dc095ae25d778ef7ad0210d9bebc1175e91e53b06c03cd7707cfbb1"
Update hardhat/hardhat.config.js with your test account's private key:
networks: {
localgeth: {
url: "http://127.0.0.1:8545",
accounts: ["YOUR_PRIVATE_KEY_FROM_testaccount.key"]
}
}cd hardhat
DEPLOY_DIR=../data/deployments npx hardhat run scripts/deploy.js --network localgeth# Basic start command
./bin/rollup start \
--dir ./data \
--rpc http://127.0.0.1:8545 \
--account-name testaccount \
--network localgeth# Advanced start with all options
./bin/rollup start \
--dir ./data \
--rpc http://localhost:8545 \
--account-name testaccount \
--account-path ./data/accounts \
--password ./wallets/password.txt \
--network localgeth \
--verifier-info ./data/deployments/localgeth.json \
--save-proofs \
--start-block 0# Initialize ZK environment
./bin/rollup setup --dir ./data
# Generate new account
./bin/rollup generate-account --dir ./data --name myaccount
# Start rollup service
./bin/rollup start --dir ./data --rpc http://127.0.0.1:8545| Flag | Description | Default |
|---|---|---|
--dir |
Base directory for rollup data | ./data |
--rpc |
Ethereum RPC URL | http://127.0.0.1:8545 |
--save-proofs |
Save generated proofs to disk | true |
--account-name |
Account name for transactions | - |
--network |
Network identifier | - |
# Custom deployment directory
DEPLOY_DIR=../data/deployments
# Custom deployment file name
DEPLOY_FILE=custom.json
# Initial Merkle root (optional)
INITIAL_ROOT=0x1234abcd...# RPC endpoint
RPC_URL=http://127.0.0.1:8545
# Data directory
ROLLUP_DIR=./data
# Save proofs flag
SAVE_PROOFS=1After deployment, you can verify contracts on Etherscan-compatible block explorers:
# Verify PlonkVerifier
npx hardhat verify --network <network> <VERIFIER_ADDRESS>
# Verify MyZKApp
npx hardhat verify --network <network> <ZKAPP_ADDRESS> "<VERIFIER_ADDRESS>" "<INITIAL_ROOT>"- Private Keys: All private keys are stored unencrypted in
./data/directory - Development Only: This setup is for development/testing only
- Production Security: Implement proper key management for production use
-
./bin/rollup clear --dir ./data- Clean command to reset environment - Encrypt private keys with password protection to Implement proper wallet security
- Add configuration validation
- Support for multiple networks
Keys already exist error:
# Delete existing keys to regenerate
rm -rf ./data/keys/*
./bin/rollup setup --dir ./dataAccount already exists error:
# Use different account name or delete existing
rm ./data/testaccount.*
./bin/rollup generate-account --dir ./data --name testaccountContract deployment fails:
# Check if contracts already deployed
rm ./data/deployments/*
# Redeploy
cd hardhat && DEPLOY_DIR=../data/deployments npx hardhat run scripts/deploy.js --network localgethGo binding generation fails:
# Ensure abigen is installed
go install github.com/ethereum/go-ethereum/cmd/abigen@latest
# Make sure contracts are compiled
cd hardhat && npx hardhat compileMIT License - see LICENSE file for details.
- Fork the repository
- Create your 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