Introducing Crypto Formulas

Ondratra
Crypto Formulas
Published in
8 min readApr 8, 2020

--

Hurray! The first version of Crypto Formulas has been released to the Ethereum network and decentralized app awaits you at cryptoformulas.com.

This is what it looks like.

Motivation behind Crypto Formulas

In early 2019 when the development of Crypto Formulas have began, the Ethereum ecosystem still lacked tools for some of the most common peer-to-peer interactions. Yes, couple of Decentralized EXchanges (DEX) have already existed, but the options they provided were limited. For example, there existed DEXes enabling you to trade ERC20 compliant tokens for other ERC20 tokens or auction ERC721 tokens for Ether. However, the possibilities to make private offers/trades, combine various asset types, customize terms, include escrow, etc. were missing. Now we have 2020, and up to now, things haven’t improved much in this area (while I acknowledge the ecosystem made tremendous progress overall).

The situation is changing now with the introduction of Crypto Formulas, an intuitive building kit for value transferring interactions on Ethereum.

What is Formula

Formula is a small program that can be interpreted and settled by the Crypto Formulas smart contract. It helps you solve everyday situations that you encounter when using Ethereum and assets based on the Ethereum network. Formula consists of 3 main parts.

The first part is a list of all participants, represented by their Ethereum addresses. Those participants will be referenced in other Formula’s parts. Participants’ addresses are called Endpoints in the project.

The second part is a sequence of operations that describe what will happen. Each operation is composed of selected instruction and its operands. One example of instruction is Send Ether from party number 1 to party number 2, with three operands sending party, receiving party, and Ether amount. You can compose these intuitive instructions into sophisticated programs.

The last part is a list of cryptographical signatures that represents approvals of respective parties. Unless all parties provide their signatures, Formula cannot be successfully executed on the Ethereum network.

Formula is always settled in a single Ethereum transaction. Formula is always executed in full or not at all.

Building blocks

The first-ever release of Crypto Formulas supports three main types of Ethereum based assets. In principle, these types are 1) currency for paying blockchain’s fees/gas, 2) Fungible tokens (all tokens are alike), and 3) Nonfungible tokens (each token is unique). In reality, while running on the Ethereum network, the first type is Ether. The second and the third types are represented by Ethereum smart contracts implementing standards ERC20, and ERC721, respectively.

The beauty of this concept is that it enables using virtually any asset because any smart contract on Ethereum with ownership capabilities can be wrapped to Fungible or Unfungible token smart contract and then be used in Formula. That is if the asset is not supporting the ERC20, or ERC721 standards already. In the next versions of Crypto Formulas, there might be support for more types of Ethereum assets that will become popular on Ethereum.

The initial set of instructions includes Send Ether, Send ERC20 tokens, Send ERC721 token, Pay fee, and Set time constraint. Even these basic instructions cover many common situations, such as several flatmates pay rent together (multiple senders, one receiver); A company paying employees’ salary (one sender, multiple receivers); a person wanting to trade collectible card for Ether with a friend (one sender of Ether, one sender of collectible), and others.

How to use it

To start using Crypto Formulas, create a new or clone an existing Formula. Fill participating Ethereum addresses and configure desired operations. Using section called Analysis, make sure there are no obstacles in executing Formula. Then ensure that all parties required to co-sign Formula signed it. After that, anyone can execute Formula by relaying the transaction to the Ethereum network.

You can see the complete workflow of some of the most common use cases in the videos on the project website. There is also a list of popular use cases that you can clone and customize instead of starting from scratch. Once you have created some Formulas, you can also clone them or share their design with others. You are welcome to discuss how to design your Formulas on the forum in the Discord channel.

After you successfully relay Formula to the Ethereum network and it is confirmed you can withdraw all your Ether from Crypto Formulas smart contract and cancel all approvals on 3rd party contracts for maximum security. If you plan to participate in more Formulas, and you trust the Crypto formulas smart contract code enough, it might make sense to keep Ether inside the contract and leave approvals intact for some time.

The easiest way to start is to clone a use case template.

Trade negotiating

In situations where you don’t know addresses of some parties — for example, when you plan to offer trade to multiple people — you can select Endpoints during Formula creation that can be filled anytime after you save Formula. In this case, you, as the author of Formula, will see one additional link for each unfilled Endpoint in the Formula overview that leads to webpages where the particular Endpoints can be filled in (or changed). You can send these edit links to respective counterparties or share them publicly on the internet. Anyone(!) with the knowledge of this edit URL can fill their address. After any counterparty fills their address, you will see this address in the Formula overview after you refresh the page.

When Ethereum addresses of all parties are known to you during a Formula creation, it is preferred to fill them right away. That is the most secure approach as none of the parties can change their address later and cause (un)intentional confusion.

When multiple parties are about to send assets, they need to make these assets available to the Crypto Formulas contract. Only then can Formula be executed — atomicly. In practice, you need to send Ether to the smart contract and approve manipulation of respective amounts of ERC20/ERC721 tokens when used in Formula. On Formula’s detail, there is the Analysis tab where you can overview the current situation and make everything right before you relay Formula to the Ethereum network.

Fees

A low fee is charged for executing Formula. Each operation used in Formula costs a small fixed fee unrelated to the value of funds transferred. There exists an instruction Pay fee that must be used in every Formula. This instruction lets you decide who will pay the fee, in case multiple parties participate in Formula and informs you about the total fee value at all times. A fee is paid only when Formula is successfully executed on the blockchain — you can create, clone, and browse Formulas on the website for free.

Versioning

In the future, Crypto Formulas will be improved with new types of instructions, security enhancements, and improvements in Formula creation (including social interactions). The project’s website can be upgraded frequently without much hassle, but changes in the settlement layer — Ethereum smart contract — will be upgraded in bigger, more thought-through, and tested wholes.

In the Ethereum smart contract design, a challenge exists on how to ship upgrades. The compromise between security and flexibility must be found. There is a popular way to upgrade smart contracts via Proxy pattern, where the main contract is merely resending received transactions to the current implementation contract that can be changed at anytime. Such an approach enables instant upgrades without requiring its users’ consent with the new rules. It can be beneficial because users are not requested to do any action (thus, saving Ethereum gas) to stay on the newest version. Unfortunately, it gives ultimate power to the entity (usually the author of the smart contract) that can release new upgrades. That is because the new version of smart contract may contain malicious code stealing (all) assets in the contract’s possession. That somehow defy blockchain philosophy of trustless control of your funds at all times. Also, all upgrades are mandatory for the users and using of an older version of the contract is impossible.

Crypto Formulas is trying to be as secure and transparent as possible for its users. That’s why the more conservative approach has been chosen. Each version is deployed into the Ethereum network as a separate smart contract. Smart contracts’ code cannot be changed in the blockchain, and the author of Crypto Formulas (that’s me :-)) cannot manipulate with your funds. Every smart contract is pointing on to the next version (except the newest one obviously), thus creating Linked list of versions. The author, or more precisely by-that-time owner of the Crypto Formulas smart contract, can do only two things with the contract. Redirect pointer to the next version of smart contract, or mark the version as (possibly) insecure for everyone to see on the blockchain (see in source code). Users are recommended to revoke all approvals and remove all funds from the version marked as insecure. Users will be informed if security compromise is discovered.

The huge upside of the chosen approach is that users are in the control of their assets all the time, and they can freely decide which version they want to use. The downside of this approach is the need to send all assets from one version (represented by separate smart contract) to the other when changing version, ultimately costing some Ethereum gas.

Future

There are already a lot of plans for future improvements to Crypto Formulas to make it even more useful for everyday interactions with crypto assets. Here are some of them.

Give users the ability to list their Formulas publicly on the Crypto Formulas website, browse them, and participate in them. At this point, the project will have DEX features that will be improved furthermore by connecting with 3rd party liquidity providers.

Formulas that can be created for escrow-like service today are limited in what they can achieve because there is no way to lock funds in the Crypto Formulas smart contract. Creating a lock mechanism will give users the option to voluntarily lock their funds in the smart contract until an agreed condition is met. That will allow Escrow agent many new possibilities.

In late 2019 we have seen the inception of an almost-risk-free way to earn more cryptocurrencies by participating in Flash Loan pools. The users will be given the option to participate in such pools with their funds waiting in the Crypto Formulas smart contract while still being available to be used in Formulas anytime. Maybe even new instruction letting you take flash loan might be created.

Of course, there will be more polishing and other improvements inspired by users’ feedback.

Keep in touch

If you want to know more about Crypto Formulas or want to leave very appreciated feedback, please:

  • check out the website and sign up to newsletter,
  • follow the blog for more insights,
  • join the Discord channel to discuss the project, share Formulas, or get advice,
  • and most importantly, start using it today!

For more technically oriented folks, there’s smart contract’s source code on the GitHub under GPL license. Ideally, you can Buidl [sic] something on top of it. You can also report issues on the GitHub. By the way, the smart contract lives at 0x26b054b0Fa823C275eb5Ab02dfB7a95A31670d26.

In case you are feeling generous and want to support the project, you can send a donation to:

  • BTC: 3L7UEAFmtzPiToAwueWen7UC1cDmXNCzfi
  • ETH: 0x034602018d4A8A53247E77eA8A26C80Fb6B4A958
  • ETH Classic: 0x034602018d4A8A53247E77eA8A26C80Fb6B4A958

--

--