How to find edge cases with echidna

© Jarrod Calati/Shutterstock
© Jarrod Calati/Shutterstock
Oh, hi!

Coding Smart Contracts is not for the faint of heart.

Very recently, I participated in making the Yield Protocol go live. For those that haven’t heard of it, it is a fixed-rate borrowing and lending platform in Ethereum. It also implements mathematical formulas that are at the edge of what it is possible for a smart contract.

The Yield Protocol is also a deploy-and-forget platform. Once we went public we had no way of stopping users interacting with our software, and no way to fix any bugs in the core contracts.

We could go up like a rocket, and then explode. …


Unlocking Ethereum for the masses

Image for post
Image for post

Everyone talks about “gas-less” Ethereum transactions because no one likes paying for gas. But the Ethereum network runs precisely because transactions are paid for. Then, how can you have “gas-less” anything? What is this sorcery?

In this article, I’m going to show how to use the patterns behind “gas-less” transactions. You will discover that although there is no such thing as a free lunch in Ethereum, you can shift gas costs in interesting ways.

By applying the knowledge from this article, your users will save on gas, will enjoy a better UX, and even build novel delegation patterns into your smart contracts. …


How to make your smart contracts cooperate safely

Image for post
Image for post
Ready to deploy

All but the simplest of Ethereum applications are composed of several smart contracts. This is because of a hard limit of 24KB in any deployed contract, and because your sanity will slip away as the complexity of a smart contract grows.

Once you break down your code into manageable contracts you will certainly find that one contract has a function that should only be called by another contract.

For example, in Uniswap v2, only the contract factory is supposed to initialize a Uniswap Pair.


A How To For Smart Contract Developers

Image for post
Image for post
Photo by Markus Spiske from Pexels

When you vote for something, how do you know that anything will actually get done? How do you know that promises will be kept?

In this article, I’m going to offer a glimpse into how blockchain can change democracy. With a blockchain democratic process, promises become actions.

I’m not going to say that we can or should do away with politicians and install a technocracy, but I’m going to show how to run a voting system where the proposals get automatically enacted if the voting passes.

You could call it unstoppable democracy.

Conceptual Design

To start, please let me set the scene with two smart contract…


Three example configurations for the new OpenZeppelin access control contract.

Image for post
Image for post
Photo by Scott Webb from Pexels

Restricting access to authorized users is really important in smart contracts. With $1 Billion locked in DeFi applications, you would really hope everyone knows what they are doing.

Recently, I collaborated with OpenZeppelin to refactor the access control in their widely used openzeppelin-contracts repository. If you have ever coded a smart contract, most likely you have inherited from their code.

In this article, I’m going to give you a walkthrough of how to use the revamped AccessControl.sol to restrict access to your smart contracts. I’ll do this through three examples.

But first, let me tell you the story of how we got here. Please feel free to skip the next section if you are not interested in how this contract came to be and only want to learn how to use it. …


If it is not going to be used by a smart contract, dump it in an event

Image for post
Image for post
All that data, neatly stored.

Anyone that is coding smart contracts as database tables is getting it wrong. That was me as well, until very recently.

Developing blockchain solutions requires you to think differently about data, about control and about privacy. Some of the details are easy to grasp, such as currency being little more than a table of balances and a few methods to operate on them. Some details are more complicated, such as the fact that you are building a solution that you might barely control.

One detail that eluded me until recently is what does exactly mean that data in a public blockchain is, well, public. Looking for a mechanism to easily report on transaction history I stumbled on a very elegant way of providing exactly that while making painfully clear how careful one has to be with data privacy. …


Put tokenized items for sale in a decentralized classifieds board

Image for post
Image for post
Photo by Ethan Brooke from Pexels

In this article, I’m going to show you how to code Craigslist for the Ethereum blockchain.

Before Gumtree, eBay, and Craigslist, classified boards were mostly made of cork or paper. There were classifieds boards in school corridors, newspapers, streetlights, storefronts.

All that changed with the internet. The number of people that could see a specific classified board multiplied by many orders of magnitude. With that, the markets they represent became much more efficient and scaled to global size. eBay is a massive business that traces its origins to these physical classifieds boards.

With blockchain these markets are set to change once more, let me show you how. …


Coding data structures in Solidity is weird and beautiful.

Image for post
Image for post

A few months ago I implemented a Linked List in Solidity for a client. More recently I decided that I might take on implementing a Fast Limit Order Book in Solidity as a pet project (aren’t nerds fun!) and Linked Lists appeared again.

As I recently wrote in an article about when to use different data structures:

Linked Lists are your data structure of choice when you need to preserve the insertion order, and also when you want to insert in arbitrary positions.

I love coding basic building blocks and no one seemed to have done this one*, so I took to it happily. …


You have a vision, now you need a roadmap.

Image for post
Image for post
Miguel Henriques — Unsplash

I am not afraid of storms for I am learning how to sail my ship.

— Louisa May Alcott

You have a product in mind which you want to build for your customers. But you have no experience building the product, and development will cost you a million dollars. How are you going to get the money? Will your customers love it? Will they buy it? You, of course, have no idea.

So, what will you do?

Like other established startups of the past (Dropbox, Uber, Slack), or like some of the people I’ve worked with, you should start by creating one or two proof of concepts (PoCs) — and after that, a minimum viable product (MVP). …


Including Solidity smart contracts to get you started.

Image for post
Image for post

People always fear change. People feared electricity when it was invented, didn’t they? People feared coal, they feared gas-powered engines… There will always be ignorance, and ignorance leads to fear. But with time, people will come to accept their silicon masters. — Bill Gates

Introduction

The energy industry contains some of the most valuable use cases for blockchain technology. Blockchain works best when dealing with decentralized markets, and with the advent of renewable microgeneration, the energy markets are rapidly becoming just that. …

About

Alberto Cuesta Cañada

Blockchain Architect | Distributed and High Performance Computing Expert | Chaotic and Complex Systems Fanboy

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store