Intro to smart contract in blockchain

Ahmad Ali Abdilah
3 min readJun 11, 2024

Blockchain has been known publicly for more than a decade already. Even though Bitcoin was the first blockchain getting all the attention, it was Ethereum which brought a massive adoption to blockhain space. One of significant reason is because the “Smart Contract” feature it brings to the table. Ethereum is also called blockchain 2.0 because of the same reason.

Smart contract is a feature to store code in the blockchain and make it executable for a specific purpose. You can think of it’s like a server for your web application, but it’s hosted on the blockchain. So why do we want to host a code on the blockchain? Well, because of the inherent features of Blockchain to be decentralized, trustless and public which would make our logic to inherit those features by default (though there are many ways you can make it violates these features, but we will discuss it in another article).

When creating a smart contract, there are several different mindsets we need to have compared to running a traditional server application:

1. Limited code size

While you have virtually unlimited code size you can deploy for your server application, for smart contract the hosting blockchain usually set a max size for the deployed smart contract on it. For example, Ethereum has 24KB limit of smart contract code. If you try to deploy smart contract that exceeding the limit, it will not passes the validation. This limit is actually by design: to allow the blockchain to operates consistently well. If it were to allow arbitrary size of smart contract, one of the consequence is one can deploy an extremely complex and long logic that would hinder the performance of the blockchain.

2. Limited programming language

Under the hood, Ethereum actually only accept smart contract in byte form. But even though, there are only 2 popular language you can use to create a smart contract: Solidity and Python, with Solidity as the most popular one. This has a consequence of steeper lerning curve that acts as barrier for a new smart contract developer. Sure you can a more popular language (Python), but for less popular, tooling and libraries are more limited compared to the prior.

3. Immutable by default

If you are developing a server code, you can always redeploy it everytime you want to add a feature or fix a bug. It’s not the case with smart contract. Smart contracts (in most blockchains) are immutables. Once a smart contract is deployed, there’s no way for you to change it. Because of this, you have to carefully design, code, and test your smart contract before deploying it to public. Because the effect of mistake would be enormous.

4. Smart contracts are executed synchronously

If you have been in development space, you might already know that there are a lot of things can go wrong when we run asynchronous logics: race conditions and read/write lock to mention a few. A synchronous logic is much more predictable, therefore this approach was choosen.

Understanding this, you would understand order of transactions in a block would matter.

We’ve talked about smart contract this much, so how does it look like in action?

Here’s the example of a very simple smart contract:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract StateUpdate {
uint256 private num = 0;

function setNumber(uint256 newNum) public {
num = newNum;

function getNumber() public view returns(uint256) {
return num;

This smart contract does a very simple logic: allowing everyone to set the number and get the recorded number.

Solidity itself is quite similar with other Object Oriented Programming language like Java. Therefore if you are familiar with one, you might be able to grasp this progrmming language fairly easy. The area you might have challenge with instead usually would be the concept of how blockchain operates. Because that’s how your smart contract would be executed.

I hope from this article, you can understand the surface concept of smart contract. See you on the next one.