Agora: Welcome to the Token BazaarAgora: Welcome to the Token BazaarAgora: Welcome to the Token Bazaar
The eCash ecosystem continues to evolve. This time delivering a unique spin on programmable money with Agora, a non-custodial marketplace protocol. It powers the recently released NFT token DEX on Cashtab, showcasing eCash’s native DeFi capabilities. This NFT DEX allows Cashtab users to list their NFTs for sale, and others to purchase them, in a decentralized permissionless manner.
Though eCash is primarily engineered as a digital cash network, it runs on a simple but powerful Script system. Script enables some DeFi use cases such as Agora, within eCash’s scalable UTXO-based design.
In this blog post, we’ll explore the Agora protocol and how it uses eCash’s Script language, giving you an idea of the unique features of decentralized applications (dApps) on eCash. We will cover more advanced topics, but the explanations are kept simple, with further links for anyone who wants to dive deeper.
First things First: What is Script?
Script is the programming language within eCash transactions, allowing users to define the conditions under which funds can be spent. Unlike traditional financial transactions, eCash transactions are not just about transferring value; they are also about executing specific conditions encoded in scripts. This setup allows for automated, decentralized operations.
Contrary to Ethereum’s Solidity, Script lacks a few computational features, which limits its capabilities. This was a deliberate design choice by Satoshi which makes it significantly more secure, predictable, and scalable. These are valuable properties, especially for a network engineered to serve as internet money.
Advantages of eCash Script
Script’s security guarantee is an advantage gained from its reduced flexibility. Exploits and hacks are much easier to prevent. It pairs well with the scalability of eCash, making native covenants operate securely and more efficiently than smart contracts on EVM chains, and in a few cases even trumping their capabilities.
It’s common on smart chains for example, that you’ll end up paying fees for failed transactions. This can’t happen on eCash, whether you’re making general transactions, sending tokens, or interacting with any kind of covenant. Fees are predictable and there is no such thing as a failed transaction. Another example is “gas-less” token transactions. A feature that allows you to pay transaction fees with the token itself instead of the native coin. A highly sought-after but virtually impossible feat for smart chains, while trivial to do on eCash. It’s been running for many years in the form of the Postage Protocol.
Script’s Operation Codes
Operation codes (opcodes) are the actual computational building blocks of Script. They are the basic commands that dictate how transactions are processed and validated on the blockchain. A noteworthy opcode is OP_CHECKDATASIG. It was introduced to Bitcoin ABC in 2018 along with the reactivation of other opcodes previously disabled in the BTC implementation. These additional opcodes add functionality for more elaborate scripts.
Particularly for Agora, OP_CHECKDATASIG enables the clever use of “anyone-can-spend” transactions to make a token for sale spendable by the person who buys it. You read that right – technically speaking, token offers that you buy on the Agora are actually spent by you (to yourself) in the same transaction you make to pay for the token. This kind of “atomic swap” allows for automated, non-custodial token trades.
How Agora Works
At the core of Agora are covenants. These are simple smart contracts on the eCash network. The covenants consist of a set of conditions that control how and when transactions are executed. Each time you make an offer via the Agora protocol, you create a covenant on the chain. The covenant will execute a predefined action (i.e.: give out NFT) when your conditions are met (i.e.: pay XEC to a specified address).
A noteworthy distinction from similar decentralized exchanges is Agora’s “non-interactive” nature. It means that while similar DEXs require both parties to be online at the same time to complete a swap (i.e.: interactive), Agora allows users to list and fulfill offers asynchronously (i.e.: non-interactive). This automates the marketplace and makes it more flexible and user-friendly.
A good analogy for how Agora covenants work from a user perspective is the vending machine. Anyone can deploy a vending machine that gives out a specific token for a specified amount of eCash, the machine takes care of the rest. Anyone else can initiate a buy order with the machine by depositing XEC, which executes a program that gives out the token. No one else than the buyer needs to be present for the trade to go through. This universal token vending protocol can be leveraged by developers to implement decentralized and automated exchanges with ease.
I see Ethereum markets more like brokerages… They are complicated, there are commissions, you need a caste of professional interpreters, and so on. The eCash market is much more like a bazaar. There are no intermediaries. Everything is peer-to-peer at the protocol level. Contracts are simple — you pay the price, you get the token.
- Joey, Cashtab Lead Dev
The History of Agora
The first version of Agora was introduced under the name SLP-DEX by Tobias Ruck and a developer going by the username Chippi. SLP stands for Simple Ledger Protocol, the original name of the eToken protocol when Bitcoin ABC was operating as Bitcoin Cash. At that time, different projects provided various token DEX solutions already, interest in additionally deploying the SLP-DEX was therefore limited. On top of that, the infrastructure for indexing token transactions was not up to the task, making it difficult for developers to implement well-rounded solutions. A problem that has been tackled and solved on eCash with its built-in Chronik indexer.
Tobias and other subject matter experts knew that the underlying Script-based protocols were efficient and technically sound, despite the indexing issues in the past. So they continued to thoughtfully extend and refine native eCash covenants over the years, waiting for their time to shine. Today, with the required infrastructure in place and no other non-interactive DEX in the ecosystem, that day has finally come.
The universal marketplace has since been deployed on eCash, constituting a global, on-chain order book of eToken offers that anyone can access to trade with. You can now buy and sell NFTs and fungible tokens through the Cashtab wallet, creating a fully automated, permissionless environment for trading all types of tokenized assets and stablecoins.
Further Agora Use-cases
Apart from the eCash to eToken swap, the Agora can also be used to facilitate swaps between one token to another. Another use case that is already being looked into is automatic market making. Tobias is also optimistic about leveraging Avalanche consensus in an ingenious combination with Agora to provide instant cross-chain atomic swaps. Smart chains like AVAX or ETH could interoperate with eCash, enabling you to buy and sell your XEC against their native coins in a similar way you would swap tokens on-chain.
There might be more applications we haven’t considered yet. It is up to the developer community to discover them. For more use cases based on Script, we provide ecash-lib, a library that serves as the first layer of abstraction from the Script programming language, along with a Script debugger (WIP), making it easy for anyone interested in developing eCash covenants without having expert knowledge. We call on all devs to give it a try and test Script and Agora to its limits. Tell us what you’ve found!
Conclusion
Although Script-based protocols like eTokens or Agora have a reputation as being rudimentary compared to those of smart chains, they are secure and powerful when wielded in the right hands. With well-thought-out protocols like eTokens and Agora carried by Script and innovative opcodes like OP_CHECKDATASIG, eCash is throwing its hat into the DeFi landscape with a native DEX made accessible through a reliable, efficient, and highly scalable infrastructure.