Unstake your tokens with zero BNB in your wallet. Powered by EIP-7702 Account Abstraction on BSC.
Zero-G Unstake is a novel rescue protocol that enables users to exit staking positions even when they have absolutely no native gas tokens (BNB) in their wallet. By leveraging EIP-7702's temporary EOA delegation, users can pay for gas using the very tokens they're unstaking.
- The Problem
- The Solution
- How It Works
- Architecture Flow
- Key Features
- Smart Contracts
- Getting Started
- License
Imagine this scenario:
- β You staked 1,000 USDT into a yield vault 30 days ago
- β The lock period has expired β your tokens are ready to withdraw
- β Your wallet has 0 BNB β you cannot pay gas fees
- π° You're stuck. Your valuable assets are locked, visible but unreachable.
This is a critical UX failure in DeFi:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β
β π° Your Wallet β
β βββ BNB Balance: 0.000 BNB β
β βββ Staked USDT: 1,000 USDT (Ready to Unstake!) β
β β
β β½ Gas Required: 0.001 BNB (~$0.60) β
β β
β β RESULT: Cannot unstake. Assets trapped. β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Current workarounds are painful:
- π Ask a friend to send you BNB (trust + coordination required)
- π± Use a CEX to buy and withdraw BNB (KYC, fees, delays)
- π Bridge from another chain (complex, risky, slow)
There has to be a better way.
Zero-G Unstake introduces a paradigm shift using EIP-7702's account delegation:
"What if your EOA could temporarily become a smart account, unstake your tokens, and pay gas from the unstaked amount β all in one atomic transaction?"
EIP-7702 allows an Externally Owned Account (EOA) to temporarily delegate its execution logic to a smart contract. This means:
- π Your keys, your control β Only you can authorize the delegation
- β‘ Temporary upgrade β Your EOA "borrows" smart contract capabilities
- π Atomic execution β Unstake + gas payment happens in one transaction
- πΈ Pay with what you have β Use your staked tokens to cover gas fees
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β
β STEP 1: User Authorization (Off-Chain) β
β βββββββββββββββββββββββββββββββββββββββ β
β β
β User signs an EIP-7702 authorization payload: β
β β’ Delegates EOA logic β UnstakeDelegate contract β
β β’ Specifies: vault address, token, expected amount β
β β’ NO gas required β this is just a signature! β
β β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β STEP 2: Relayer Submission (On-Chain) β
β βββββββββββββββββββββββββββββββββββββββ β
β β
β A Relayer bot picks up the authorization: β
β β’ Bundles the EIP-7702 auth into a transaction β
β β’ Pays the BNB gas fee upfront β
β β’ Submits to BSC Testnet β
β β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β STEP 3: Atomic Execution (On-Chain) β
β ββββββββββββββββββββββββββββββββββββ β
β β
β The UnstakeDelegate logic executes FROM the user's EOA: β
β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β 1. Call vault.unstake() βββββββββββββββΊ Tokens released β β
β β 2. Receive ERC20 tokens βββββββββββββββΊ Into user's EOA β β
β β 3. Calculate gas cost + fee βββββββββββΊ e.g., 5 USDT β β
β β 4. Transfer fee to Relayer ββββββββββββΊ Relayer reimbursed β β
β β 5. Keep remaining tokens ββββββββββββββΊ User's wallet β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β
β ALL STEPS ARE ATOMIC β If any step fails, everything reverts! β
β β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
| Before | After |
|---|---|
| 0 BNB | 0 BNB (unchanged) |
| 1,000 USDT (staked) | 995 USDT (in wallet) |
| β Trapped | β Free! |
The user paid ~5 USDT (gas + fee) and rescued 995 USDT β without ever holding BNB.
βββββββββββββββββββ
β BSC TESTNET β
β BLOCKCHAIN β
ββββββββββ²βββββββββ
β
β 3. Submit Tx
β (Pays Gas)
β
ββββββββββββββββ 1. Sign Auth βββββββββββ΄ββββββββββ
β β βββββββββββββββββΊ β β
β USER β (Off-Chain) β RELAYER β
β (0 BNB) β β (Bot) β
β β βββββββββββββββββ β β
ββββββββββββββββ 6. Success! βββββββββββββββββββββ
β β
β β
βΌ βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β ON-CHAIN EXECUTION β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β User's EOA β β
β β (Temporarily Upgraded via 7702) β β
β β β β β
β β ββββββββββββββββββββββΌβββββββββββββββββββββ β β
β β β UnstakeDelegate Logic β β β
β β β ββββββββββββββ βββββββββββββββββββ β β β
β β β β unstake() βββββΊβ Transfer Tokens β β β β
β β β β from Vaultβ β (User + Relayer)β β β β
β β β ββββββββββββββ βββββββββββββββββββ β β β
β β βββββββββββββββββββββββββββββββββββββββββββ β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β β
β βββββββββββββββββ΄ββββββββββββββββ β
β βΌ βΌ β
β βββββββββββββββββββ βββββββββββββββββββ β
β β Staking Vault β β ERC20 Token β β
β β (Releases $) β β (USDT/etc) β β
β βββββββββββββββββββ βββββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Every step β from unstaking to relayer reimbursement β happens in a single, atomic transaction. If any part fails, the entire operation reverts. Your funds are never at risk of being partially processed.
Unlike traditional meta-transaction solutions that require pre-setup or session keys, Zero-G Unstake works instantly. Sign once, rescue immediately.
Users don't just "defer" gas payment β they pay with a different asset entirely. No BNB needed, ever. The gas cost is deducted from the unstaked tokens.
- Private keys never leave the user's device
- The Relayer cannot steal funds (atomic execution ensures fair reimbursement)
- EIP-7702 delegation is temporary and scoped
The delegate contract calculates the real-time gas cost (in BNB) and converts it to the equivalent token amount plus a small service fee. Transparent and fair.
Built and tested on BSC Testnet with full EIP-7702 support. Ready for mainnet deployment post-audit.
| Contract | Description |
|---|---|
MockERC20.sol |
Test token for simulating staked assets |
StakingVault.sol |
Simple time-locked staking vault |
UnstakeDelegate.sol |
Core EIP-7702 delegate logic for rescue operations |
Relayer.sol |
(Optional) On-chain relayer registry and fee management |
# Clone the repository
git clone https://github.com/your-team/zero-g-unstake.git
cd zero-g-unstake
# Install Foundry dependencies
forge install
# Install Node.js dependencies
npm install# Compile contracts
forge build
# Run tests
forge test -vvv
# Deploy to BSC Testnet
forge script script/Deploy.s.sol --rpc-url $BSC_TESTNET_RPC --broadcast# Start the relayer bot
npx ts-node scripts/relayer.ts- Core concept & architecture design
- Smart contract implementation (ZeroGToken, StakingVault, UnstakeDelegate)
- Comprehensive Foundry test suite (14 tests passing)
- Viem-based relayer with EIP-7702 support
- Sepolia Testnet deployment & demo
- MEV-Safe Execution - Transactions routed through Flashbots/MEV Blocker
- Auto-Unstake Bot - Monitors users and auto-rescues when lock expires
- One-Click Frontend - React/Next.js UI with ConnectKit wallet integration
# Clone the repository
git clone https://github.com/Shubhojit-17/Zero-G_Unstake.git
cd Zero-G_Unstake
# Install Foundry dependencies
forge install
# Install Node.js dependencies
npm install# Compile contracts
forge build
# Run tests
forge test -vvv# Copy and configure environment
cp .env.example .env
# Edit .env with your keys
# Run the full demo
npx tsx scripts/demo.tscd frontend
npm install
npm run dev# Register users for auto-rescue
npx tsx scripts/autoUnstakeBot.ts register <user-address>
# Start the bot
npx tsx scripts/autoUnstakeBot.ts start| Contract | Address |
|---|---|
| ZeroGToken | 0xACDca6c55F4CBA946763413854341b9E5556212A |
| StakingVault | 0x5085d1DD5FbDA9166094C3a3dc41dea7Df8fD9e7 |
| UnstakeDelegate | 0x8ca2A267D31989FE05111cd46326AFA6971607AF |
Built with β€οΈ for the BSC EIP-7702 Hackathon 2025
MIT License β See LICENSE for details.
Zero-G Unstake β Because your tokens shouldn't be held hostage by gas fees.