Ethereum and Smart Contract

Ethereum and smart contract

Don’t be pushed around by the fears in your mind. Be led by the dreams in your heart.

Roy T. Bennett

One year ago, I got to know ethereum and smart contract. This post is serve as a documentation and sharing to those who interested develop smart contract in ethereum.  

Ethereum

Ethereum – A decentralized platform where you deploy and execute smart contract.

Download and install ethereum’s protocol – geth.
This is the entry point to ethereum’s main network, test network or private network. By connecting to any network, you’ll join the network as a node.

Smart Contract

A piece of source code that people assume it will replace the middle-man, such as lawyer or agent in the future.

Below is some tools that you need before start developing smart contract:

#1 Ethereum wallet

Download Ethereum wallet from Github repo

  • Ethereum wallet
  • Mist Browser – Browse Dapps or function as Ethereum wallet
  • MetaMask – a browser extension to access Ethereum mainnet or testnet

#2 Programming language

Solidity 

  • A new object-oriented programming language, for creating smart contract in Ethereum
  • Similar to C++ and python (Personal thought, I don’t feel it is similar to JavaScript, despite their website stated)
  • Partial supported fixed point number (Decimal point)
  • VS Code – solidity extension

#3 Framework

Truffle framework's logo
Image via https://truffleframework.com

Truffle

  • Compile, deploy and debug your smart contract
  • Ganache – Provided testing environment for your smart contract (formerly called TestRPC)
  • Drizzle – develop dapp (decentralized application)

#4 Testing smart contract

Using Mocha or any other JavaScript test runner. That can greatly simplify developer work flow and make testing automated.

  • Deploying smart contract depend on mining process, automated testing script can reduce the time waiting for deploy
  • Once deployed, smart contract will stay forever in the network, therefore, test as much as possible before deploy smart contract.

#5 Upgradable smart contract

Splitting smart contract into business logic and data smart contract. Then, developer can upgrade business logic smart contract without touching data part. 

Pro:
  • Easier to tackle smart contract bug in production environment
Con:
  • Higher cost in term of deploying smart contract

#6 Library

OpenZeppelin –  smart contract library that you can use to develop secure smart contract. This library has prepared a lot smart contracts for various use case. Developer just need to include and extends the smart contract with or without modification.

Thanks for reading. Have a nice day. 😀