CoviDapp with Tezos Blockchain
Tags: blockchain, react, tezos, smartcontracts
Published: 2021-03-22 09:09:47

---
title: CoviDapp with Tezos Blockchain
published: true
date: 2021-03-20 17:44:32 UTC
tags: blockchain,react,tezos,smartcontracts
canonical_url: https://medium.com/coinmonks/covidapp-with-tezos-blockchain-80d89fba88db
---

![](https://cdn-images-1.medium.com/max/1024/1*yWnNaoIZBhJb1TZXTXP0mw.png)

Tezos is a decentralized, open-source blockchain network that can execute peer-to-peer transactions and serve as a platform for deploying smart contracts.

CoviDapp was our first try to develop a blockchain-based corruptionless distribution for COVID-19 vaccines. The features of this Dapp are:

- Distribution of vaccines can be done in the systematic top to bottom approach.
- Hospitals/States with emergency cases/surge in cases can send in requests for more vaccines directly to the higher authority, and their request will be in priority of the higher officials, i.e., hospital requests are a higher priority for State Government Officials.
- As we all know, in a blockchain, every transaction is tracked, so all the vaccines that enter the chain through the central government are tracked all the way down to the hospitals receiving it, hence no chances of corruption in between the authorities.
- All the transactions for a specific hash address can be seen available publicly to everyone, to make the taxpayers see where their tax is being invested.

Let’s get to the building part!

#### Installing Thanos Wallet:

1. Our first step would be to install the Thanos Wallet extension. You can get that from [here](https://thanoswallet.com/download).
2. Once installed, create a new Wallet.

![](https://cdn-images-1.medium.com/max/1024/1*HUoP8-a5jsCfTcTlADY-8A.png)

3. For future use purposes, take the backup of your seed phrase and then continue.

![](https://cdn-images-1.medium.com/max/1024/1*DfH197DAltCtPZT9mPXCgA.png)

4. Now go to [Tezos faucet](https://faucet.tzalpha.net/) to get a Testnet account for testing the Dapp with Thanos wallet and download the JSON file.

![](https://cdn-images-1.medium.com/max/1024/1*T_9VaauiChZtPkGQomGv_Q.png)

5. Select import account and upload the Faucet file.

![](https://cdn-images-1.medium.com/max/1024/1*3Df527cqKCR9flstsFIytA.png)

After the confirmation, you will receive some amount of XTZ in Delphi Testnet account.

![](https://cdn-images-1.medium.com/max/1024/1*Ck6CRcI_oZ5ByaxIbv3eAg.png)

Now we are ready to build the CoviDapp!

### Building the Dapp

For building a Dapp we first need smart contracts. Smart contracts help in designing custom protocols for the transactions. Tezos smart contracts are based on [Michelson Language](https://www.michelson-lang.com/) and for a beginner, it will be really difficult to get started with it. So, to overcome this problem [SmartPy](https://smartpy.io/) is there which is a Python-based library specifically developed to design Michelson contracts. It has good [documentation](https://smartpy.io/reference.html/). Also, SmartPy comes with a web-based [IDE](https://smartpy.io/ide/) so you don’t have to install anything in the local system. Since we are designing a COVID-19 distribution system we will need to develop three different contracts, one for Central Government, one for State Government & one for Hospital.

All the codes are available in my CoviDapp GitHub Repository.

[sukesh2000/coviDapp](https://github.com/sukesh2000/coviDapp)

#### Designing a contract for Central Government:

There will be three main entry points in the contract,

1. For storing the requests from the State Government, this entrypoint will be triggered by the State Government.

{% gist https://gist.github.com/sukesh2000/6c360a158ae4c2acf728a3f128c46cd6 %}

2. For changing the vaccine count.

{% gist https://gist.github.com/sukesh2000/40aac31c87634d593612321c0ce14f33 %}

3. For transferring the vaccine, this entrypoint will trigger another entrypoint in the State Government’s contract which will update the vaccine count available with the State Government automatically.

{% gist https://gist.github.com/sukesh2000/d228a80f45bcaa3ca4a1baba683dbb2e %}

#### Designing a contract for State Government:

In the State Government’s contract, there will be four main entrypoints,

1. For updating the vaccine count. This will be triggered by the Central Government.

{% gist https://gist.github.com/sukesh2000/a6426d958c546b0107061adbaca59cc8 %}

2. For requesting the vaccines from the Central Government, this entrypoint will trigger another entrypoint in the Central Government’s contract.

{% gist https://gist.github.com/sukesh2000/b93e3d6d850011e01f2a85b71d16d340 %}

3. For storing the hospital’s request, this entry point will be triggered by the hospital.

{% gist https://gist.github.com/sukesh2000/003a9f905d7901f602bf4b3d3ef9933c %}

4. For transferring the vaccines to the hospital.

{% gist https://gist.github.com/sukesh2000/3dbbeab2fdef72895dc578d958b3a3f4 %}

#### Designing a contract for Hospital:

In the Hospital’s contract, there will be two main entrypoint.

1. For requesting vaccines from the State Government.

{% gist https://gist.github.com/sukesh2000/675f3952c215f956209cefc06bf3b213 %}

2. For updating the vaccine count.

{% gist https://gist.github.com/sukesh2000/69d832b0cb13c4a4a62a6b658a1a912d %}

Now we are done with designing the contracts for the Vaccine Distribution!

### Deploying the Dapp

For deploying the Dapp, we will first need to generate the Michelson Contract which can be done from the SmartPy IDE itself and then deploy the generated contract in Delphi Testnet. Once the contract is deployed our next step is to create a React App for deploying the Dapp on a web server. Since all the Javascript files contain nearly similar code I’ll be explaining only for the State Government’s website. To develop the React App you will need to main libraries, Taquito & Thanos Wallet.

1. First, we will need to create a config.json file which contains the configuration details of the contract. Update the config.json file with the contract address of the generated contract.

{% gist https://gist.github.com/sukesh2000/9311a2bdc9854720653cacae1fe8159d %}

2. Now we will need to create a JavaScript file that will be used to connect to the local Thanos Wallet by the Dapp.

{% gist https://gist.github.com/sukesh2000/30637c81b874a17fd58d778df2c0a50b %}

3. A Javascript file that will be used to interact with the contract and trigger the entrypoints.

{% gist https://gist.github.com/sukesh2000/1d55345d23eac31c192a61d4269a0f2e %}

4. A client-side application that will be used by the State Government hospital to interact with the Dapp. Code for the same can be found here.

[sukesh2000/coviDapp](https://github.com/sukesh2000/coviDapp/blob/main/src/StateGov.js)

A similar procedure can be repeated to develop the React App for the Central Government and the Hospital.

**Hurray, we are done with developing the Dapp that can be used to record the details of the vaccine that is being distributed!!!**

Furthermore, if you would like to display the details of the transactions happening between the Central Government, State Government & Hospital, you can use the TZKT API.

[TzKT API Documentation](https://api.tzkt.io/)

Code for the same can be found in my repository.

[sukesh2000/coviDapp](https://github.com/sukesh2000/coviDapp/tree/gh-pages)

This project was built by me during the [Python Week Hackathon](https://thepythonweek.tech/).

Special thanks to [Tezos India Foundation](https://tezosindia.foundation/) and [GD Soumya, Blockchain Developer Intern at Tezos India](https://www.linkedin.com/in/gdsoumya/) for helping us develop this Dapp.

Project Contributors:

- [Arnab Deep - East Singhbhum, Jharkhand, India | Professional Profile | LinkedIn](https://www.linkedin.com/in/arnabdeep/)
- [Sukesh Seth - Flight Systems Engineer - Student Copter Research Organization | LinkedIn](https://www.linkedin.com/in/sukeshseth)

> Join Coinmonks [Telegram group](https://t.me/joinchat/EPmjKpNYwRMsBI4p) and learn about crypto trading and investing

#### Also, Read

- [What is Margin Trading](https://blog.coincodecap.com/margin-trading)
- The Best [Crypto Trading Bot](https://medium.com/coinmonks/crypto-trading-bot-c2ffce8acb2a) | [Grid Trading](https://blog.coincodecap.com/grid-trading)
- [3Commas Review](https://medium.com/coinmonks/3commas-review-an-excellent-crypto-trading-bot-2020-1313a58bec92) | [Pionex Review](https://medium.com/coinmonks/pionex-review-exchange-with-crypto-trading-bot-1e459d0191ea) | [Coinrule review](https://medium.com/coinmonks/coinrule-review-2021-a-beginner-friendly-crypto-trading-bot-daf0504848ba)
- [AAX Exchange Review](https://medium.com/coinmonks/aax-exchange-review-2021-67c5ea09330c) | [Deribit Review](https://medium.com/coinmonks/deribit-review-options-fees-apis-and-testnet-2ca16c4bbdb2) |[FTX Exchange Review](https://medium.com/coinmonks/ftx-crypto-exchange-review-53664ac1198f)
- [NGRAVE ZERO review](https://medium.com/coinmonks/ngrave-zero-review-c465cf8307fc) | [Phemex Review](https://medium.com/coinmonks/phemex-review-4cfba0b49e28) | [PrimeXBT Review](https://medium.com/coinmonks/primexbt-review-88e0815be858)
- [Bybit Exchange Review](https://medium.com/coinmonks/bybit-exchange-review-dbd570019b71) | [Bityard Review](https://medium.com/coinmonks/bityard-review-7d104239be35) | [CoinSpot Review](https://blog.coincodecap.com/coinspot-review)
- [3Commas vs Cryptohopper](https://medium.com/coinmonks/3commas-vs-pionex-vs-cryptohopper-best-crypto-bot-6a98d2baa203) | [Earn crypto interest](https://medium.com/coinmonks/earn-crypto-interest-b10b810fdda3)
- The Best Bitcoin [Hardware wallet](https://medium.com/coinmonks/the-best-cryptocurrency-hardware-wallets-of-2020-e28b1c124069?source=friends_link&sk=324dd9ff8556ab578d71e7ad7658ad7c) | [BitBox02 Review](https://medium.com/coinmonks/bitbox02-review-your-swiss-bitcoin-hardware-wallet-c36c88fff29)
- [Ledger vs Ngrave](https://medium.com/coinmonks/ledger-vs-ngrave-zero-7e40f0c1d694) | [Ledger nano s vs x](https://medium.com/coinmonks/ledger-nano-s-vs-x-battery-hardware-price-storage-59a6663fe3b0)
- [Crypto Copy Trading Platforms](https://medium.com/coinmonks/top-10-crypto-copy-trading-platforms-for-beginners-d0c37c7d698c)
- [YouHodler Review](https://medium.com/coinmonks/youhodler-4-easy-ways-to-make-money-98969b9689f2) | [BlockFi Review](https://medium.com/coinmonks/blockfi-review-53096053c097)
- The Best [Crypto Tax Software](https://medium.com/coinmonks/best-crypto-tax-tool-for-my-money-72d4b430816b) | [CoinTracking Review](https://medium.com/coinmonks/cointracking-review-a-reliable-cryptocurrency-tax-software-5114e3eb5737)
- Best [Crypto Lending Platforms](https://medium.com/coinmonks/top-5-crypto-lending-platforms-in-2020-that-you-need-to-know-a1b675cec3fa) | [Leveraged Token](https://medium.com/coinmonks/leveraged-token-3f5257808b22)
- [BlockFi vs Celsius](https://medium.com/coinmonks/blockfi-vs-celsius-vs-hodlnaut-8a1cc8c26630) | [Hodlnaut Review](https://medium.com/coinmonks/hodlnaut-review-best-way-to-hodl-is-to-earn-interest-on-your-bitcoin-6658a8c19edf)
- [Bitsgap review](https://medium.com/coinmonks/bitsgap-review-a-crypto-trading-bot-that-makes-easy-money-a5d88a336df2) | [Quadency Review](https://medium.com/coinmonks/quadency-review-a-crypto-trading-automation-platform-3068eaa374e1) | [Bitbns Review](https://medium.com/coinmonks/bitbns-review-38256a07e161)
- [Ellipal Titan Review](https://medium.com/coinmonks/ellipal-titan-review-85e9071dd029) | [SecuX Stone Review](https://medium.com/coinmonks/secux-stone-hardware-wallet-review-15-discount-coupon-2020-7577032faa6e)
- [LocalBitcoins Review](https://medium.com/coinmonks/localbitcoins-review-6cc001c6ed56) | [Cryptocurrency Savings Accounts](https://blog.coincodecap.com/cryptocurrency-savings-accounts)
- Best [Blockchain Analysis](https://bitquery.io/blog/best-blockchain-analysis-tools-and-software) Tools | [Earn Bitcoin](https://medium.com/coinmonks/earn-bitcoin-6e8bd3c592d9)
- [Crypto arbitrage](https://medium.com/coinmonks/crypto-arbitrage-guide-how-to-make-money-as-a-beginner-62bfe5c868f6) Guide | [How to Short Bitcoin](https://medium.com/coinmonks/how-to-short-bitcoin-568a2d0b4ae5)
- Best [Crypto Charting Tool](https://medium.com/coinmonks/what-are-the-best-charting-platforms-for-cryptocurrency-trading-85aade584d80) | [Best Crypto Exchange](https://medium.com/coinmonks/crypto-exchange-dd2f9d6f3769)
- [How to buy Bitcoin in India?](https://medium.com/coinmonks/buy-bitcoin-in-india-feb50ddfef94) | [WazirX Review](https://medium.com/coinmonks/wazirx-review-5c811b074f5b)
- [Bitcoin exchange in India](https://medium.com/coinmonks/bitcoin-exchange-in-india-7f1fe79715c9) | [Bitcoin Savings Account](https://medium.com/coinmonks/bitcoin-savings-account-e65b13f92451)
- [CoinDCX Review](https://medium.com/coinmonks/coindcx-review-8444db3621a2) | [Crypto Margin Trading Exchanges](https://blog.coincodecap.com/crypto-margin-trading-exchanges)

> [Get Best Software Deals Directly In Your Inbox](https://medium.com/coinmonks/newsletters/coinmonks)

[![](https://cdn-images-1.medium.com/max/584/1*BoDnKUyK8p4hitHAJZ5Pdw.png)](https://medium.com/coinmonks/newsletters/coinmonks)

* * *