This project implements a bridge to transfer tokens from Polygon (Layer 2) back to Ethereum (Layer 1) using the Polygon PoS Bridge mechanism.
- Withdraw (burn) tokens on Polygon network
- Wait for checkpoint completion
- Submit proof to unlock tokens on Ethereum
- Python 3.13 or higher
- Ethereum wallet with private key
- Infura account (or other Ethereum RPC provider)
- Sufficient tokens on Polygon network
- Sufficient MATIC for gas fees on Polygon
- Sufficient ETH for gas fees on Ethereum
-
Clone the repository
-
Install dependencies using uv:
uv venv
source .venv/bin/activate
uv pip install -e .
- Copy
.env.example
to.env
and configure:
cp .env.example .env
- Set the following environment variables in
.env
:
ETH_RPC_URL
: Your Ethereum RPC endpointPOLYGON_RPC_URL
: Polygon RPC endpointPRIVATE_KEY
: Your wallet's private key (without 0x prefix)CHILD_TOKEN_ADDRESS
: Token contract address on Polygon
- python-dotenv >= 1.0.1
- requests >= 2.32.3
- web3 >= 7.8.0
Run the bridge script:
python bridge_to_ethereum.py
The script will:
- Withdraw tokens on Polygon
- Wait for checkpoint (approximately 30 minutes)
- Submit proof to unlock tokens on Ethereum
- The bridge process takes approximately 30+ minutes due to checkpoint requirements
- Ensure sufficient gas fees on both networks
- Keep your private key secure and never share it
- Test with small amounts first
- Root Chain Manager (Ethereum):
0x86E4Dc95c7FBdBf52e33D563BbDB00823894c287
- Child Token (Polygon): Set in environment variables