top of page
  • Writer's pictureGlobal MoonXBT

A Guide To Smart Contracts


What Are Smart Contracts?


In the world of cryptocurrencies, we may define a smart contract as an application or program that runs on a blockchain. Typically, they work as a digital agreement that is enforced by a specific set of rules. These rules are predefined by computer code, which is replicated and executed by all network nodes.

Blockchain smart contracts allow for the creation of trustless protocols. This means that two parties can make commitments via blockchain, without having to know or trust each other. They can be sure that if the conditions aren't fulfilled, the contract won't be executed. Other than that, the use of smart contracts can remove the need for intermediaries, reducing operational costs significantly.

Although the Bitcoin protocol has been supporting smart contracts for many years, they were made popular by the creator and co-founder of Ethereum, Vitalik Buterin. It's worth noting, though, that each blockchain may present a different method of implementing smart contracts.


How do they work?


In simple terms, a smart contract works as a deterministic program. It executes a particular task when and if certain conditions are met. As such, a smart contract system often follows "if… then…" statements. But despite the popular terminology, smart contracts are not legal contracts, nor smart. They are just a piece of code running on a distributed system (blockchain).

On the Ethereum network, smart contracts are responsible for executing and managing the blockchain operations that take place when users (addresses) interact with each other. Any address that is not a smart contract is called an externally owned account (EOA). Thus, smart contracts are controlled by computer code, and EOAs are controlled by users.

Basically, Ethereum smart contracts are made of a contract code and two public keys. The first public key is the one provided by the creator of the contract. The other key represents the contract itself, acting as a digital identifier that is unique to each smart contract.

The deployment of any smart contract is made through a blockchain transaction, and it can only be activated when called by an EOA (or by other smart contracts). However, the first trigger is always caused by an EOA (user).


Key features


An Ethereum smart contract often presents the following characteristics:

1. Distributed. Smart contracts are replicated and distributed in all nodes of the Ethereum network. This is one of the major differences from other solutions that are based on centralized servers.

2. Deterministic. Smart contracts only perform the actions they were designed to, given the requirements are met. Also, the outcome will always be the same, no matter who executes them.

3. Autonomous. Smart contracts can automate all sorts of tasks, working like a self-executing program. In most cases, though, if a smart contract isn't triggered, it will stay "dormant" and won't perform any action.

4. Immutable. Smart contracts can't be changed after deployment. They can only be "deleted" if a particular function was previously implemented. Thus, we may say that smart contracts can provide tamper-proof code.

5. Customizable. Before deployment, smart contracts can be coded in many different ways. So, they can be used to create many types of decentralized applications (DApps). This is related to the fact that Ethereum is a Turing complete blockchain.

6. Trustless. Two or more parties can interact via smart contracts without knowing or trusting each other. In addition, blockchain technology ensures that data is accurate.

7. Transparent. Since smart contracts are based on a public blockchain, their source code is not only immutable but also visible to anyone.


Can I change or delete a smart contract?


It's impossible to add new functions to an Ethereum smart contract after deployed. However, if its creator includes a function called SELF-DESTRUCT in the code, they are able to "delete" the smart contract in the future - and replace it with a new one. In contrast, though, if the function isn't included in the code beforehand, they won't be able to delete it.

Notably, the so-called upgradeable smart contracts allow developers to have more flexibility over contracts' immutability. There are many ways to create upgradeable smart contracts with varying degrees of complexity.

Taking a simplified example, let’s imagine that a smart contract is divided into multiple more minor contracts. Some of them are designed to be immutable, while others have the 'delete' function enabled. This means that part of the code (smart contracts) can be deleted and replaced while other functionalities remain intact.


Advantages and use cases


As programmable code, smart contracts are highly customizable and can be designed in many different ways, offering many kinds of services and solutions.

As decentralized and self-executing programs, smart contracts may provide increased transparency and reduced operational costs. Depending on the implementation, they can also increase efficiency and reduce bureaucratic expenses.

Smart contracts are beneficial in situations that involve the transfer or exchange of funds between two or more parties.

In other words, smart contracts can be designed for various use cases. Some examples include the creation of tokenized assets, voting systems, crypto wallets, decentralized exchanges, games, and mobile applications. They may also be deployed along with other blockchain solutions tackling healthcare, charity, supply chain, governance, and decentralized finance (DeFi).


ERC-20


Tokens issued on the Ethereum blockchain follow a standard known as ERC-20. The standard describes the core functions of all Ethereum-based tokens. As such, these digital assets are often referred to as ERC-20 tokens, and they represent a significant portion of the existing cryptocurrencies.

Many blockchain companies and startups deployed smart contracts in order to issue their digital tokens on the Ethereum network. After the issuance, most of these companies distributed their ERC-20 tokens through Initial Coin Offering (ICO) events. In most cases, the use of smart contracts enabled the exchange of funds, and distribution of tokens, in a trustless and efficient way.


4 views0 comments

Recent Posts

See All
bottom of page