If you are looking for trusted transactions and agreements between anonymous parties without the need for a central authority you can use the smart contracts.
While the blockchain was thought as the foundation for bitcoin, the technology goes beyond cryptocurrencies.
A few smart words about it
Smart contracts are self-executing contracts with the terms of the agreement between buyer and seller. They are directly written into lines of code that exist across a decentralized blockchain network.
The smart contracts were first proposed in 1994 by an American computer scientist and cryptographer named Nick Szabo. He tried to invent a virtual currency called “Bit Gold” in 1998 and also wanted to extend the functionality of electronic transaction methods to the digital realm.
Bitcoin vs. Ethereum
Bitcoin was the first cryptocurrency that used the basis of smart contracts which avoids the double spending. Given the fact that Bitcoin’s blockchain allows for peer-to-peer payments between its users, the Ethereum platform was created as a technology with a few extra more features.
Ethereum replaces Bitcoin’s restrictive language with one that allows developers to write their own programs or apps. In contrast with Bitcoin, Ethereum follows a different pattern for selecting which blocks get added to the valid blockchain and also allows for faster confirmation of the transactions.
(The Bitcoin blocks are created every 10 minutes; the Ethereum blocks are created within seconds).
How smart contracts work
Smart contracts can function as ‘multi-signature’ accounts. With this function, the funds are spent only when a required percentage of people agree with the transaction. Furthermore, it can provide utility to other contracts (similar to how a software library works), from storing an app’s information to domain registrations and information or membership records.
Ethereum works on two types of accounts that share the same address space: external account and contract accounts.
A smart contract account has:
- An address;
- A balance (of Ether);
- A state;
The address is like any regular account. It’s just the unique identifier for the account.
The balance gives the account the possibility to own funds.
The state of a smart contract account is the current state of all fields and variables declared in the smart contract.
The code of the smart contract is compiled in byte-code which is run by the Ethereum clients and nodes. The code is executed which leads to the creation of the smart contract.
The execution of the code is paid in something called gas. Gas is the fuel that runs the Ethereum Virtual Machine (EVM). Each transaction is charged with a certain amount of gas, whose purpose is to limit the amount of work that is needed to execute the operation. But also to pay for the execution. The gas price is a value set by the creator of the transaction.
EVM is the runtime environment for Ethereum’s smart contracts, and it has no access to the network, filesystem or other processes.
Because EVM is working at a level so low that it becomes inconvenient to program, the developers have created a few code languages dedicated to writing contracts. The most popular is called Solidity.
Transparency and flexibility
In a blockchain system, a smart contract must be visible so it can be verified. This means that anyone can look and check the transactions.
A smart contract can do anything that a typical computer can do. In plus, it has more flexibility in the implementation of tokens and transfers. But also the potential to perform a variety of functions that traditional contracts cannot.
A Smart way to understand it
To understand better the concept of a smart contract, let’s have a simple example:
Greg wants to deliver some furniture to his friend Chris whom he trusts.
While he trusts his friend, he’s not so sure about the firm which carries the furniture (smart contract). On the other hand, the moving company can have the same trust issues when it comes to Greg, paying the services.
In this case, both of them have to sign an agreement that Greg will pay for the delivery and that the good will arrive save to the destination. This transaction requires papers, contracts scanned, printed and signed.
By using the smart contract, this lengthy process can be easily simplified.
Greg is making a payment for the services to a smart contract that keeps the money locked until Chris confirms the delivery.
Smart contracts represent agreement statements written in the form of code which gets executed like any other computer program.
With clear standards that everyone agrees to, the smart contract is offering multiple options for collaborating, with no human error or corruption. Many new startups are working and developing products on this technology.