A bridge service that monitors ZK proof submissions on the Telos Native chain and automatically bridges them to the Telos EVM via the EOSIO EVM smart contract.
This system consists of:
- NativeChainMonitor - Monitors Telos Native for proof submissions to
snarkbabybv1::submit
- ProofBridge Contract - Solidity contract on Telos EVM that receives bridged proofs
- ProofBridge Service - Node.js service that bridges proofs from Native to EVM
- ✅ Monitors Telos Native chain for ZK proof submissions
- ✅ Automatically bridges proofs to Telos EVM
- ✅ Prevents duplicate processing with transaction tracking
- ✅ Graceful error handling and recovery
- ✅ State persistence for reliable restarts
- ✅ Configurable monitoring parameters
# Clone and install dependencies
npm install
# Copy configuration template
cp config.json.example config.json
# Edit configuration with your settings
nano config.json
Edit config.json
with your settings:
{
"NATIVE_ENDPOINT": "https://mainnet.telos.net",
"BRIDGE_PRIVATE_KEY": "your_telos_native_private_key",
"BRIDGE_EVM_PRIVATE_KEY": "0x...",
"BRIDGE_ACCOUNT": "your_telos_account",
"EVM_CHAIN_ID": 40,
"PROOF_BRIDGE_CONTRACT_ADDRESS": "0x...",
"TARGET_CONTRACT": "snarkbabybv1",
"TARGET_ACTION": "submit"
}
# Install Hardhat for contract deployment
npm install --save-dev hardhat @nomiclabs/hardhat-ethers
# Compile and deploy the contract (requires Hardhat setup)
npm run deploy-contract
# Fund with 10 TLOS (default)
npm run fund-bridge
# Fund with custom amount
npm run fund-bridge 25.0000
npm start
The system now uses Hyperion v2 API (https://mainnet.telos.net/v2
) for efficient monitoring:
- Direct Action Filtering: Queries only
snarkbabybv1::submit
actions - Global Sequence Tracking: Uses Hyperion's global_sequence for reliable state
- Batch Processing: Processes up to 100 actions per request
- Better Performance: No need to scan entire blocks
GET https://mainnet.telos.net/v2/history/get_actions
?account=snarkbabybv1
&action.name=submit
&limit=100
&sort=desc
&after=<last_global_sequence>
npm start
npm run check-balance
The service will log:
- New proof submissions detected
- Bridge transactions submitted
- Error conditions and recovery
- Polls Telos Native for new blocks
- Scans transactions for
snarkbabybv1::submit
actions - Extracts proof data and metadata
- Emits events for the bridge service
- Listens for proof events from the monitor
- Creates EVM transactions calling
submitBridgedProof()
- Submits transactions via
eosio.evm
contract - Tracks processed transactions to prevent duplicates
- Stores bridged proofs with metadata
- Prevents duplicate submissions
- Provides verification status tracking
- Emits events for proof submissions
function submitBridgedProof(
bytes calldata _proofBytes,
string calldata _nativeAccount,
string calldata _nativeTxHash
) external onlyBridgeOperator
The service includes robust error handling:
- Network connectivity issues
- Failed transactions (retries)
- Invalid proof data
- Insufficient bridge wallet balance
- State file corruption recovery
Key metrics to monitor:
- Bridge wallet balance
- Processing lag (blocks behind)
- Failed bridge attempts
- Duplicate transaction attempts
- Bridge operator private keys should be secured
- Regular monitoring of bridge wallet balance
- Contract owner controls for emergency stops
- Audit proof verification logic before production
├── src/
│ ├── main.js # Entry point
│ ├── nativeMonitor.js # Native chain monitoring
│ └── proofBridge.js # Bridge logic
├── contracts/
│ └── ProofBridge.sol # EVM contract
├── scripts/
│ ├── deployContract.js # Contract deployment
│ ├── fundBridge.js # Bridge wallet funding
│ └── checkBalance.js # Balance checking
└── config.json.example # Configuration template
npm run dev # Runs with Node.js inspector for debugging
Bridge wallet not found:
npm run fund-bridge # Creates and funds the wallet
Insufficient gas:
- Check bridge wallet balance
- Increase funding amount
Missed transactions:
- Check
monitor-state.json
for last processed block - Manually set START_BLOCK in config if needed
Contract deployment issues:
- Ensure OpenZeppelin contracts are installed
- Verify EVM chain ID matches network
- Check bridge operator address in constructor
MIT