My Journey navigating the Web 3 Space
Join along as I familiarize myself with the nuances of building applications in the web 3.0 space.
A Brief Intro
I am primarily a Data Scientist and a backend developer. I am proficient in Python, C/C++ and have worked with TypeScript briefly in my internships.
Previously, my tryst with blockchain and cryptocurrency, topics that had greatly piqued my interest, had led nowhere. When I was made aware of this exciting opportunity to have hands-on experience with building blockchain-based applications, it seemed like a no-brainer for me to jump right in !!
Getting familiar with the Techstack
Blockchain, like AI, was a whole new field that I felt had the potential to orchestrate remarkable progress and usher in new possibilities of innovation and development.
With a swirl of uncertainty surrounding the state of crypto in India, there was always a chance that things might not pan out at all. But, a part of me couldn’t wait to get started and I kicked things off by familiarising myself with crypto-terms like decentralization of data, distributed ledger, smart contracts etc
As it turns out, the idea behind Web 3.0 is quite straightforward - take back the centralization established with Web 2.0 entities and decentralize everything, with greater transparency and utility
With Web 3.0 everyone, from people to machines and businesses will be able to trade data, information and work with global counterparts, without the intervention of a centralized authority
Bound by a layer of trust and immutability, inherent to the blockchain, Web 3.0 will fundamentally expand the scale & scope of both human and machine interactions far beyond what we can imagine today. These interactions, ranging from seamless payments to richer information flows, to trusted data transfers, will become possible with a vastly increased range of potential counterparties.
Bound by a layer of trust and immutability, Web 3.0 will fundamentally expand the scope of human and machine interaction.
A paradigm shift of this magnitude will enable a whole new wave of previously unimaginable businesses and business models: from global co-operatives to decentralized autonomous organizations and self-sovereign data marketplaces. Terms like Decentralised finance(Defi), NFTs or even the Metaverse, all of which have taken over our news feeds, is just the beginning.
Blockchain - New Data Ownership Dynamics
Personally, I have been a huge freak about protecting my data. I am well aware of the value of user data and sadly, current systems are not doing enough to secure it. There have been pockets of privacy-driven initiatives like DuckDuckGo, a contrarian approach to Google’s data hoarding search engine, but nothing that has gathered steam for mainstream adoption.
As a result, the onus of securing one’s data has fallen on the user.
With blockchain, I see a clear upending of the current user data ownership dynamics.
We can own our own data & digital footprints by using a provable digital scarcity of data & tokenized digital assets, a fascinating premise for people like me. This establishes implicit trust across the network and eliminates the need for explicitly trusting certain centralized entities and aggregators.
The blockchain is a new, exciting, powerful technology that I feel is yet to cement its place in the world, much akin to the internet in the early 90s.
With blockchain, I see a clear upending of the current user data ownership dynamics.
My newsfeed is populated with strong propagators against blockchain adoption and presumably, these guys have much to lose. Books like Sapiens and Homo Deus, which enlightened me on the entire journey of humanity through the years, made me realize that historically “change” is always met with resistance. A disruptive idea such as blockchain has the potential to tip the balance of existing power dynamics, which can be a major downside for established monetary and economic powerhouses.
I was pleasantly surprised that blockchain technology and the ideas of decentralization had their humble origins circa 1990. Here’s to hoping that the blockchain succumbs to the Lindy effect and pushes the envelope for innovation in the coming decades. We’ll find out how all this pans out together :)
Bitcoin , with its origins in 2008, opened up the conversation around blockchain, effectively introducing the concept of cryptocurrency and garnering significant mindshare among the tech audience. For the longest time ever, the efforts to use it as a general platform were ineffective due to a plethora of problems, with speed and the cost of transactions being the major ones.
Ethereum, promising to be the world computer, stepped in 2014 to tackle the issues bogging down Bitcoin, but has failed to be scalable. In fact, the Scalability Triangle, a term coined by the co-founder of Ethereum, delves into this.
NEAR - Eth 2.0
This is where NEAR enters, incorporating all the core strengths of blockchain and innovating on the code, to make it faster and remove barriers to scalability.
But what exactly is NEAR? [ Video Resources : https://www.youtube.com/watch?v=1cozsZP8yd4&t=98s ]
- It’s a layer 1 protocol for independent powering of Open Web (not a side chain or supplemental system)
- It’s a base-layer system, meaning that all Dapps and services created with its help are on top of the underlying NEAR layer. NEAR is also interoperable with Ethereum via the Rainbow bridge.
- It’s a sharded system that can be scaled infinitely. Sharding basically maximizes efficiency. The sharding mechanism is called Nightshade. The shard chains on NEAR are modeled as a single blockchain rather than creating side chains in other existing systems.
- It’s a highly flexible and easy-to-use protocol enabling developers to build apps quickly and introducing the general public to blockchain
An Introduction to the Web3 Tech Stack
Till now we have talked about the benefits of decentralization but this change is not going to happen in one day. The core issues outlined by the Scalability Trilemma on the trade-offs between scalability, security, and decentralization still persist. Thus, even though we are moving towards a more decentralized world, we can’t completely abandon the centralized system.
I was advised to start learning Rust as this is one of the go-to languages for writing contracts. The syntax is not very different to get used to but I am still in the process of picking it up but here are some resources that have helped me.
There are a lot of resources to start writing contracts and making them live. To avoid all the hassle that one has to deal with local installation, I prefer using Google cloud shell. It easily lets you clone a github repo and work effortlessly.
How to Open a github repository in the Cloud Shell
Getting started with Rust
Writing smart contracts is the most basic thing of blockchain development, but what is a smart contract? Is it similar to a class in Object-Oriented Programming ? What is its deal?
A smart contract is a self-executing contract with the terms of the agreement between buyer and seller being directly written into lines of code. The code and the agreements contained therein exist across a distributed, decentralized blockchain network. The code controls the execution, and transactions are trackable and irreversible.
The code and the agreements contained therein exist across a distributed, decentralized blockchain network
Smart contracts permit trusted transactions and agreements to be carried out among disparate, anonymous parties without the need for a central authority, legal system, or external enforcement mechanism.
In essence, it's a tiny computer program that is on a blockchain. One of the most basic examples of a smart contract can be that of a Kickstarter.
Let there be a Kickstarter campaign for a cause XYZ that requires 10 lakh rupees. Thus, if we are able to collect the needed amount it should be transferred to XYZ else it should be returned back to the people who donated in the first place.
What is the most important thing in this whole scenario?
Trust. Both the parties have to trust Kickstarter that it will hold up their side of the deal successfully. What if we could even automate all this?
This is where smart contracts come into play. We can write a block of code to perform all the following functions. Basically in the form of if-else.
Hence, every time the target money is collected this smart contract is triggered and the function takes place. Looks simple right?
Why should we trust smart contracts?
- They are immutable - This means they cannot change or be tampered with. But what if there is a bug, it would mean that there will be a bug forever? Well, No. The smart contracts on near can be updated by redeploying.
- They are distributed - It means there are no discrepancies. The code is on a bunch of computers around the world and publically accessible to everyone, implying that the output of the contract is validated by everyone on the network. This also means there is more service uptime. One node going down will not affect the end-user experience.
Smart Contracts are the back-end of your application that runs code and stores data on the blockchain. All smart contracts on NEAR must be compiled to WebAssembly or simply WASM.
In a way, a smart contract is similar to a Java class.
In the same way that a class may be instantiated.If you instantiate 5 instances of a Java class within the same OS process, the JVM bytecode will be loaded once into volatile computer memory and all 5 instances will share that loaded bytecode, whereas if you instantiate 5 instances of a contract, the EVM bytecode will be copied to 5 locations in permanent blockchain storage. But this difference doesn’t break the analogy; it just means that instantiating a contract 5 times is analogous to instantiating a Java class 5 times from a different process each time.
Looking up the databases
The next task was basically to look up a way to sort, filter and query data that we will be stored on the blockchain. Coming from a naive development background, I thought there must exist something like SQL to perform similar functions. Haha, but no.
There still isn’t a very straightforward way to do it. Yet. As it turns out this is why we still use centralized databases. In most cases, for maximum efficiency storage takes place as a mix of both traditional databases and the blockchain. While reading about it I came across the NEAR Indexer.
How does the NEAR Indexer work?
Blockchain data is optimized for serialized writes, one block at a time, as the chain is being created. Querying the blockchain for data about a specific block or account is a fairly straightforward or "narrow" query. However, querying data across many blocks can be cumbersome because we have to aggregate results from multiple single-block queries. We can consider these "wide" queries. The NEAR Indexer Framework allows for streams to be captured and indexed in a customised manner. The typical use-case is for this data to make its way to a relational database
- An indexer listens to the stream of data as it's being written on a chain and can then be immediately filtered and processed to detect interesting events or patterns.
- This stream of data can then be written to a permanent database for later data analysis using a convenient query language like SQL.
The NEAR Indexer Framework allows for streams to be captured and indexed in a customised manner.
All in all, this has been an overwhelming but a rewarding journey. I began my month thinking that learning blockchain from scratch would be a daunting task. But today, I can confidently vouch that if you have some preliminary knowledge about programming languages, coding and data structures, it is not as tough as it looks.I wouldn’t say I have gained a 100% clarity around the Web 3.0 space but I am sure that Web 3.0 is here and is here to stay for sure.