Skip to content
This repository was archived by the owner on Nov 6, 2025. It is now read-only.

aakash4dev/rollup-incomplete

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Rollup ZK Verifier

A complete ZK-rollup implementation with Plonk verifier running on local Geth blockchain and Hardhat development environment.

πŸ“‹ Prerequisites

  • Node.js >= 18.x
  • npm or yarn
  • Go >= 1.19
  • Geth (Ethereum client)
  • abigen (Go Ethereum ABI generator)

πŸš€ Quick Start

1. Clone & Install Dependencies

git clone https://github.com/aakash4dev/rollup.git
cd rollup
npm install

2. Build Go Binary

go build -o bin/rollup main.go

3. Setup ZK Environment

# Generate proving/verifying keys and setup directories
./bin/rollup setup --dir ./data

4. Compile Smart Contracts

cd 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 ..

5. Rebuild with Generated Contracts

# Rebuild binary with new Go contract bindings
go build -o bin/rollup main.go

6.1 Generate Test Account

./bin/rollup generate-account --dir ./data --name testaccount

This creates:

  • ./data/testaccount.key - Private key (keep secret!)
  • ./data/testaccount.addr - Public address

7. Start Local Blockchain

# Start Geth in development mode
geth --dev \
  --http --http.api personal,eth,net,web3,miner,txpool \
  --http.corsdomain "*" \
  --datadir ./gethdata

8. Fund Test Account

  • connect to running blockchain
geth attach http://127.0.0.1:8545
  • replace to address 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"

9. Configure Hardhat

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"]
  }
}

10. Deploy Smart Contracts

cd hardhat
DEPLOY_DIR=../data/deployments npx hardhat run scripts/deploy.js --network localgeth

11. Start ZK Rollup Service

# 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

πŸ› οΈ CLI Commands

Setup Commands

# 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

Command Options

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 -

πŸ”§ Environment Variables

Deployment Script

# Custom deployment directory
DEPLOY_DIR=../data/deployments

# Custom deployment file name
DEPLOY_FILE=custom.json

# Initial Merkle root (optional)
INITIAL_ROOT=0x1234abcd...

Rollup Service

# RPC endpoint
RPC_URL=http://127.0.0.1:8545

# Data directory
ROLLUP_DIR=./data

# Save proofs flag
SAVE_PROOFS=1

πŸ” Verification

After 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>"

🚨 Security Notes

⚠️ Important Security Considerations:

  1. Private Keys: All private keys are stored unencrypted in ./data/ directory
  2. Development Only: This setup is for development/testing only
  3. Production Security: Implement proper key management for production use

πŸ“ TODO

  • ./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

πŸ› Troubleshooting

Common Issues

Keys already exist error:

# Delete existing keys to regenerate
rm -rf ./data/keys/*
./bin/rollup setup --dir ./data

Account already exists error:

# Use different account name or delete existing
rm ./data/testaccount.*
./bin/rollup generate-account --dir ./data --name testaccount

Contract deployment fails:

# Check if contracts already deployed
rm ./data/deployments/*
# Redeploy
cd hardhat && DEPLOY_DIR=../data/deployments npx hardhat run scripts/deploy.js --network localgeth

Go 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 compile

πŸ“„ License

MIT License - see LICENSE file for details.

🀝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

About

Its an incomplte outdated sample rollup project.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors