The Rundown on Divi’s Specialized Smart Contracts

July 31, 2023

Some unique magic in the Divi Blockchain

Introduction

I want to start by asking you a couple of introspective questions. How do you learn best? 

Once you think about that question, then ask yourself, who can you trust to have learned something better than you? 

Let me propose a learning hierarchy as a concept. This isn’t pop psychology, it's just a model I tend to use which helps me understand if someone is speaking from full knowledge and experience, or if I am speaking with someone who has a terse understanding of a concept.

Most people will learn something by reading about it (or maybe watching a video on it). The great majority of learning is done this way, it’s extremely efficient and can be done by almost anyone with basic reading skills. This is likely to be the lowest effort required to learn something. And frankly, in many cases, this is limited to tweet or headline reading. It has a pretty big problem, it’s not really learning, It’s just making yourself comfortable

Higher on the ladder are people who will ask questions about the material, and dive down for answers, which will usually also be read or seen in a learning platform. Further than this, someone might already have significant expertise in similar fields and have also done a deep dive into the subject, which allows them to have a greater understanding of the subject than someone armed with only unrelated knowledge.

At the final step on this ladder, there may be someone with knowledge in multiple related fields, but who has also done work in the present subject, solved problems, performed logical derivations, or just took something apart and put it back together in a better condition. 

Who do you trust to fix your car? Someone who has only read about cars in a book, or do you trust someone who has read about every aspect of a car, driven cars, and taken apart a car and put it back together in a better way?

Why am I talking about this? Because the Divi blockchain is being rebuilt by someone who has strong knowledge in multiple related fields, who has dived deep into mathematics, cryptography, and blockchain, and who has gone into our codebase, taken it apart, and put it back together again in a far improved fashion. And the result is having one of the cleanest and extensible blockchain code bases in the market, as well as being able to provide new features that don’t exist elsewhere. Enter Specialized Smart Contracts (SSCs) on the Divi blockchain.

What is a Specialized Smart Contract?


Divi was originally just a couple of forks away from Bitcoin and nothing more. Now it is truly unique and clean. Fundamentally many Bitcoin features are laden into the Divi core,

some always have been.

Bitcoin already has basic scripting capabilities, which are incomplete (unlike, for example, Solidity, the programming language used to create smart contracts, which is Turing Complete.) Most commonly, in practice, this means that the Bitcoin scripting language can not perform loops or recursion, as well as a few other things. Thus even though the extremely complicated scripting language has been made easier with Miniscript, programming them is still exceedingly difficult for basic programmers, and using them is almost impossible for your average crypto enthusiast.

The problem with script addresses is that even if they are very flexible, they are also harder to use than regular addresses because you need to back up the scripts in a similar way that you would need to back up the private keys in a regular wallet (among many other things that also make them difficult to use). If now you had to back up some stuff other than your seed, then it would make it difficult for the general crypto-using public and result in loss of funds. It’s not the Divi way.

The solution for making this easier on Divi is to provide skeletal structures for some basic scripts that function on the Divi blockchain that anyone can use. Thus Specialized Smart Contracts are Divi Developed templates for using script addresses, this way a user can have smart contract capabilities, without needing to know about complicated script addresses. In Divi, we have three examples: Vaults, Escrow, and Subscriptions.

Examples of Specialized Smart Contracts

Vaults were the first example of the Divi Specialized Smart contract. Vaults can be set up manually or using Divi Lab’s one-click technology. As a result, you get cold wallet security, while being able to earn as if you were running a hot wallet.

Escrow is a simple concept. If Alice wants to pay Bob, then Bob will want assurances the money is coming. Without crypto, Alice and Bob would have to ask Charlie, whom they both trust, to hold the money. With crypto, they don’t need to trust anyone. Alice puts the funds in a script address with conditions for release. Bob can then see that the funds are there, and he just needs to perform the service or give Alice the thing she wants. Upon the conditions being met, Alice signals the script to release the funds into Bob’s control.


Subscriptions are similar. Alice hires Bob to provide website services. She runs a script to put funds in each of X script addresses which are cryptographically linked. She gives Bob read access to them so he can see all the funds are lined up for a contract length. Each month (for example) funds are released to Bob so he can continue providing his service. 


There are a lot of questions that immediately come to mind about these features, like “What if Alice later hates Bob’s work?” These will be dealt with in future articles.

Why now?


If Bitcoin already had scripting functionality, why couldn't these features have been delivered earlier? Answer: Masternodes.

With the masternode network in place, the entire ecosystem has been prone to network instability in the form of unintended forking (which, by the way, has also improved greatly since the Blockchain Mechanic smoothed out the code base). But eliminating most of the risk concerning forking is required because if people perform escrow or subscription transactions, and a long-lived fork happens, it will be very difficult to understand what happens to the funds. Better to eliminate the problem altogether and then offer the features.

Vaults, however, were launched before the sunset of masternodes. In fact, they have been out for years! It was felt that recovering from a potential fork, with a vault in place was a far lower risk, than having script-based addresses holding people's funds. Thus we were able to release vaults but preferred to wait until masternodes were not a risk factor to the network, for more Specialized Smart contracts to come on the scene.

                                    

Example Case : Alice, Bob, and the Power of Divi Specialized Smart Contracts

In a world where blockchain technology is swiftly evolving, Divi Blockchain unveils its state-of-the-art Divi Specialized Smart Contracts, with the revolutionary 'Vaults' leading the way. Thanks to Divi's one-click technology, Alice, an enthusiastic crypto-trader, can effortlessly set up a Vault, enjoying the safety akin to a cold wallet while reaping the benefits of a hot wallet.

The story of Alice's transactional journey within the crypto space becomes even more captivating when she encounters Bob, a service provider. In a traditional financial setting, they would need to involve a trusted third party, Charlie the Escrow Agent, to hold the funds, creating an extra layer of complication, trust, and fees. Alice and Bob can use the Divi Smart Escrow to toss the archaic model aside.

In this straightforward process, Alice locks the funds on Divi Blockchain, using a Divi Smart Escrow contract, set with predetermined conditions for release. And Bob can easily verify the funds and know they are kept secure, giving him the confidence to deliver the agreed service or item to Alice. Once Bob fulfills Alices' request, Alice triggers the Divi Smart Escrow contract, releasing the funds directly into Bob's control. Alice and Bob never need to trust one another and certainly don't need Charlie, the Escrow Agent.

The plot thickens as Alice decides to employ Bob for website services on a long-term basis. Divi Smart Subscription is employed. Alice prepares a Divi Smart Subscription to deposit funds into various script addresses that are cryptographically linked. And like before, Bob can easily verify the funds and know they are kept secure, giving him the confidence to deliver services and be paid and the agreed-upon schedule. No Escrow agent or 3rd party application is needed.

Each month, as part of a well-oiled machine, the Divi Smart Subscription contract dispenses the funds to Bob, ensuring he continues to provide unhindered services. The use of subscription-based smart contracts mitigates any risks, encouraging a seamless relationship between Alice and Bob.

Naturally, one might wonder, "What if Alice becomes dissatisfied with Bob's work?" These potential difficulties promise to make Alice and Bob's journey, even more enthralling, promising future stories filled with intrigue and exploring uncharted territories in the realm of Divi Specialized Smart Contracts. Stay tuned for more gripping tales of Alice and Bob.

This article is part of a series of articles regarding the migration to Divi 3.0. It will be executed in steps over several weeks, allowing for a seamless and efficient transition process. We urge you to pay close attention to the forthcoming updates, as they will contain vital instructions for the migration. There will be a gamification element incorporated, so we encourage you all to stay engaged! This should make the process more engaging and a rewarding experience for all node owners and the Divi family. You can find the introduction article as well as the list of articles of the series on this link.