Installing Ethereum Development tools: geth and truffle on Ubuntu 22

By | August 30, 2023

Geth (Go Ethereum) is Ethereum client. It is Ethereal node to access to blockchain, run the Ethereal Virtual Machine (EVM) and mine. Geth is command line application. Truffle is a develop framework to smart contracts. I tried to install both on Ubuntu 22 using CLI only and what happened. With geth was simple, I downloaded tar.gz file, unpacked and it worked, but with truffle it was painful.
OK geth first. Download:


curl -O https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.12.2-bed84606.tar.gz

Unpack:


tar -zxvf geth-linux-amd64-1.12.2-bed84606.tar.gz

Check if it works:


cd geth-linux-amd64-1.12.2-bed84606/
./geth -v
geth version 1.12.2-stable-bed84606

Now truffle. The first step is npm installation, npm is the package manager for the Node JavaScript platform.


apt-get install npm

I need npm for truffle add-on installation.


npm install -g truffle

Check truffle version:


truffle version
/usr/local/lib/node_modules/truffle/build/3618.bundled.js:24586
 nbsp;  nbsp; return _this.outputFormatter && res ? _this.outputFormatter(res, this?.hexFormat) : res;
^

SyntaxError: Unexpected token ‘.’
 nbsp; at wrapSafe (internal/modules/cjs/loader.js:915:16)
 nbsp; at Module._compile (internal/modules/cjs/loader.js:963:27)
 nbsp; at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
 nbsp; at Module.load (internal/modules/cjs/loader.js:863:32)
 nbsp; at Function.Module._load (internal/modules/cjs/loader.js:708:14)
 nbsp; at Module.require (internal/modules/cjs/loader.js:887:19)
 nbsp; at require (internal/modules/cjs/helpers.js:74:18)
 nbsp; at Object.__webpack_require__.f.require (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:608:28)
 nbsp; at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:538:40
 nbsp; at Array.reduce ()

Ops! truffle does not work. To make it working we need to change npm version using nvm (Node Version Manager).

Current npm and node versions are:


npm -v
8.5.1
node -v
v12.22.9

We need higher.
Installing nvm by running the nvm install.sh script:


curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash

Add nvm to .bashrc script:


source ~/.bashrc

List of availed node versions:


nvm list
->   v16.20.2
      system
default -> 16.20.2 (-> v16.20.2)
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v16.20.2) (default)
stable -> 16.20 (-> v16.20.2) (default)
lts/* -> lts/hydrogen (-> N/A)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.24.1 (-> N/A)
lts/erbium -> v12.22.12 (-> N/A)
lts/fermium -> v14.21.3 (-> N/A)
lts/gallium -> v16.20.2
lts/hydrogen -> v18.17.1 (-> N/A)

6.20.2
Let us select version v16.20.2, install it and use:


nvm install 16.20.2
nvm use 16.20.2

New npm and node versions are:

Now check truffle version again:


npm -v
8.19.4
node -v
v16.20.2

truffle version
Truffle v5.11.3 (core: 5.11.3)
Ganache v7.9.1
Solidity v0.5.16 (solc-js)
Node v16.20.2
Web3.js v1.10.0

The truffle suit shows also Ganache and Solidity versions.
Solidity is compiler for solidity language, its location is:


/usr/local/lib/node_modules/truffle/node_modules/solc/solcjs
Must provide a file

Ganache is personal Ethereum Blockchain which may be used for testing Ethereum blockchain development tasks.
Starting ganache server by CLI command:


/usr/local/lib/node_modules/truffle/node_modules/.bin/ganache-cli
ganache v7.9.1 (@ganache/cli: 0.10.1, @ganache/core: 0.10.1)
Starting RPC server

Available Accounts
==================
(0) 0xAdD44B8CA169358B1c0dE5e948EbD8611a04E78C (1000 ETH)
(1) 0x399e4e8BFD876EdA894F79632978940085bb1283 (1000 ETH)
(2) 0x5F7c5a19A9DB6CfD9f68CfC352044f7aA30358Ac (1000 ETH)
(3) 0x62B94305D49A5D6590d7922fbB3961dFA443c601 (1000 ETH)
(4) 0xb067a3363609eF19525700766092BB9994279eE3 (1000 ETH)
(5) 0x1A844d0344B19c2B20883b2d220447CC5E802F7E (1000 ETH)
(6) 0xb3446b443b87fc04a150bA235dc5c56759233643 (1000 ETH)
(7) 0x6ac549AfDD87537c09C9267f134545586454c64f (1000 ETH)
(8) 0xe3Ca745246a69D97250B701dA82f57F9b790Dd34 (1000 ETH)
(9) 0xA218bCe11A39a9b32FE77989d7178413aEF7e896 (1000 ETH)

Private Keys
==================
(0) 0x44d06bd620af8d86ce1acf221df9c6684c91254c3343d2b1be4c116fd7a6f619
(1) 0x644d2d79ed6f1ac3bccd32846ad07f0436d07feee5f60da4609d159af1114eed
(2) 0xcfbeefae0db29cc483abca491c6624f2990f24292992659bf4dd03269c63451f
(3) 0x66c1b0d57e471eee973025a0621ff2edf576beb602e94793f6439feadf17b571
(4) 0xe3ad138307891d566029d7ab17d3454657d220c962125dd9cc03dcf5dc0bc25e
(5) 0x695cd43168554bfbb6eb9c03ed71ff86c1c095f1ca3d39e6ff8cfff444f53971
(6) 0x5d71364d167579b1dea9c554b1585cc50775f4816df46bcb8f160a729277803a
(7) 0xf539e6bd5215d7136eb09b05cc2ccefcf997e2861d5ccd58c526f3e7df2e3769
(8) 0x2367a0328cd2bacd7ff44b866ad44c8d6a5ff18f0ee9fcfe61f441c0f2bc4c55
(9) 0xa27ad176c11db79a1048f36bf1a09f55c79235a5ea17e494f9b5c3c5b6220a66

HD Wallet
==================
Mnemonic: sauce later clock provide valve case rebuild oyster inherit polar swing advice
Base HD Path: m/44’/60’/0’/0/{account_index}

Default Gas Price
==================
2000000000

BlockGas Limit
==================
30000000

Call Gas Limit
==================
50000000

Chain
==================
Hardfork: shanghai
Id: 1337

RPC Listening on 127.0.0.1:8545

Leave a Reply

Your email address will not be published. Required fields are marked *