June 7th 2020
blockchain-based, distributed computing platform which supports smart contracts, Ethereum quickly turned out to be a game-changer.
Smart contracts paved the way for a variety of trustless distributed applications (
DApps) and encouraged a host of blockchain projects, each trying to bring about a paradigm shift in its own way.
(Vitalik Buterin – the man who introduced smart contracts to blockchain)
As blockchain technology continues to spread its wings, smart contracts continue to be the wind underneath. A host of articles are readily available on the Internet which talk about how smart contracts are revolutionizing the world today. In this article, we’ll take a slightly different route – we’ll look at different types of smart contracts in existence, and glance at projects which are implementing them.
Time-lock contracts are one of the simplest and most common forms of smart contracts. As the name suggests, digital assets deposited to these contracts are ‘locked’ for a pre-defined period of time, before the assets can be retrieved by the sender. Such contracts typically come with a
‘time-lock’ function, which sets a numerical timestamp for each deposit
address. Tokens can be withdrawn to a certain address only after the associated timestamp has expired; prior to that, the lock contract only accepts deposits.
Time-lock contracts are ubiquitous in
Apart from the time-lock function, a HTLC also contains a hash-lock – a function that prevents the recipient from spending the funds until a certain cryptographic proof is publicly broadcasted.
(Lightning Network is using HTLCs to ensure faster and secure transaction settlements)
Portal Payment Channel Contract
Payment channels are an important aspect of off-chain scaling solutions in blockchain networks. Any blockchain transaction has to be verified, included in a block, and publicly broadcast to all the nodes.
Each transaction also involves a mining fee, which might end up being a significant portion of the actual amount being transferred. For cases which involve multiple small-value transactions, the entire process becomes extremely costly and time-consuming.
Payment channels use a smart contract to enable users to transact multiple times, without recording every single transaction on the blockchain.
Intermediate transactions are recorded off-chain, and on completion, when the payment channel is closed, the final state of the participants is published on the blockchain.
Irrespective of the number of transactions, only one block has to be mined when payment channels are used. As already mentioned in the context of Lightning Network, by creating a mesh of payment channels, a secure and distributed network connecting multiple users can be created.
verify) feature was introduced to such smart contracts to avoid malleability attacks. Other upgrades include time-locking transactions in a manner
such that the last state of the channel always has the lowest time-lock, and is the first one that can be broadcast on the blockchain.
These smart contracts consider 3 variables – the accumulated load that the sender loads into the channel, the accumulated payment that the sender has already paid, and the expiration timestamp beyond which the receiver can no longer accept funds. These three variables can only increase, which ensures the presence of a certain amount of funds in the channel for the receiver, and enables the recipient to withdraw the collected funds without waiting for the channel to terminate.
(Off-chain settlement techniques frequently use payment channel smart contracts)
Application Logic Contract
ALCs contain application specific code, which can work in conjunction with other smart contracts and programs on the blockchain.
They aid in communicating with and validating communication between different IoT devices. Since there is no third-party required to oversee transactions, these smart contracts can effectively oversee micro-payments between different IoT nodes.
structure is termed Tangle, but let’s not get into these technicalities
In a recent
announcement, Iota stated that they would be developing their ALCs off-chain, outside the core protocol of the tangle.
For on-chain smart contracts, every network node has to keep a copy of each contract’s program code and state, and execute the code when the smart contract is triggered. By transferring them off the tangle, Iota’s ALCs can be executed in a localized manner, greatly improving the network scalability.
(The growing importance of IoT and blockchain brings ALCs sharply into focus)
individual units are interchangeable and indistinguishable from each other.
The most common example used to explain fungibility is fiat currencies, where a valid note of any denomination is virtually indistinguishable from any other such note for all intents and purposes.
On the other hand, each NFT is unique and cannot be replaced by another of its kind. In the digital world, NFTs are usually used to represent collectibles, art items, memorabilia, and the like.
NFTs are being increasingly used in blockchain-based
games, to represent the ownership of unique items which are of value within the gaming ecosystem. Exchange of such items across different games is also possible through these smart contracts.
contract represents only one unique token.
When a non-fungible token contract is initialized, its constant is set to zero. Once the token has been issued and it begins to exist, its supply is permanently fixed to 1. This guarantees the stability and security of every operation performed in the contract, and ensures that the token is provably unique.
Decentraland is one of the most prominent blockchain projects which make use of non-fungible smart contracts.
(Non-fungible contracts are one of the driving vectors in the crypto-collectible market place)
PS – Being from a non-blockchain background, searching for different
varieties of smart contracts on the Internet turned out to be a notoriously
difficult task. Thank god for Binance Academy and the announcement posts of blockchain projects upgrading their smart contracts! If you know of any that’s worth a read, please do leave a comment here.