Category: DeFi
Emoji: 😎
Demo: https://hackathon.project.io
Tezra: The first trustless portal between Ethereum and Tezos ecosystems 🌉
Tezra is a cross-chain DeFi protocol that enables trustless, atomic swaps between Ethereum and Tezos. Users can securely exchange assets across both ecosystems without relying on centralized bridges or custodians. Tezra leverages advanced smart contracts and a resolver mechanism to ensure swaps are either completed on both chains or safely refunded, eliminating counterparty risk.
- Key Features
- Architecture
- How Tezra Works (Step-by-Step)
- Project Structure
- Requirements
- Setup & Installation
- Building & Running Locally
- Notable Integrations
- Why we are applying for the 1inch prize
- Atomic Swaps: Uses hash time-locked contracts (HTLCs) and a resolver for true cross-chain atomicity.
- Ethereum ↔ Tezos: Swap tokens between Ethereum (including ERC-20s) and Tezos (XTZ), supporting both native and token assets.
- Non-Custodial: Users always control their funds; no third party ever holds user assets.
- Open Source & Auditable: All smart contracts and backend code are public for maximum transparency.
- Modern UI: Inspired by leading DeFi protocols, with a smooth, intuitive user experience.
- Robust Security: Safety deposits, time locks, and on-chain validation protect against malicious actors and failures.
- Extensible: Designed for future multi-chain support.
Tezra is a full-stack protocol with the following components:
- Smart Contracts:
- Ethereum (Solidity): Escrow contracts (
EscrowSrc,EscrowDst) using OpenZeppelin, 1inch Limit Order Protocol, and HTLCs. - Tezos (SmartPy/Michelson): Escrow contract in SmartPy, mirroring Ethereum logic.
- Ethereum (Solidity): Escrow contracts (
- Backend Resolver:
- Node.js/TypeScript: Orchestrates swaps, deploys escrows, monitors funding, and triggers secret revelation.
- Frontend:
- React + Next.js + TailwindCSS: Modern SPA for user interaction, wallet connection, and swap flow.
- SDKs & Libraries:
- @1inch/cross-chain-sdk, Ethers.js, Taquito: For blockchain interactions and cross-chain logic.
- The user connects their Ethereum wallet (MetaMask) and Tezos wallet (Temple/Beacon/Kukai) via the frontend.
- The frontend verifies connections and displays balances.
- The user specifies the asset, amount, and destination address for the swap.
- The frontend generates a random secret and computes its hash (hashlock).
- An order object is created and signed by the user using EIP-712 (on Ethereum).
- The signed order is sent to the backend resolver.
- The resolver validates the order and deploys the source escrow contract on Ethereum using the 1inch Limit Order Protocol.
- The resolver also prepares the destination escrow contract for Tezos.
- On Ethereum, the source escrow contract is deployed and funded by the user (locking their tokens).
- On Tezos, the resolver deploys and funds the destination escrow contract (locking the resolver's tokens).
- The backend monitors both chains to ensure both escrows are funded.
- The frontend displays real-time status updates to the user.
- Once both escrows are funded, the user reveals the secret via the frontend.
- The secret is submitted to both contracts:
- On Tezos, the user withdraws their tokens from the destination escrow using the secret.
- On Ethereum, the resolver uses the revealed secret to withdraw the user's tokens from the source escrow.
- If the swap completes successfully, both parties receive their assets.
- If any party fails to fund or reveal the secret in time, the contracts allow for refunds after a timeout, ensuring no funds are lost.
backend/
src/
contracts/
ethereum/
compiled/
interfaces/
libraries/
BaseEscrow.sol
Escrow.sol
EscrowDst.sol
EscrowSrc.sol
solidity-utils/
contracts/
interfaces/
libraries/
mixins/
mocks/
tests/
tezos/
compiled/
EscrowFactory_v2.py
EscrowFactory.py
EscrowFactoryAdvanced.py
EscrowSrc.py
package.json
swap-ui/
app/
components/
resolver/
globals.css
layout.tsx
page.tsx
public/
.env.example
- Node.js (v18+ recommended): For backend and frontend development.
- Yarn or npm: For managing JavaScript/TypeScript dependencies.
- Python 3.8+: For SmartPy (Tezos contract development).
- SmartPy CLI: For compiling and testing Tezos contracts.
- Hardhat: For Ethereum contract development and testing.
- MetaMask: For Ethereum wallet connection in the frontend.
- Temple/Beacon/Kukai: For Tezos wallet connection in the frontend.
- Docker (optional): For running local blockchain nodes (Ethereum/Tezos) for full local testing.
-
Clone the repository:
git clone https://github.com/yash0501/1inch-tezos.git cd tezra -
Install backend dependencies:
cd backend npm install -
Install frontend dependencies:
cd ../../swap-ui npm install -
Ethereum and Tezos contract compilation: Compiled contracts bytecode is present in
/contracts/ethereum/compiledand/contracts/tezos/compiled -
Configure environment variables:
- Copy
.env.exampleto.envin both/swap-uiand/backendand fill in the required values (RPC URLs, private keys, etc).
- Copy
-
Run the backend resolver:
cd ../../backend npm startServer started on http://localhost:3000
-
Run the frontend:
cd ../../swap-ui npm run devOpen http://localhost:3000 in your browser.
- 1inch Limit Order Protocol: Used for secure, non-custodial order matching and settlement on Ethereum.
- OpenZeppelin: For secure contract patterns and utilities.
- Taquito & Beacon: For seamless Tezos wallet integration and contract interaction.
- @1inch/cross-chain-sdk: For order creation, signing, serialization, and hashlock management.
Tezra's innovative use of the 1inch Limit Order Protocol for cross-chain atomic swaps exemplifies the future of DeFi interoperability. Our protocol not only enhances liquidity access across Ethereum and Tezos but also sets a foundation for multi-chain DeFi ecosystems. By participating in the 1inch prize, we aim to further refine our integration, contribute to the 1inch community, and accelerate the advent of a truly interconnected blockchain finance landscape.
Join us in bridging the Ethereum and Tezos ecosystems!