DittoBridge Contract
https://bscscan.com/address/0xdF11367EE135C8fb95b70769437FccB63D59092c
Implementation Notes
Our bridge contract DittoBridge is a secure EIP-712–based withdrawal bridge adapted from industry-standard OpenZeppelin components and inspired by designs such as Polygon FxPortal and Immutable X’s off-chain custody bridges. It enables seamless transfers between Ditto’s off-chain ledger and the on-chain DITTO token contract.
The bridge validates signed withdrawal permits issued by the backend using EIP-712 structured data signatures, ensuring tamper-resistant verification and replay protection. Deposits are emitted as on-chain events, allowing the backend to credit users’ off-chain balances.
The contract is implemented entirely with audited OpenZeppelin modules and does not introduce any new or unaudited logic beyond glue code connecting these modules.
Key Components
-
OpenZeppelin security primitives: SafeERC20, ECDSA, EIP712, Ownable, ReentrancyGuard, Pausable.
- Used to guarantee secure token handling, cryptographic signature validation, ownership control, and protection from reentrancy or paused states.
- OpenZeppelin audit references:
-
EIP-712 structured data signing:
We use EIP-712 typed data to generate and verify backend-signed withdrawal permits.
- EIP standard
- Each (user, nonce) pair can be used only once, preventing replay or double withdrawals.
-
Polygon FxPortal audit (inspiration):
- Polygon’s FxPortal bridge uses the same message-verification model for withdrawals validated via signatures.
- Audit reference
-
Immutable X / dYdX bridge inspiration:
- Off-chain custody pattern where backend-signed slips authorize on-chain withdrawals.
- Demonstrates mature production precedent for hybrid custody models.
- Audit reference
What We Changed vs Reference Designs (and Why)
- Simplified architecture: We removed message-passing layers (e.g., child/parent state sync) and implemented a single-chain bridge focused on off-chain balance verification.
- Added EIP-712 withdrawal slips: Our version explicitly binds each slip to (user, amount, nonce, expiry), with backend signer rotation for operational security.
- Added deposit event tracking: Each user deposit emits a DepositCompleted event with a hashed external reference (e.g., Telegram ID) for the backend to process credits deterministically.
- Vault controls:
- ownerTopUpDitto() lets the admin replenish the vault.
- ownerWithdrawDitto() enables rebalancing or draining of excess liquidity.
- Both require owner authority and are non-reentrant.
- Pausable safety: All external flows (deposit and withdraw) are guarded by whenNotPaused.