Example scripts demonstrating how to use the @ravenhouse/bridge-sdk package for bridging tokens between Ethereum L1 and Aztec L2. Supports both public and private (shielded) transfers.
- Bun runtime installed
- Aztec sandbox or access to devnet/testnet
- Ethereum wallet with funds (Sepolia ETH for devnet/testnet)
- Aztec account credentials
bun install- Copy the example environment file:
cp .env.example .env- Fill in your credentials in
.env:
# Aztec Environment (devnet/sandbox/testnet)
AZTEC_ENV=devnet
# L1 Wallet (Ethereum/Sepolia)
ETHEREUM_WALLET_PRIVATE_KEY=your_ethereum_private_key_here
# L2 Account (Aztec)
ADMIN_SECRET_KEY=0x...
ADMIN_SIGNING_KEY=0x...
ADMIN_SALT=0x...
# Bridge Configuration (optional)
BRIDGE_AMOUNT=2
BRIDGE_PRIVATE=false# Devnet
bun run bridge:l1-to-l2:devnet
# Sandbox (local)
bun run bridge:l1-to-l2:sandbox
# Testnet
bun run bridge:l1-to-l2:testnet# Devnet
bun run bridge:l1-to-l2:devnet:private
# Sandbox (local)
bun run bridge:l1-to-l2:sandbox:private
# Testnet
bun run bridge:l1-to-l2:testnet:private# Devnet
bun run bridge:l2-to-l1:devnet
# Sandbox (local)
bun run bridge:l2-to-l1:sandbox
# Testnet
bun run bridge:l2-to-l1:testnet# Devnet
bun run bridge:l2-to-l1:devnet:private
# Sandbox (local)
bun run bridge:l2-to-l1:sandbox:private
# Testnet
bun run bridge:l2-to-l1:testnet:private| Variable | Description | Required |
|---|---|---|
AZTEC_ENV |
Network environment (devnet, sandbox, testnet) |
Yes |
ETHEREUM_WALLET_PRIVATE_KEY |
Private key for L1 wallet | Yes |
ADMIN_SECRET_KEY |
Secret key for L2 Schnorr account | Yes |
ADMIN_SIGNING_KEY |
Signing key for L2 Schnorr account | Yes |
ADMIN_SALT |
Salt for L2 account derivation | Yes |
BRIDGE_AMOUNT |
Amount to bridge (defaults to 2 for L1→L2, 1 for L2→L1) | No |
BRIDGE_PRIVATE |
Set to true for private transfers |
No |
- Public: Tokens are deposited to your public balance on Aztec L2. Visible on-chain.
- Private: Tokens are shielded and deposited to your private balance on Aztec L2. Not visible to observers.
- Public: Withdraws from your public balance on L2, sends to L1.
- Private: Unshields tokens from your private balance, then withdraws to L1.
Bridges tokens from Ethereum L1 to Aztec L2:
- Sets up L1 wallet using the provided private key
- Connects to Aztec node and sets up L2 wallet
- Initializes the CompliantBridge with network configuration
- Executes the bridge operation with step-by-step progress tracking
- Supports both public and private (shielded) deposits on L2
Bridges tokens from Aztec L2 to Ethereum L1:
- Sets up L1 wallet for receiving tokens
- Connects to Aztec node and sets up L2 wallet
- Burns tokens on L2 (from public or private balance) and waits for proof generation
- Withdraws tokens on L1
This project uses the @ravenhouse/bridge-sdk npm package which provides:
CompliantBridge- Main bridge orchestrator classCachedAztecNode- Cached Aztec node connectionTestWalletAdapter- Adapter for test wallet compatibilitynetworks- Pre-configured network settings (devnet, sandbox, testnet)createLogger- Logging utilityBridgeStep- Type for tracking bridge progress
MIT