project screenshot 1
project screenshot 2
project screenshot 3
project screenshot 4
project screenshot 5
project screenshot 6

PintSwap

We built the first DEX on Essential Blockchain, powered by a declarative framework. Users can seamlessly add/remove liquidity, swap tokens, and earn LP tokens. Plus, we open-sourced a JS framework to make Essential development accessible to all developers.

PintSwap

Created At

ETHGlobal San Francisco

Winner of

Essential - Best DeFi Application Written in Pint Runners Up

Project Description

Our project is the first decentralized exchange (DEX) built on Essential Blockchain, which operates using a declarative programming model. Essential allows state updates driven by constraints and solvers, optimizing outcomes without requiring direct transaction execution. We dedicated significant time to developing and open-sourcing a TypeScript framework for Essential Blockchain, as no such framework existed before. This tool allows other developers to build applications on Essential using JavaScript/TypeScript, significantly lowering the barrier to entry for the ecosystem. In addition, we created a rigorous testing framework that helped us master contract syntax. Due to the limited resources and documentation available, we frequently worked with Essential’s development team in Australia to troubleshoot issues and deepen our understanding of the chain and its capabilities.

Our DEX allows users to: • Add/remove liquidity using token pairs and receive LP tokens, representing their share of the liquidity pool. • Swap tokens within the liquidity pools, with prices adjusting automatically based on the AMM model. • Earn LP tokens for providing liquidity and share in transaction fees as passive income. Since no tokens existed on the Essential Blockchain when we started, we wrote contracts to mint, burn, and transfer tokens. We also experimented with building a smart wallet tailored for the Essential Blockchain.

On the front-end, we utilized Next.js and React to create a modern, responsive user interface, adhering to best practices observed in other swap protocols.

Despite building the DEX in just 36 hours, we see incredible potential for future enhancements. Our next steps include developing a Dollar-Cost Averaging (DCA) tool, which will allow users to automatically purchase assets on a scheduled basis using time-based constraints in Pint contracts. This DEX project is just the beginning of leveraging the power of declarative blockchains to innovate in decentralized finance.

How it's Made

Building the first decentralized exchange (DEX) on Essential Blockchain was a deeply technical and challenging process, particularly because Essential is a declarative blockchain, and most tooling traditionally supports imperative blockchains. Since Essential only supported Rust, we had to innovate to make the blockchain more accessible to a broader developer audience.

Technologies We Used: • Pint: Essential’s declarative smart contract language. It allowed us to write contracts with constraints that solvers could optimize, making the DEX function without relying on sequential execution. • JavaScript/TypeScript: To make development easier and more accessible, we built a TypeScript framework that lets other developers write tools in JS/TS for Essential, bypassing the need for fluency in Rust. This framework also integrates with Essential’s backend to allow contracts to be executed declaratively. • Next.js: We built the DEX’s front-end using Next.js & React to create a modern, responsive user interface, adopting best practices from established DEX protocols like Uniswap. This gave us a solid front-end development framework with server-side rendering for optimal performance. • Custom Testing Framework: Since no robust testing framework existed for Pint contracts, we built our own to ensure that the constraints and contract logic were functioning properly. This involved writing tests that forced us to learn the nuances of the contract language and ensuring that all contract conditions were met during execution. • Solvers & Constraints: The DEX relies on solvers to find the optimal token swaps and liquidity pooling conditions based on user-set constraints. This required a deep understanding of how solvers work to ensure that valid state transitions were made.

How It Came Together: • Backend Contracts: We built contracts for minting, burning, and transferring tokens since no tokens existed on the Essential chain when we started. These foundational contracts allowed us to create liquidity pools and issue LP tokens. Using Pint, we expressed constraints rather than step-by-step execution, which solvers would optimize to ensure valid outcomes. • Frontend Development: With Next.js, we implemented the DEX’s UI, allowing users to interact with the smart contracts seamlessly. We focused on user experience by mimicking the design patterns of successful swap protocols, ensuring users could add liquidity, swap tokens, and remove liquidity with ease.

Challenges & Hacky Solutions: • Building a JavaScript Framework: One of the most hacky and notable aspects of our project was building the JavaScript framework from scratch. Essential only supports Rust, so to make development easier for the broader community, we created this JS framework so that developers could write tools and apps for Essential without needing to dive deep into Rust. This was critical for us to overcome the limitations imposed by Rust-only support and enabled us to open-source the framework for future projects. • Custom Wallet Development: We experimented with creating our own smart wallet to handle specific token interactions on the Essential chain. While this wasn’t fully completed during the hackathon, it allowed us to explore how custom wallets could interact with the new JS framework and Pint contracts. • Constant Communication with Essential’s Dev Team: Since the documentation and guides for Essential were sparse, we often found ourselves directly reaching out to their dev team in Australia. This became essential for resolving tough bugs, especially when we were trying to wrap our heads around the proper contract syntax in Pint and testing various contract executions.

background image mobile

Join the mailing list

Get the latest news and updates