The clever use of smart contracts has contributed significantly to the exploding popularity of blockchain technology.
Initially proposed by computer scientist Nick Szabo, a smart contract is a collection of instructions executing automatically. This technology aims to make the contract execution as automated as possible.
Many know how basic smart contracts work, but it is rare to find a guide on their advanced versions. After a basic overview, we will analyze two typical cases of advanced smart contracts.
The article will not deal, for simplicity, with a series of technical details. The text aims to make it possible for non-technical readers to understand how this technology works.
A quick overview of smart contracts
A smart contract is a code that runs itself when the system registers specific circumstances. If and when particular events occur in a smart contract, a piece of code executes a new action.
Developers build and implement the code, having as many criteria as necessary to execute a transaction. Some claim that labeling these tools as “contracts” is wrong, leading to a debate in the legal industry.
Smart contracts were one of the first essential advancements in digitally automating traditional agreements. Consequently, they allowed users to ensure an instantaneous execution with minimum human input.
A developer may turn a legal agreement into a piece of code, creating a smart contract. Without further technicalities, this introduction is essential to follow the remaining part of our article.
The most famous advanced smart contracts: NFT smart contracts
A non-fungible token (NFT) represents a unique digital asset. Fungibility is the feature allowing swaps between two indistinguishable assets.
Fiat currencies are the most typical example used to demonstrate fungibility. The same is true for cryptocurrencies: exchanging 1 BTC for 1 BTC is a possible (yet, absurd) action.
Each NFT, on the other hand, is one-of-a-kind, and we cannot replace it with another. We generally use NFTs to represent collectibles, art, and other such goods in the digital world.
Non-fungible smart contracts are the engine generating these NFTs, representing only one token. NFT smart contracts have a maximum token supply equal to one, in slightly technical terms.
The contract contains a constant value that developers set to zero. Without overcomplicating the matter, the move makes this advanced smart contract relatively stable and secure.
Even those who are not particularly familiar with NFTs may have heard of the most popular projects in this sector. Think, for example, about Decentraland: an NFT-based metaverse platform.
In Decentraland and similar projects, users can purchase land and objects in the digital universe. These assets correspond to NFTs, which strictly depend on the underlying NFT smart contracts.
What are ALCs?
IoT (“Internet of Things”), like blockchain, is a technology that has caught the world’s attention and imagination.
Interconnecting billions of devices and allowing them to exchange data opens up a world of unlimited possibilities. On the other hand, this technology creates data security and privacy issues.
Traditional IoT systems feature a centralized design, in which data passes from an IoT device to the cloud. The system processes the data to send information back to the device in this virtual environment.
Such a centralized system has very limited scalability and high vulnerability in network security. The problem is significant in situations when devices can start payments independently.
This limit is where blockchain comes into play. Application Logic Contracts (ALCs) are smart contracts on blockchain networks enabling devices to operate relatively safely and independently.
For this reason, ALCs are gaining a fair amount of popularity in the IoT world. Their implementation results are increased automation, scalability, and lower transaction costs.
Every network node must store a copy of each contract’s program code and state for on-chain smart contracts. Furthermore, since we talk about smart contracts, nodes must know how and when to execute the code.
Is it possible to hack advanced smart contracts?
The short answer is: yes, hackers can attack even advanced smart contracts. NFT contracts may contain bugs that a cybercriminal can exploit.
CryptoPunks, arguably the most popular NFT project to date, suffered a significant problem in their smart contracts in 2017. After selling thousands of NFTs, many found a flaw that allowed sales without receiving money.
This is a classic example of the importance of testing a piece of code before releasing it. The problem with the code was one line, and a Twitter user explained the flaw in detail.
In general terms, there are many studies on hacking smart contracts. In 2018, five computer scientists cooperated on a research work and distinguished:
- Suicidal Contracts, which anybody can terminate.
- Prodigal Contracts, which recklessly leak money to unauthorized users.
- Greedy Contracts, which lock money for an infinite period.
On the Ethereum Network, they examined 970,898 smart contracts. They discovered 34,200 of them to be vulnerable to hacking/exploitation, so one out of every 20 smart contracts.
Claiming that 5% of the smart contracts belong to one of the three categories above is a severe issue. Since few traders can read the code of a smart contract, the market needs serious auditors.
Smart contracts will continue to be the wind underneath blockchain technology’s wings for a while. This technology is gradually changing the world, and it will be interesting to see its future developments.
As smart contracts become more complex, audit services should get more and more efficient. Whenever there is a group of hackers one step ahead of controllers, we will have a problem.