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…
- 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;
- you are ready to do some hands-on coding to see how it works;
- you want to start doing so in the most direct way.
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
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.
- After doing step 1, you’d be familiar using blockchain with your own browser.
- After executing step 2, you’d get acquainted with blockchain development tools and you’d have deployed locally a complete blockchain application (frontend and backend) on your own computer.
- After doing step 3, you’d have unrolled the complete production chain, including the public deployment of a blockchain app with your name on it. You can now plan coding by yourself a blockchain dApp and deploy it publicly. Or maybe contribute open source code to Machu Picchu? ❤️
- The last effort would be to use
gitto save your code on
githuband show the world that you are a blockchain programmer. For this, you are on your own. Feel free to Google the numerous
gittutorials that are available.
- After that, you are ready to take full benefits of a paid course such as ConsenSys Academy Bootcamp or Eat The Blocks if you want to progress further.
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:
- it connects your browser to a blockchain that you select,
- it authorizes spending by signing a transaction on behalf of one of your user accounts and submits this transaction to be broadcast to all nodes and have the whole community remember it,
- it generates and manages amounts stored in as many user accounts as you decide, all owned by you,
- it authenticates and authorizes you to use the 3 above functions, from this specific Metamask installation.
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.
- the password: this is a classical means to authenticate yourself every time you open your Metamask. If someone knows your password and accesses your Metamask, this person can make this Metamask reveal the backdoor –the embedded seed phrase– with the same disastrous consequences explained above.
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.
- at 1'24" of this video you are asked to decide whether you want to use an existing seed phrase or have a new seed phrase. Most users will choose to have a new seed phrase, that Metamask will create for them. Developers may want to reuse an existing seed phrase, to create a Metamask that is identical to an existing one. This is very useful for a developer who needs to check the compatibility of their code on several browsers, in several operating systems, using an identical Metamask for all of them.
- at 1'41" you are asked to create a password. It’s always a good habit to have a really strong password but this specially holds if you intend to put valuable cryptocurrencies in the accounts that you’ll ask this Metamask to create.
- at 1'51" Metamask displays a “Secret Backup Phrase” for you to copy and store securely. You’ll notice that its actually the seed phrase of 1'24". You understand why you need to secure it: it’s the “accounts machine”. With it, anybody can access your accounts generated with this seed phrase. Without it, nobody in the world can help you get access to your accounts.
- At 2'38" you see again this “Secret Backup Phrase”. Because it is critical, Metamask asks you to confirm the 12 words again in the right order.
- Once installed, Metamask automatically generates one first account which will be used to pay the transaction fees. You can create an infinite number of accounts with Metamask.
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.
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.
- Currently in April 2021, there are already 23 disguises publicly available on the Rinkeby blockchain. Type in the text box the number of the disguise you want to retrieve, for example the 7th one, and click on ”Retrieve this disguise from blockchain”. Retrieving a disguise is a cost-free transaction.
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.
- The mindset is that a blockchain account is different from a bank account. A blockchain account is a representative of yourself in the virtual world. A same account can be used in many communities (blockchains), but the virtual money it has in one community is worthless in all others, like with Monopoly.
- Note that the virtual money ETH on the main blockchain (mainnet) has an enormous value in our real world, only because we all have agreed so. No central power has decided that, contrary to paper money.
- Metamask is a browser extension for you to access the blockchain easily. It has an infinite account generator, the “seed phrase”. A same seed phrase will generate the same series of accounts. If someone has the same seed phrase as yours, this person will generate and use the same accounts as yours. Scary. You’re the only responsible of your seed phrase.
- Metamask has also a password to protect its use. A person who knows your password will be able to retrieve your seed phrase.
- After you installed your own Metamask browser extension and fed its first account with some currency in use in the testnet Rinkeby, you can play with the Machu Picchu demo, named Pepito Disguises. It is designed to simulate how you can use this testnet blockchain to on-board a person-in-need (create and store a Disguise) and retrieve this person’s data.
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:
- Article 2: we’ll together set up a development environment to download and deploy locally a simple but complete blockchain application.
- Article 3: we’ll code some changes and deploy on public (and free) servers the frontend and backend of this 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:
- Store the disguise data on IPFS. IPFS is a distributed storage system, in synergy with the blockchain.
- Port the frontend to a mobile-based browser. We plan to use React Native.
- Make the frontend usable even with a rudimentary cellular phone, the one that a person-in-need can afford, and have it cooperate with a smartphone of a chief of village to update the data on blockchain. The persons-in-need keep control of their personal data and can revoke the data at will.
- … and more. The final objective is to create a self-help community of persons-in-need, supported by helper organizations. Inclusive finance is the target.
Stay tuned. The Internet and the blockchain are bringing the power to the people.