This project enables atomic swaps of ERC20 tokens between Ethereum and Filecoin networks. It uses a trusted escrow contract to facilitate the swap, ensuring that the exchange is atomic and secure. This implementation is designed for EVM-compatible chains and does not rely on a centralized exchange.
The process involves two parties, Party A and Party B, who wish to swap tokens. Party A initiates the swap by deploying an escrow contract on an Ethereum-based chain (e.g., Sepolia). This contract holds the tokens to be exchanged. Party B, on a Filecoin-based chain (e.g., Filecoin Calibrationnet), interacts with a corresponding escrow contract to complete the swap.
The swap is "atomic" because it is executed as a single, indivisible transaction. If any part of the swap fails, the entire transaction is rolled back, and the tokens are returned to their original owners. This is made possible through the use of a shared secret that both parties must provide to unlock the funds.
Document on the Implementation Plan
-
Clone the repository:
git clone https://github.com/your-username/ETH-FIL-SWAP.git cd ETH-FIL-SWAP -
Install dependencies:
npm install
-
Set up environment variables:
Create a
secrets.jsonfile in the root directory and replacing the privatekey values with your own
First, deploy the escrow contracts to both the Sepolia and Filecoin networks:
-
Deploy to Sepolia (Chain A):
npx hardhat run scripts/deploy_chain_a.js --network sepolia
-
Deploy to Filecoin (Chain B):
npx hardhat run scripts/deploy_chain_b.js --network filecoin
These scripts will deploy the Escrow.sol contract to each network
After deploying the contracts, you need to fund them with the tokens to be swapped. You can do this by sending tokens to the escrow contract addresses.
To see how the swap will work simply run the below command
npx hardhat run scripts/execute_swap.js --network sepoliaThis script will initiate the swap on the Sepolia network, which will then be reflected on the Filecoin network.
Going live on Mainnet after Thanksgiving week :)
Please visit https://x.com/momack28/status/1992768978155135159