Onchain and Offchain — What’s the Difference.

Mayowa Obisesan
4 min readDec 21, 2023

--

Web3 is here to stay. It has its flaws, but those flaws are actively being worked on, with the likes of L2 chains, which are centred towards achieving Scalability and Faster Speed while leaving the security to the L1 chains.

These active developments and fixes are already getting people interested in web3. But there is still the problem of consistent hacks or exploits, which are prominent these days. It’s safe to say that most web3 platforms are unsafe — or to put it in lighter terms, not as safe as we would want them to be. And this is a big problem because everything about web3 is tied to money one way or another.

But enough of my talk about the problems of web3. This article is meant to explain one concepts that is common in web3 — Onchain and Offchain.

Before I dive deep into what onchain and offchain is, let me give a background explanation of what web3 is all about for those who might be new to web3. So, what is web3 about? Consider this scenario, I have an app on my phone, be it a game, a social media app, a browser, a blog app, or any other web2 apps. These apps require you to login for one reason or another, and once you signup or login, your data is collected and sent to a server somewhere or to multiple servers that you most probably don’t know about nor know what your data will be used for. That server or those servers are paid for by the company who owns the app and by “legality” they have access to the data they collect and can use it for other services to provide better services for you. Long story short, they can use your data at will as long as you agreed to the terms and conditions at the point of signup to the app. But this haven’t still explained why web3 was born.

Web3 aim is to solve two problems,

  1. Decentralization
  2. Transparency

Decentralization in the sense that in the event that the company that holds your data using the scenario above, goes bankrupt or experience some physical hazard, you might loose access to the that apps’ services because you might have lost your data. But, it will be unfair to think that this scenario will happen and you will easily loose your data in web2. Nah… it’s not that bad. In web2, almost every web cloud infrastructure is decentralized, with every data cloned and stored in multiple data centres around the world and shared by nodes. So, if your data were to be lost in one physical location, you will still have access to your data served to you from another location, probably the data centre in the country closest to you. But out of the box, web3 is decentralized, with every transaction you perform on the web3 networks available on every nodes that powers the network. Similar to the web2 cloud infrastructure above.

The second problem web3 aims to solve is Transparency. This is quite wild and is perceived as acceptable or unacceptable, relative to whoever is considering it. Let me explain. The purpose of transparency in web3 is that every code (called smart contracts) that is deployed to a blockchain network can be seen by everybody. In fact, it is not just seen by everybody, but copied and, if permitted, used and freely distributed as well. Imagine if you have access to google’s entire codebase or Microsoft’s or Apple’s codebase. Yeah, that’s what happens in web3. I literally have access to the thousands of dapps created on any public blockchain because I have access to each dapps code (smart contract). It’s crazy right? But yeah, you can do that in web3. This is why there is a lot of hacks in web3, especially in defi apps, because even in web2 whose code is not publicly accessible, we still have individuals and / or groups who find flaws and exploit the system once in a while. Now, imagine when access to the code base is made public? You could probably understand the good and the bad side of transparency in web3. Another side to the transparency in web3 is code immutability. Smart contracts once deployed to the blockchain are permanent. This means smart contracts can not be deleted nor updated. Yes, smart contracts are deployed once and they exist forever.

So yeah, that’s what web3 aims to solve.I believe everyone reading this is caught on up to this point.

Now to the main focus of this article.

ONCHAIN

The word onchain simply means to exist on the blockchain. That’s it.

It means having data that is sent and received from and to smart contracts exists permanently on the blockchain.

If I say data is sent onchain, it means I have sent data to the blockchain.

If I say data is onchain, it means that data exists permanently on the blockchain.

OFFCHAIN

Offchain is the opposite of onchain. It means not stored on the blockchain. These kinds are data that are not stored on the blockchain. Examples are weather data, stocks-data, etc. Platform’s like chainlink offer these services to web3 dapps.

That’s what the term offchain and onchain mean. They make sense to you once you understand the fundamentals of web3 and blockchains, and that was why I had to give much fundamental explanations about web3.

I believe you have learnt something from this article.

Check my other articles about web3. They are easy to understand. You can also check out my C++ articles if you want to understand low-level concepts.

Thanks for reading. 🙂

--

--