FreeBSD ETH - How to Connect to Ethereum Blockchain Using Go Lang

Ethereum Foundation co-creator and founder "Vitalik Buterin", had the idea of making Ethereum a decentralized computing blockchain platform that allows anyone to create, store, and run smart contract-based Decentralized Applications, or DApps.

As shown in the diagram below, the Ethereum blockchain network is one decentralized Peer-to-Peer (P2P) network of Ethereum clients, which represent network nodes. An Ethereum client refers to any node that can verify new transactions, execute smart contracts, and process new chain blocks. It is a kind of enclave, residing on thousands of computers or devices on the internet, and connected via the Ethereum P2P network. In the bag is an EVM and a runtime environment on a P2P network for smart contract execution.

In the image above, the Ethereum Client is running EVM and technically it can be written in any computer programming language, but the most popular Ethereum is written in Go Lang. There are many different implementations of Ethereum clients. Basically Ethereum allows a variety of different client implementations, although they differ, each implementation must conform to the protocol specifications defined in the Ethereum Yellow Paper. There are many advantages to the variety of Ethereum client implementations. The following is a programming language that runs the Ethereum protocol.

The Ethereum Client also provides a set of Web3 APIs via JSON-RPC for DApps. This Web3 API can interact with the Ethereum blockchain, via a web application or Mainnet wallet. You can use the Web3 API objects provided by the web3.js library to communicate with the Ethereum blockchain network. The Web3 API can be used with all Ethereum clients written in any programming language.

The Web3 API can connect to local or remote Ethereum nodes and make RPC calls. On the old model Ethereum network DApps were used as clients, and the entire Ethereum network as a whole, acted as servers. For DApps, the Ethereum network is like a giant global computer, cobbled together with thousands of computing devices across the internet. Once you connect to the network, you can connect to any node in the decentralized network, as shown in the following diagram:

1. Install Go-Ethereum

In this article, we will explain how to install and configure Etehereum on a FreeBSD server. You need to know, if we use the ports system or PKG package during the installation process, Ethereum will be installed using the Go programming language.

The following is the Etehereum installation process using the default FreeBSD ports system.
root@ns3:~ # cd /usr/ports/net-p2p/go-ethereum
root@ns3:/usr/ports/net-p2p/go-ethereum # make config
The "make config" command will display a menu of installation options. Mark the "DEVTOOLS" option. After that run the installation command.
root@ns3:/usr/ports/net-p2p/go-ethereum # make install clean
This command installs the Geth core software and developer tools in the form of binary files. Ethereum binary files are located at "/usr/local/bin". The results of the installation process will produce files.

===>  /usr/local/bin/geth
===>  /usr/local/bin/abigen
===>  /usr/local/bin/bootnode
===>  /usr/local/bin/evm
===>  /usr/local/bin/rlpdump
===>  /usr/local/bin/clef
===>  /usr/local/bin/puppeth

2. Set up Ethereum Wallet

Before you can use the Ethereum network, you must first create an Ethereum wallet. Ethereum wallet is a virtual wallet where all ETH assets are stored. You may find up-to-date information about your balance, transaction history, and further information stored in your account. An Ethereum wallet will work properly if it is synchronized and connected to the Ethereum blockchain.

Run the following command to connect your Ethereum to the Ethereum blockchain network.
root@ns3:~ # geth --datadir /root/.ethereum --syncmode "snap" -cache=2048
The --syncmode "snap" command above will carry out the process of synchronizing your Ethereum Network with the Ethereum Blockchain network. The snap Synchronization model starts from a relatively new block and starts synchronizing from the top of the chain. This sanp model is only able to store the latest 128 block states in memory. The block headers to be synchronized are provided by the consensus client. Between the initial synchronization block and the latest 128 blocks, nodes occasionally save snapshots that can be used to rebuild any intermediate state "on-the-fly".

After that you have to create an account and set a password.
root@ns3:~ # geth account new
INFO [02-08|23:06:39.519] Maximum peer count                       ETH=50 LES=0 total=50
INFO [02-08|23:06:39.522] Smartcard socket not found, disabling    err="stat /var/run/pcscd/pcscd.comm: no such file or directory"
Your new account is locked with a password. Please give a password. Do not forget this password.
Password: router123
Repeat password: router123

Your new key was generated

Public address of the key:   0xf891274344b464182199f2259052d7ACB1a85D98
Path of the secret key file: /root/.ethereum/keystore/UTC--2024-02-08T16-06-50.268610116Z--f891274344b464182199f2259052d7acb1a85d98

- You can share your public address with anyone. Others need it to interact with you.
- You must NEVER share the secret key with anyone! The key controls access to your funds!
- You must BACKUP your key file! Without the key, it's impossible to access account funds!
- You must REMEMBER your password! Without the password, it's impossible to decrypt the key!

root@ns3:~ #
To see the entire list of accounts on your Ethereum network, use the following command.
root@ns3:~ # geth account list
INFO [02-08|23:09:55.022] Maximum peer count                       ETH=50 LES=0 total=50
INFO [02-08|23:09:55.024] Smartcard socket not found, disabling    err="stat /var/run/pcscd/pcscd.comm: no such file or directory"
Account #0: {f891274344b464182199f2259052d7acb1a85d98} keystore:///root/.ethereum/keystore/UTC--2024-02-08T16-06-50.268610116Z--f891274344b464182199f2259052d7acb1a85d98
Use the "geth att" command to attach the console to an already running instance. This console allows you to interact with local Ethereum nodes, for example, you want to view your Ethereum account.
root@ns3:~ # geth attach
Welcome to the Geth JavaScript console!

instance: Geth/v1.12.2-stable/freebsd-amd64/go1.20.12
at block: 0 (Thu Jan 01 1970 07:00:00 GMT+0700 (WIB))
 datadir: /root/.ethereum
 modules: admin:1.0 debug:1.0 engine:1.0 eth:1.0 miner:1.0 net:1.0 rpc:1.0 txpool:1.0 web3:1.0

To exit, press ctrl-d or type exit
> eth.accounts
If you want to update your account, such as changing your password, run the following command.
root@ns3:~ # geth account update 0xf891274344b464182199f2259052d7acb1a85d98
INFO [02-08|23:45:06.195] Maximum peer count                       ETH=50 LES=0 total=50
INFO [02-08|23:45:06.198] Smartcard socket not found, disabling    err="stat /var/run/pcscd/pcscd.comm: no such file or directory"
Unlocking account 0xf891274344b464182199f2259052d7acb1a85d98 | Attempt 1/3
INFO [02-08|23:45:11.123] Unlocked account                         address=0xf891274344b464182199f2259052d7ACB1a85D98
Please give a new password. Do not forget this password.
Repeat password:
root@ns3:~ #
Even though Blockchain technology is still relatively new, interest in it continues to grow. The guide in this article will make it easier for you to get started with Ethereum blockchain technology. What you need to pay attention to when starting to open an Ethereum wallet is to always maintain the confidentiality of your password and the security of your Ethereum assets. This way, you can enjoy the benefits of a secure and well-maintained Ethereum wallet.
Iwan Setiawan

I Like Adventure: Mahameru Mount, Rinjani Mount I Like Writer FreeBSD

Post a Comment

Previous Post Next Post