Ethereum is the  decentralized platform for blockchain. On this article, you will know how to setup Ethereum on mac OS platform using various tools like geth, ganache, truffle which helps you to make development lifecycle fast.

Also, we will se  funds transfer from one account to another and check account balances.

Prerequisites

  • Basic understanding of Blockchain
  • Basic understanding of Ethereum

Ethereum ecosystem

Ethereum development ecosystem inclus of the following tools.

  • HomeBrew : HomeBrew is package manager for macOS.
  • XCode command line tools: Xcode command line tools include compilers, utilities needed by HomeBrew.
  • Geth : Command line interface implemented in Go.

Geth It allows you to   :

  1. exploit blocks
  2. generate ethers
  3. create and manage accounts
  4. deploy and interact with smart contracts
  5. transfer funds
  6. inspect block history
  7. Connect to the public ethereum network (mainnet)
  8. Create your own private network
  • Ganache: An ethereum blockchain emulator how replace testRPC.
  • NodeJS and NPM
  • Truffle: Build framework used to compile, test and deploy your smart contract.
  • Text editor

Install Ethereum on Mac OS

Step 1: Install Homebrew

Use below command to install

$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Step 2: Install XCode

Step 3: Install go-ethereum

$ brew update
$ brew tap ethereum/ethereum
$ brew install ethereum

If ethereum already installed upgrade it to the latest version using below command.

$ brew upgrade ethereum

Step 4 : Install Ganache

Download Ganache for macOS from

Step 5 : Install NodeJS & NPM

$ brew install node

$ node -v
$ npm -v

Step 6 : Install Truffle

$ npm install -f truffle

Your ethereum setup is done and its ready to use.

To verify if the setup works, let’s do some fund transfer and check balance,
$ mkdir rcherara-blockchain
$ cd rcherara-blockchain
$ truffle init
$ truffle develop
truffle will create 10 default accounts and with initial balance 100 ethers each

To check balance use web3 API as below

First account : In Geth console,
$ web3.fromWei(web3.eth.getBalance(‘Account-1’), ‘ether’).toNumber()
Second account : In Geth console,
$ web3.fromWei(web3.eth.getBalance(‘Account-2’), ‘ether’).toNumber()

To Transfer ether from account one to account two using web3 API as below

In Geth console, use eth_sendtransaction function to send a transaction to the destination

web3.eth.sendTransaction({
    from: "Account-1",
    to: "Account-2",
    value: web3.toWei(1, "ether")
})
Geth console : sendTransaction functioncc

References:

https://www.ethereum.org/cli
https://github.com/ethereum/go-ethereum/wiki/geth
http://truffleframework.com/ganache/
http://truffleframework.com/
https://ide.atom.io/