Use Ethereumjs-tx and Web3 to Send an Ether Transaction using your Terminal

A tutorial that goes over how to send a send an ether transaction using Ethereumjs-tx and Web3.

This article was first published to MLG Blockchain. Before beginning this tutorial you must have node and npm downloaded on your computer. After this tutorial you should have sent an ethereum transaction with test-ether on testrpc.

npm install web3 ethereumjs-tx ethereumjs-util

Download web3, ethereumjs-tx and ethereumjs-util from your terminal.


Go to your node console.

var Web3 = require("web3")

Require web3.

var web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"))

Get web3 Instance in Node Console. 8545 is the default port to connect to.


In a new terminal window run testrpc.


Check balance of account[0] in Wei.

web3.fromWei(web3.eth.getBalance(web3.eth.accounts[0]), 'ether')

Check balance of account[0] in Ether.

acct1 = web3.eth.accounts[0]
acct2 = web3.eth.accounts[1]
acct3 = web3.eth.accounts[2]

Create account helper methods.

var balance = (acct) => { return web3.fromWei(web3.eth.getBalance(acct), 'ether').toNumber()}

Create balance method.


Query balance of account[0] to make sure its working.

web3.eth.sendTransaction({from: acct1, to:acct2, value: web3.toWei(1, 'ether'), gasLimit: 21000, gasPrice: 20000000000})

Send 1 test ether from acct1 to acct2.

var txHash = _

Create variable for txHash output from above.

balance(acct2) balance(acct1)

Query balance of acct1 and acct1 to make sure the transaction went through. Your balance should have changed by the number of ether that you sent.


Check transaction data from txHash.

MLG Blockchain is a blockchain development and consulting firm based in Toronto that is focused on building next generation applications using blockchain and smart contract technology. See more blockchain development tutorials at