
Introduction to a smart contract on blockchain
Table of Contents
A smart contract is a computer protocol intended to facilitate, verify, or enforce the negotiation or performance of a contract. Since the launch of Ethereum, we deal with a smart contract on blockchain which is a kind of computer programm that is stored on a blockchain and is used to automate the execution of an agreement. Let’s see how it works!
Smart Contract on blockchain – needed knowledge
Before we start creating example of a smart contract on blockchain I would like to introduction some terminology that you should known. What technologies and tools we need to create and deploy a Smart Contract to the Ethereum network. In this article I will show you how source code looks like, how to compile with Solidity compiler. Also how to create private network for testing.
You should know basic knowledge about:
- Javascript
- Linux and CLI
- Solidity
- Ethereum network
Tools we need for a smart contract on blockchain
- NodeJS
- Solidity compiler (solcjs)
- Ethereum client: geth
To write a smart contract on blockchain we need editor. I prefer Web IDE called Remix. Remix gives us possibility to write, compile and deploy our Contract. It also support JavaScript Virtual Machine – so we don’t really need deploy our code to the network. It is good for testing, but does not reflect a full network (e.g. with time of block mining). In this article we will use private network. Remix have option to set Web3 Provider, so then we can use our network.
Ethereum have multiple clients. Mentioned above geth but also Parity or cpp_ethereum. Parity is good for general group of users because it have Web UI, where we can find your wallet, transactions list, transactions queues even console.
Private Network
To create private Ethereum network and blockchain we need Ethereum Client (called nodes). Ethereum network is Peer to Peer network.