So you want to start coding blockchain? … continued [1, 2 & 3]

One of the challenges for associations and organizations that help the persons in need is how to justify to donors the use of the funds that are collected. The blockchain technology can reduce drastically the cost of collecting, maintaining and analyzing these data. It can also facilitate many other tasks, as you’ll see.

(April 2021) This is the second article of a series to introduce you to blockchain coding and to make you feel at home among the blockchain community. In the same time, it will introduce you to Machu Picchu, Data as a Public Service.

Machu Picchu is a collaborative open source initiative. It aims to use the Ethereum blockchain to share “Data as a Public Service” among all the helper organizations that provide support and benefits to the persons in need. Machu Picchu is designed to be a library of reusable components that can be leveraged by IT staff of helper organizations for their own needs. Because blockchain programming is still alien to most of these persons, this series of articles is a step-by-step introduction to show how simple it can be to use blockchain, and motivate these persons to adopt Machu Picchu.

This article is for you if…

  1. you are curious to learn if and how the IT teams of the helper organizations can take advantage of the blockchain to reduce operating costs while helping better;

This series of articles is less for you if you want only to know philosophically how the blockchain can change the world. But you may still be interested to read because you’ll also see the “why” of the steps, contrary to similar tutorials that focus solely on explaining the “how”.

What is our roadmap?

I did recently a previous article that describes how efficient are the modern development tools, with a hands-on example to code and deploy your own web server and its client in only 10 lines of code. Let’s call it Step 0. All the following articles of this series will end up with a live demo. With the last one you’ll have your own blockchain-based demo application published and accessible worldwide. All for free, nothing to pay.

Step 1: (this article) Install Metamask, feed some ETH (name of the cryptocurrency we use), run Machu Picchu blockchain demo of Pepito Disguises.

Step 2: Install nodeJS, truffle, git. Download the example source code from github, compile and deploy with truffle a complete blockchain application, locally on your PC.

Step 3: Install VSCode, modify this application to add your name. Deploy the backend on a public testnet and the frontend on a public web hosting.

Update of July 2021: Step 2 and Step 3 are addressed by this free course from ConsenSys Academy. It is very comprehensive. No need for me to do yet another tutorial post on the subject.

Expected outcomes

  1. After doing step 1, you’d be familiar using blockchain with your own browser.

Let’s start and install Metamask browser extension

Metamask is a browser extension (a “plug-in”) that simplifies doing transactions with the blockchain. It brings you 4 functions.

From right to left:

  1. it connects your browser to a blockchain that you select,

When Metamask was introduced in April 2016, it was a big improvement to the existing tools at that time. It simplified considerably access to the blockchain by suppressing the need to run a node. But because it handles 4 different functions, it is still confusing for a newcomer today and this is a barrier to blockchain adoption. In the next section, you’ll see the “why” of the actions required from you when you install Metamask.

Metamask installation video on YouTube

There are many tutorial videos explaining how to install Metamask. Follow the instructions of this one, https://youtu.be/WAStJtjYI_c, the shortest and one of the most up-to-date.

Before you start installing, let’s watch the video and focus on the 2 main decisions you need to make and for which no video give you the elements of decision: what is the use of a seed phrase (1'24") and what is the use of a password (1'41").

  • the seed phrase: this set of 12 random words is the backdoor to the Metamask “account generator”: the same set of 12 words will always generate the same pairs of cryptographic keys. If someone is able to use your seed phrase to install a Metamask on another computer, this person will have the same control as you do on the accounts you have generated in your Metamask. Scary. So keep these 12 words secret.

What does this mean for you when you install Metamask?

  • start by downloading the extension, guided by the tutorial. Attention Metamask is incompatible with Safari. It is compatble with Firefox, Chrome, Brave and Edge.

What is a blockchain account?

In your daily life, you have accounts that are managed by banks. When you change bank you change the account. Don’t keep this same idea in the blockchain world.

In the blockchain world, an account is simply a pair of public and private keys. An account number is the public key. You can use the same account number in all blockchains that are based on the same core code: the Ethereum main net (the main blockchain), the Ethereum test nets, the Binance Smart Chain, the CELO blockchain, the MATIC network, the TOMOChain, the RSK Network, the xDAI Chain and many more. Each blockchain ignores what this account has, on other blockchains.

To summarize:

Once installed, Metamask will show its first account and will select the Ethereum main net. You can still use this account on any other net. For our purposes here, let’s use this account on the testnet Rinkeby and use its cryptos to pay the transaction fees of the Machu Picchu demo of Pepito Disguises.

Feed some ETH cryptos in the first account

You can consider each blockchain as a distinct Monopoly party. Money on one party has no value in the other parties. Similarly, the ETH in a net do not exist on any other nets. ETH on testnets are for demos. They have no value and can be obtained for free from dedicated web sites call “faucets”. You can ask the faucets for some ETH to feed your new account in Metamask.

Faucets must protect themselves from being overloaded by robot requests. Some do it by making sure you are a real person. Others do so by sending very small amount at each request. With these latter faucets you have to do dozens of requests before having enough.

The following faucet checks that you are a real person by requiring you to start by posting on Twitter or Facebook the address of your account to which it will send ETH to (don’t worry, there is no risk: there is no real value at stake). Once the social media post is published, paste the link of that post on your request to the faucet: https://faucet.rinkeby.io/

The following Rinkeby faucet doesn’t check social media but gives you a very small amount: http://rinkeby-faucet.com/

Else at last resort, ask me. We’ll discuss about your interest and I’ll send you 0.1 Rinkeby ETH.

Now, your first blockchain transactions on Rinkeby

Once you have received the cryptocurrency, you are ready to do your first blockchain transaction. In your browser with the Metamask extension, open this URL: https://pepito-disguises-rinkeby-v011.netlify.app/ Notice that the form factor of Pepito’s display is already designed for a vertical mobile screen ❤️

This is a gamified version of how a helper organization can on-board a person in need, store and retrieve from the blockchain the personal data of this person.

  • Click on “Get blockchain interface & Pepito instance”. When you do it for the first time, Metamask will ask you to confirm that you accept queries from this web page. Accept. This dialog will not appear anymore.
  • Click on “Store disguise on blockchain”. A pop-up will appear for you to accept to pay a transaction to create a disguise. After you accept, a second pop-up will appear asking you to accept a transaction to store the parameters of this disguise on the blockchain. These 2 transactions altogether will cost you around 0.03 ETH but remember that we are using free and worthless cryptos, for demos only.

Here is a video showing the actions described above. The right panel that is shown here is the developer console to check the response of the blockchain. You don’t need to display it on your browser.

What have we learned?

  • Using the blockchain can be as simple as using the Internet, once you get the right mindset.

Where are we going?

Plans for you

For you as IT staff of a helper association of organization, if you are interested, the next steps are:

  1. Article 2: we’ll together set up a development environment to download and deploy locally a simple but complete blockchain application.

You’ll need only a web browser to operate the application once deployed. The cost and the pain of operations are drastically reduced. You don’t care about hosting a server and a database. Your application is on the cloud and on all nodes of the blockchain community.

Plans for Machu Picchu

Machu Picchu is continuing its development. Its plans are:

  1. Store the disguise data on IPFS. IPFS is a distributed storage system, in synergy with the blockchain.

Stay tuned. The Internet and the blockchain are bringing the power to the people.

Machu Picchu — Data as a Public Service