Protein Swaps

extend fusion + to non evm chains (8 chains / tracks) , following the fusion + whitepaper

Protein Swaps

Created At

Unite Defi

Project Description

The Protein-Swap project is a comprehensive, multi-blockchain atomic swap platform designed to enable secure, trustless, peer-to-peer token exchanges using smart contracts and hash time-locked contracts (HTLCs). Its main goal is to facilitate atomic swaps meaning token transfers that are either fully completed or fully reverted across several blockchain networks

Core Concepts and Functionality

Atomic Swap Escrow

  • The heart of the project is an atomic swap escrow system. This leverages smart contracts to allow users to exchange tokens without needing to trust one another or a third party.
  • The system uses hashlock (requiring a secret for redemption) and timelock (automatically cancels if not claimed in time) mechanisms to ensure safety and fairness.
  • Multi-party support enables owners and takers to interact flexibly across chains.

How the Atomic Swap Works

  1. Owner creates an escrow contract, locking tokens and committing a secret hash.
  2. Taker claims the tokens by revealing the correct secret.
  3. If the taker fails to claim before the timelock expires, the owner can reclaim the tokens.
  4. All operations are logged for transparency.

How it's Made

Development Details & Technologies Smart Contracts & Escrow Logic The project uses smart contract technology to implement atomic swap escrows. These contracts are responsible for securely locking tokens, enforcing hashlock (secret-based unlocking), and timelock (automatic cancellation if unclaimed) mechanisms. Contracts are written in the native language of each platform, ensuring efficiency and adherence to best practices. Token contracts are mock implementations, allowing unrestricted minting and burning for easy testing. Tooling & Automation Contract Toolkits: Compilation, deployment, and testing are automated using platform-specific development environments and CLIs. This ensures fast iteration and easy reproducibility. Scripts: Node.js scripts orchestrate actions such as deployment, minting tokens, creating escrows, revealing secrets, and canceling swaps. TypeScript is used for type safety and code clarity. Environment Configuration: Sensitive data and settings (private keys, RPC URLs, contract addresses) are injected via .env files. Example templates are included to streamline onboarding and collaboration. Testing & Security End-to-end test flows are provided for each platform. Tests automatically: Deploy contracts Mint tokens Create escrows with randomly generated secrets Unlock escrows by revealing secrets Cancel escrows when the timelock expires Tests verify balances and print explorer links for every transaction, enabling real-time debugging. Security features include strict access control, hash verification, and timelock enforcement to prevent funds loss. Project Structure The codebase is modularized, with a dedicated directory for each platform. Each module contains its own contracts, deployment scripts, tests, and documentation. Universal scripting conventions make the project easy to extend or port to other platforms. Partner Tech & Integration Benefits Development Toolkits: Chosen for their speed, reliability, and developer support, allowing rapid prototyping and debugging. Web Wallets & IDEs: Used for interactive contract management and testing, simplifying the developer experience. SDKs: Integrated for seamless communication with the platforms, making automation and integration straightforward. Notable Hacks & Clever Approaches Automated Secret and Order ID Generation: Escrow scripts randomly generate secrets and IDs for each test run, removing manual steps. Retry Logic in Scripts: Automated retries handle transient network or RPC issues for robust testing. Multi-Wallet Simulation: Test scripts generate new wallets to mimic real-world swaps between distinct users. Explorer Links: Every operation outputs direct explorer links for instant verification and transparency. Hash Function Abstraction: Scripts select the platform’s recommended hash algorithms automatically. Environment Templates: Example env files simplify configuration and facilitate collaboration. Summary This project is a multi-platform atomic swap system, built with a strong emphasis on developer experience, security, and modularity. The architecture enables seamless, trustless token swaps, with hacky but effective scripting for robust automation and rapid prototyping. The use of modern toolkits, SDKs, and detailed testing flows makes it a powerful foundation for decentralized finance experimentation.

background image mobile

Join the mailing list

Get the latest news and updates