Smart contracts for the English speaker

Smart contracts for the English speaker

While regular contracts have presumably been in use since alphabets came into existance, the concept of smart contract has only been around for a couple decades and it’s inextricably entangled with blockchain technology.

The wording smart contract was first used by cryptographer Nick Szabo in 1997, who in the following year designed a mechanism for a decentralized digital currency he called bit gold. While he never implemented it, bit gold has been named “a direct precursor to the Bitcoin architecture.”

Over a decade later, the Ethereum Yellow Paper authored by Gavin Wood, co-founder of Ethereum (the second largest cryptocurrency after Bitcoin), describes smart contracts as “algorithmic enforcement of agreements” and adds that “the future of law would be heavily affected by such systems.”. The paper further describes how smart contracts can be written using Solidity, a “language library with similarities to C and JavaScript” that progressively gained momentum as the Ethereum platform grew.

But what can I use a smart contract for and what does it look like?

One interesting use case is contained in the patent filed by Nasdaq about a smart contract based newswire, that “releases” information only at the scheduled time or the IBM-Maersk joint venture that aims to make global shipment paperless by using smart contracts instead of the regular paper trail. A smart contract could be for example used to make sure that a payment is automatically released, immediately after a certain event has taken place; another application is a voting platform where both voting and counting is processed by smart contracts and stored in an tamper-proof blockchain, just like Decode’s “Barcelona pilot”.

If we get a closer look at Solidity, a simple smart contract that sends crypto-currency, looks more like software code than a regural contract:

contract GavCoin
{
mapping(address=>uint) balances;
uint constant totalCoins = 100000000000;
/// Endows creator of contract with 1m GAV.
function GavCoin(){
balances[msg.sender] = totalCoins;
}
/// Send $((valueInmGAV / 1000).fixed(0,3)) GAV from the account of $(message.caller.address()), to an account accessible only by $(to.address()).
function send(address to, uint256 valueInmGAV) {
if (balances[msg.sender] >= valueInmGAV) {
balances[to] += valueInmGAV;
balances[msg.sender] -= valueInmGAV;
}
}
/// getter function for the balance
function balance(address who) constant returns (uint256 balanceInmGAV) {
balanceInmGAV = balances[who];
}
}

More advanced smart contract languages are being used today, for example Formality, that allows for “formal proofs” (it can prove that what is expressed is what is executed), still features a programming language-like syntax, making it practically unaccessible to non-programmers.

What is Zenroom and what makes it special?

Zenroom is the brainchild of Dyne’s founder Denis “Jaromil” Roio, whose interest in cryptography spans for over a decade and involvement in cryptocurrency is marked by several sizeable commits to the Bitcoin source code, while it was in its infancy. Zenroom provides the cryptography and the sensitive data manipulation for the whole Decode project, implementing the Coconut credential scheme developed by UCL in 2018.

Zenroom implements an interpreter of natural language (read: “plain English”) based on BDD, making smart contracts look way more like the pen and paper contracts we are used to. A simple Zenroom smart contract that requests a cryptographic keypair and stores it locally, can be written in three lines:

Given that I am known as ‘Citizen’
When I create my new credential request keypair
Then print all data

A more complex smart contract, allowing to vote for a petition, where the eligibility is checked anonymously by a digital authority and the result is stored in a blockchain, would look like this:

Given that I am known as ‘Citizen’
and I have my keypair
and I have a signed credential
and I use the verification key by ‘State Digital Authority’
When I aggregate all the verification keys
and I sign the petition ‘To not build the wall’
Then print all data

While every line of these smart contracts corresponds to several lines of programming language, the contract is easy to understand by any English speaker and can be written with minimal training, as defined in the implementation specifications of Decode’s Barcelona Pilot. Most important, while all other smart contract languages are executed inside a Blockchain, Zenroom is a standalone virtual-machine so it can run in a Blockchain-agnostic environment and can use a file or a regular database for input/output, optionally along with a Blockchain.

Zenroom also stands out for its capability to operate “permissionless” (in any moment a new blockchain node should be able to interprete the language and malevolent code should not affect the system) and for being “deterministic” (any node in the network can verify results of contracts executed by other nodes). Zenroom is written in C language: it doesn’t need specific hardware and can run on a variety of devices, including PCs, mobile phones, Raspberry Pi, and ultra low voltage ARM Cortex M boards.

https://zenroom.org/
https://zenroom.org/

Tune in to the discussion 💬

(These services are bridged: join your favorite and reach them all)

🗨️ Matrix
🗨️ Telegram
🗨️ Discord

Support Dyne 🫱🏿‍🫲🏾

🪙 Bitcoins: bc1qz9wz2f9swcefra2tfrhk4fx49evqsv03m9nx4l
Ko-Fi
🍴 Github.com
🧁 LiberaPay
🍥 Patreon.com

Follow Dyne.org 🗞️

Social Media everywhere!

🐘 Mastodon
🎬 Peertube
🐭 Lemmy
📸 Instagram
🐦 Xitter
👔 Linkedin
🪞 Facebook
✍️ Medium

Dyne.org

Dyne.org

Dyne.org is a digital community & free software foundry. We share tools, practices & narratives that empower artists, creatives & citizens in the digital age. - Website
Haparandadam 7-A1 1013AK Amsterdam
Andrea D'Intino

Andrea D'Intino

Co-Founder at ForkBomb | Building components and solutions for cryptography, identity, blockchain interop and DPP, based on the Zenroom stack. - Website