content logo

Ethereum:

Ethereum Smart Contract

What is a smart contract?

First of all, a Smart Contract is basically a program which runs on the Ethereum blockchain. It is a combination of data and code where the data is its state and the code its functions. This collection is located at a specific address which is on the Ethereum blockchain.

Smart contracts are simply a type of Ethereum account. What this means is that they have a certain balance and can send transactions over the Internet. However, this is not controlled by a user and instead it’s the network they are deployed to so they run as programmed. With that said, User accounts can still interact with smart contracts via submitting transactions which execute a function which is defined on the said smart contract. Smart contracts may define rules, same as a regular contract; they may then automatically enforce them using the code.

Prerequisites

Before you jump into the world of smart contracts, make sure you have read about accounts, the Ethereum virtual machine and transactions. This knowledge helps you immensely to understand the subject more thoroughly.

A digital vending machine

The best metaphor to explain a smart contract is probably a simple vending machine. These machines are programmed in a way to dispense out snacks based on two parameters; first the money input and second snack selection. This logic is programmed into the machine so that there is always a guaranteed output, given the right inputs are in. A smart contact, is like a vending machine in the way that it has a logic programmed into it as well. Imagine how a vending machine completely removes the staff requirement of vendor employees. Smart contracts are basically same in this regard as they replace intermediaries in most industries.

Permissionless

Anyone has the ability to write a simple smart contract and deploy on the Internet. All they need is to learn the basics of coding in smart contract language and possess enough ETH to actually deploy the written program. Deploying a smart contract is technically considered as a transaction, so you have to pay your “Gas” exactly how you have to pay Gas for a simple transfer of ETH. Keep in mind that Gas costs are far higher for contract deployment.

Hopefully, Ethereum has some developer friendly languages which can be used for writing smart contracts with those two being “Solidity” and “Vyper”. However, before they can actually be deployed, these two languages should be compiled first so that the Ethereum virtual machine is able to interpret the contract and store it.

Composability

Smart contracts on Ethereum are public and may be thought of as open Application Programming Interfaces (APIs). What this means is that you may call other smart contracts in your smart contract in order to greatly extend the possibilities. A smart contract may even deploy another contract.

Limitations

Smart contracts alone don’t have the ability to gain information regarding the real-world events for they cannot send HTTP requests and this is by design. Moreover, relying on external information may jeopardise consensus and that is important for decentralization and security.

#

Smart Contract

#

Smart Contract Permission

#

Ethereum Limitations

#

Digital Vending Machine

#

Ethereum Specification