What is a smart contract? Explained via Web2 analogies

Diana Hsieh
Learning with Diagrams
2 min readSep 23, 2022

I recently starting following some Buildspace tutorials, and wanted to share some high level concepts that I learned!

In this post, I’ll cover what a smart contract is and how you use it, by comparing it with web2 concepts that are more familiar to most people.

As outlined above, smart contracts can be directly compared to many existing Web2 concepts in terms of what they enable. They just enable things slightly differently in a distributed, transparent way.

What is it? Code deployed on blockchain vs deployed on servers / cloud that are centrally owned.

How do you use it? You’re calling functions, just like you would an API.

What do you need to access it? Of course, you need to tell the smart contract who you are!

What do you need to deploy it? Similarly to deploying to a server, you need to tell the blockchain who you are and how to recognize you.

So deploying a smart contract is pretty interesting, and honestly a little annoying because it requires several services. In the tutorial, we were using a combination of HardHat, QuickNode, and Metamask to deploy things. I’m sure there might be more end-to-end services that can do all of this.

Essentially what you have to do is get a Metamask private key for the network you’re trying to deploy to. Then, you can deploy your code to a QuickNode URL, and QuickNode will handle broadcasting your contract and making sure it gets put onto the blockchain. Once that’s done, you’ll get an address back.

What’s really interesting is that smart contracts are IMMUTABLE. So everytime you make a change and deploy, you have to change the address of your contract that is being called from your UI (or backend code). That’s pretty crazy!

Meanwhile on the user end, you just leverage everything that’s been built, connect your wallet, and pay gas to run functions.

What was interesting here is that gas depends on how many transactions you make, so if there is a lot of logic in the backend determining how many transactions to make, you might end up paying more gas than expected. In these cases, you can set a gas limit and fail if the limit is hit.

I’m pretty new to this stuff, so if there’s any misses in understanding above, let me know in the comments below!

--

--