This project is a cross-chain bridge implementation developed for Unite Defi. It provides a solution for executing 1inch Fusion+ cross-chain orders between Tezos and Ethereum networks.
- Hashlock and timelock functionality - Preserved on the Tezos side to ensure secure cross-chain transactions
- Signature verification - Implemented on the Tezos side for validating swap requests
- Bidirectional swaps - Token swaps are supported in both directions (Tezos ↔ Ethereum)
- On-chain execution - Deployed and tested on Tezos Ghostnet and Local EVM Node
- Resolver server - A lightweight resolver implemented to launch cross-chain order execution
- User interface - Console application for easy interaction
- Partial fills - Not implemented
The system consists of:
- Smart contracts deployed on both EVM-compatible chains and Tezos
- A resolver service that receives cross-chain orders from clients and executes them on Tezos and Ethereum
- A command-line interface application that allows users to swap tokens between Tezos and Ethereum networks
packages/client
- Command-line interface application that allows users to swap tokens between Tezos and Ethereum networkspackages/server
- Resolver service that receives cross-chain orders from clients and executes them on Tezos and Ethereum
Note: For simplicity, we combined the functionality of three separate components into a single server:
- Backend – Responsible for creating and storing cross-chain orders.
- Resolver – Handles order execution, escrow contract origination, and performs
withdraw
/cancel
operations.- Relayer – Monitors escrow contract states and forwards the user's secret to the resolver.
packages/common
- Shared utilities, types, and configuration helpers used across client, server and local-evm-node packagespackages/local-evm-node
- Local EVM node for testing that deploys escrow factory and resolver contracts on EVM-compatible chainscontracts/evm
- 1Finch Fusion+ Solidity smart contracts from https://github.com/1inch/cross-chain-resolver-examplecontracts/tezos
- CameLIGO smart contracts for Tezos blockchain, including escrow and escrow factory contractsscripts
- Build scripts and development utilities
- Node.js: >= 22.0.0
- npm: >= 10.9.0
- Clone the repository:
git clone https://github.com/baking-bad/1inch-fusion-plus-tezos.git
cd 1inch-fusion-plus-tezos
- Install dependencies and build the project:
npm run build
Or use the -o
flag to override existing .env
files:
npm run build -- -o
To run the system locally, follow these steps:
-
Start the local EVM node
This service runs a local EVM environment and allows testing of swap execution on the EVM side.
cd packages/local-evm-node npm start
-
Start the resolver server
This service listens for cross-chain orders and executes them on both Tezos and Ethereum.
cd packages/server npm start
-
Start the client application
The CLI client allows you to initiate and finalize cross-chain swaps.
cd packages/client npm start
Use the Client
application to run the following commands
-
Check initial balances for maker and taker
Run the command:
balances-all
This command displays the balance of all available tokens for the user (a.k.a. the
maker
orme
), and the balance of all available tokens for the resolver (a.k.a thetaker
). -
Create a cross-chain order
Run the
swap
command in the following format:swap 123 tez:usdt 123 eth:usdc
After executing this command:
- A cross-chain order will be created on the server with all necessary parameters.
- The server will deploy smart contracts:
- On the Tezos network, an
escrow_src
contract will be originated with the maker's (user's) funds locked. - On the Ethereum network, an
escrow_dst
contract will be deployed with the taker's (resolver's) funds locked.
- On the Tezos network, an
-
Withdraw funds (you have 1 minute to do this)
Run the
withdraw
command:withdraw last
After executing this command:
- The resolver will use the user's secret to call
withdraw
on both escrow contracts deployed on Tezos and Ethereum networks. - Funds will be unlocked from the smart contracts, completing the swap.
- Funds from the
escrow_src
contract will be transferred to the taker (resolver). - Funds from the
escrow_dst
contract will be transferred to the maker (user).
- Funds from the
- The resolver will use the user's secret to call
-
Check balances for maker and taker after swap
Run the command:
balances-all
Compare the balances with those from step 1.
- The user's balance on Tezos should be decreased by the corresponding amount.
- The user's balance on Ethereum should be increased by the corresponding amount.
- The resolver's balance on Tezos should be increased by the corresponding amount.
- The resolver's balance on Ethereum should be decreased by the corresponding amount.
Use the Client
application to run the following commands
-
Check initial balances for maker and taker
Run the command:
balances-all
This command displays the balance of all available tokens for the user (a.k.a. the
maker
orme
), and the balance of all available tokens for the resolver (a.k.a thetaker
). -
Create a cross-chain order
Run the
swap
command in the following format:swap 123 eth:usdc 123 tez:usdt
After executing this command:
- A cross-chain order will be created on the server with all necessary parameters.
- The server will deploy smart contracts:
- On the Ethereum network, an
escrow_src
contract will be originated with the maker's (user's) funds locked. - On the Tezos network, an
escrow_dst
contract will be deployed with the taker's (resolver's) funds locked.
- On the Ethereum network, an
-
Withdraw funds (you have 1 minute to do this)
Run the
withdraw
command:withdraw last
After executing this command:
- The resolver will use the user's secret to call
withdraw
on both escrow contracts deployed on Tezos and Ethereum networks. - Funds will be unlocked from the smart contracts, completing the swap.
- Funds from the
escrow_src
contract will be transferred to the taker (resolver). - Funds from the
escrow_dst
contract will be transferred to the maker (user).
- Funds from the
- The resolver will use the user's secret to call
-
Check balances for maker and taker after swap
Run the command:
balances-all
Compare the balances with those from step 1.
- The user's balance on Tezos should be increased by the corresponding amount.
- The user's balance on Ethereum should be decreased by the corresponding amount.
- The resolver's balance on Tezos should be decreased by the corresponding amount.
- The resolver's balance on Ethereum should be increased by the corresponding amount.
Use the Client
application to run the following commands
-
Check initial balances for maker and taker
Run the command:
balances-all
This command displays the balance of all available tokens for the user (a.k.a. the
maker
orme
), and the balance of all available tokens for the resolver (a.k.a thetaker
). -
Create a cross-chain order
Run the
swap
command in the following format:swap 123 tez:usdt 123 eth:usdc
After executing this command:
- A cross-chain order will be created on the server with all necessary parameters.
- The server will deploy smart contracts:
- On the Tezos network, an
escrow_src
contract will be originated with the maker's (user's) funds locked. - On the Ethereum network, an
escrow_dst
contract will be deployed with the taker's (resolver's) funds locked.
- On the Tezos network, an
-
Wait 70 seconds or more
Wait until the withdrawal period expires.
-
Try withdraw funds
Run the
withdraw
command:withdraw last
The corresponding error should be displayed in console.
-
Cancel the swap
Run the
cancel
command:cancel last
After executing this command:
- The resolver will call
cancel
on both escrow contracts deployed on Tezos and Ethereum networks. - Funds will be returned back to the maker and taker respectively.
- Funds from the
escrow_src
contract will be transferred to the maker (user). - Funds from the
escrow_dst
contract will be transferred to the taker (resolver).
- Funds from the
- The resolver will call
-
Check balances for maker and taker after swap
Run the command:
balances-all
Compare the balances with those from step 1. Balanced should be the same.
Use the Client
application to run the following commands
-
Check initial balances for maker and taker
Run the command:
balances-all
This command displays the balance of all available tokens for the user (a.k.a. the
maker
orme
), and the balance of all available tokens for the resolver (a.k.a thetaker
). -
Create a cross-chain order
Run the
swap
command in the following format:swap 123 eth:usdc 123 tez:usdt
After executing this command:
- A cross-chain order will be created on the server with all necessary parameters.
- The server will deploy smart contracts:
- On the Ethereum network, an
escrow_src
contract will be originated with the maker's (user's) funds locked. - On the Tezos network, an
escrow_dst
contract will be deployed with the taker's (resolver's) funds locked.
- On the Ethereum network, an
-
Wait 70 seconds or more
Wait until the withdrawal period expires.
-
Try withdraw funds
Run the
withdraw
command:withdraw last
The corresponding error should be displayed in console.
-
Cancel the swap
Run the
cancel
command:cancel last
After executing this command:
- The resolver will call
cancel
on both escrow contracts deployed on Tezos and Ethereum networks. - Funds will be returned back to the maker and taker respectively.
- Funds from the
escrow_src
contract will be transferred to the maker (user). - Funds from the
escrow_dst
contract will be transferred to the taker (resolver).
- Funds from the
- The resolver will call
-
Check balances for maker and taker after swap
Run the command:
balances-all
Compare the balances with those from step 1. Balanced should be the same.