5  Prática: Criando uma Rede Ethereum Privada: Ethash

Ethash

Resumo
Esta prática apresenta os passos para criarmos uma Rede Ethereum Privada Local. Fornecemos um genesis block para inicializar a rede com as características desejadas e depois podemos executá-la para efeitos de testes de desenvolvimento ou se desejarmos ter um Rede privada funcionando. Nesta prática utilizaremos o protocolo Ethash que é o antigo protocolo de prova de trabalho (Prof-of-Work (PoW)), para isso precisamos instalar as ferramentas e aplicações de acordo com a versão que suportava tal protocolo.

5.1 Introdução

O objetivo dessa prática é criarmos uma Rede Ethereum Privada. Podemos criar uma rede privada local utilizando o algoritmo de consenso por Proof-of-Work (PoW) que é o ethash. Outro protocolo de consenso é o clique que funciona PoA ou Proof-of-Authority (PoS). O casper é o algoritmo de consenso Proof of Stake (PoS) atual da Ethereum.

A rede Ethereum iniciou usando um mecanismo de consenso que envolve Proof-of-Work (PoW). Entretanto, Ethereum depreciou o uso de Proof-of-Work em \(2022\) e iniciou o uso de Proof-of-Stake.

Leia mais em Proof-of-Stake e staking.

5.2 Ferramentas e Versões

Para utilizarmos o algoritmo de consenso Prof-of-Work (PoW), o ethash é necessário instalarmos o geth na versão 1.11.6, pois a partir da versão 1.12 o ethash não é mais suportado. No link https://github.com/ethereum/go-ethereum/releases temos todas as versões, a versão corrente é a Impact Restrictors (v1.16.3).

Antes de baixarmos os fontes do geth da versão 1.11 precisaremos instalar o go. Para compilar os fontes do geth é necessário ter o go versão 1.21.1 instalado. Pode ser instalado o pacote do sistema (golang-go no Ubuntu ou go no Manjaro) ou baixando os binários de golang, go versão 1.21.1.

Se a versão do sistema não for a 1.21.*:

$ go version
go version go1.21.0 linux/amd64
$ 

Será necessário baixar e instalar a partir dos binários:

  1. Remova a instalação prévia do Go deletando o diretório /usr/local/go1.21.1, se existir, então extraia o arquivo baixado dentro do diretório /usr/local, criando uma subárvore em /usr/local/go1.21.1 ou caso não tenha permissão, crie dentro da pasta home do seu usuário:
$ cd /usr/local
$ wget https://go.dev/dl/go1.21.1.linux-amd64.tar.gz
$ rm -rf /usr/local/go1.21.1 && tar -C /usr/local -xzf go1.21.1.linux-amd64.tar.gz && mv go go1.21.1
$ ln -s go1.21.1 go

​(Você pode precisar executar o comando como root ou usando o sudo).

Não descompactar o arquivo dentro de uma subárvore /usr/local/go existente. Isso pode produzir instalações Go quebradas.

​2. Adicione /usr/local/go/bin para a variável de ambiente PATH. Você pode fazer isso adicionando a linha de comando para o seu $HOME/.profile ou /etc/profile (para uma instalação ampla no sistema):

export PATH=/usr/local/go/bin:$PATH         

Nota: Mudanças feitas no arquivo de profile podem não ser aplicadas até a próxima vez que você fizer login no computador. Para aplicar as mudanças imediatamente, execute os comandos diretamente em um terminal ou execute eles do profile usando o comando source $HOME/.profile.

​3. Verifique que a versão correta do Go foi instalada:

$ go version          
  1. Confirme que o comando imprime a versão do Go instalado.

Para instalarmos o geth a partir do repositório a versão Azimir (v1.11.6), basta acessarmos o repositório do Github e baixar na pasta do seu usuário:

$ git clone -b 'v1.11.6' --single-branch --depth 1 https://github.com/ethereum/go-ethereum.git go-ethereum-1.11.6

$ cd go-ethereum-1.11.6
[go-ethereum-1.11.6]$ make all

Após a compilação os binários estarão disponíveis no diretório go-ethereum-1.11.6/build/bin:

[go-ethereum-1.11.6]$ ls build/bin
abidump  bootnode          clef    ethkey  faucet  p2psim
abigen   checkpoint-admin  devp2p  evm     geth    rlpdump
[go-ethereum-1.11.6]$

Sendo necessário considerar esse caminho dos binários para acessar os executáveis da versão correta nesta prática: /home/rag/go-ethereum-1.11.6/build/bin.

5.3 Criando uma Rede Privada Local

Para a criação de uma nova Rede Privada Local é necessário fazermos algumas configuraçãos. Precisamos criar um diretório mkdir ~/.etherprivate-ethash para ser a base de armazenamento da nova rede. As configurações iniciais devem ser fornecidas em um genesis file. Então criamos o arquivo privategenesis.json em ~/.etherprivate-ethash.

NotePassos
  1. Criar um diretório mkdir ~/.etherprivate-ethash
  2. Criar um arquivo privategenesis.json em ~/.etherprivate-ethash.

O conteúdo do arquivo privategenesis.json deve ser o listado no Código 6.I.

Listing 5.I: Genesis File
{
  "config": {
    "chainId": 786,
    "homesteadBlock": 0,
    "eip150Block": 0,
    "eip155Block": 0,
    "eip158Block": 0,
    "byzantiumBlock": 0,
    "constantinopleBlock": 0,
    "petersburgBlock": 0,
    "istanbulBlock": 0,
    "berlinBlock": 0,
    "ethash": {}
  },  
  "nonce": "0x0000000000000042",
  "timestamp": "0x00",
  "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "extraData": "0x00",
  "gasLimit": "0x8000000",
  "difficulty": "0x0400",
  "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "coinbase": "0x3333333333333333333333333333333333333333",
  "alloc": {}
}

Utilizando as configurações fornecidas no Código 6.I a rede será criada sem nenhum usuário, o "alloc": {} vazio indica isso. Será possível criar posteriormente conforme descrito na Seção 5.6.

Uma outra forma de estabelecer a configuração inicial da rede com contas com valores alocados, é criando o usuário antes de inicializar a rede com as configurações do Genesis File, conforme o Código 6.II.

Listing 5.II: Criando Usuário para iniciar a rede
[.etherprivate-ethash]$ /home/rag/go-ethereum-1.11.6/build/bin/geth --networkid 786 --datadir ~/.etherprivate-ethash/ account new
INFO [04-19|16:22:04.258] Maximum peer count                       ETH=50 LES=0 total=50
INFO [04-19|16:22:04.258] Smartcard socket not found, disabling    err="stat /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: 
Repeat password: 

Your new key was generated

Public address of the key:   0x2db017e44b03b37755a4b15e14cd799f83de4c13
Path of the secret key file: /home/rag/.etherprivate-ethash/keystore/UTC--2023-04-17T12-22-11.261468773Z--2db017e44b03b37755a4b15e14cd799f83de4c13

- 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!

Com um id da conta criada (0x2db017e44b03b37755a4b15e14cd799f83de4c13) é possível completarmos algumas informações para inicializar a nova rede. Altere o conteúdo do arquivo privategenesis.json tal como listado no Código 6.III.

Listing 5.III: Genesis File Atualizado
{
  "config": {
    "chainId": 786,
    "homesteadBlock": 0,
    "eip150Block": 0,
    "eip155Block": 0,
    "eip158Block": 0,
    "byzantiumBlock": 0,
    "constantinopleBlock": 0,
    "petersburgBlock": 0,
    "istanbulBlock": 0,
    "berlinBlock": 0,
    "ethash": {}
  },  
  "nonce": "0x0000000000000042",
  "timestamp": "0x00",
  "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "extraData": "0x00",
  "gasLimit": "0x8000000",
  "difficulty": "0x0400",
  "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "coinbase": "0x2db017e44b03b37755a4b15e14cd799f83de4c13",
  "alloc": {
    "2db017e44b03b37755a4b15e14cd799f83de4c13": { "balance": "300000" }
  }
}

Após a configuração inicial no Genesis File, o geth é utilizado para a criação e inicialização da nova Rede sendo executado com os parâmetros --datadir, indicando o diretório onde os dados da nova rede serão armazenados e com o init indicando o caminho para o Genesis File, conforme o Código 5.IV.

Listing 5.IV: Inicialização da Rede Privada Local
[.etherprivate-ethash]$ /home/rag/go-ethereum-1.11.6/build/bin/geth --networkid 786 --identity "RAGEtherPrivate" --datadir ~/.etherprivate-ethash init ~/.etherprivate-ethash/privategenesis.json
INFO [09-10|18:22:14.423] Maximum peer count                       ETH=50 LES=0 total=50
INFO [09-10|18:22:14.426] Smartcard socket not found, disabling    err="stat /run/pcscd/pcscd.comm: no such file or directory"
INFO [09-10|18:22:14.430] Set global gas cap                       cap=50,000,000
INFO [09-10|18:22:14.431] Using pebble as the backing database 
INFO [09-10|18:22:14.431] Allocated cache and file handles         database=/home/rag/.etherprivate-ethash/geth/chaindata cache=16.00MiB handles=16
INFO [09-10|18:22:14.496] Opened ancient database                  database=/home/rag/.etherprivate-ethash/geth/chaindata/ancient/chain readonly=false
INFO [09-10|18:22:14.496] Persisted trie from memory database      nodes=1 size=142.00B time="10.896us" gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [09-10|18:22:14.496] Freezer shutting down 
INFO [09-10|18:22:14.502] Successfully wrote genesis state         database=chaindata hash=c4bd3f..d74cb0
INFO [09-10|18:22:14.502] Using pebble as the backing database 
INFO [09-10|18:22:14.502] Allocated cache and file handles         database=/home/rag/.etherprivate-ethash/geth/lightchaindata cache=16.00MiB handles=16
INFO [09-10|18:22:14.555] Opened ancient database                  database=/home/rag/.etherprivate-ethash/geth/lightchaindata/ancient/chain readonly=false
INFO [09-10|18:22:14.556] Persisted trie from memory database      nodes=1 size=142.00B time="21.093us" gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [09-10|18:22:14.563] Successfully wrote genesis state         database=lightchaindata hash=c4bd3f..d74cb0
[.etherprivate-ethash]$

5.4 Executando a nova Rede

Ao tentar iniciar o cliente Geth com a nova rede privada utilizando o algoritmo de consenso da PoW, o ethash conforme o Código 5.V.

Listing 5.V: Execução da Nova Rede Privada Local
[.etherprivate-ethash]$ /home/rag/go-ethereum-1.11.6/build/bin/geth --identity "RAGEtherPrivate" --datadir ~/.etherprivate-ethash
INFO [09-10|19:06:06.995] Starting Geth on Ethereum mainnet... 
INFO [09-10|19:06:06.996] Bumping default cache on mainnet         provided=1024 updated=4096
INFO [09-10|19:06:06.997] Maximum peer count                       ETH=50 LES=0 total=50
INFO [09-10|19:06:06.998] Smartcard socket not found, disabling    err="stat /run/pcscd/pcscd.comm: no such file or directory"
INFO [09-10|19:06:07.000] Set global gas cap                       cap=50,000,000
INFO [09-10|19:06:07.003] Allocated trie memory caches             clean=614.00MiB dirty=1024.00MiB
INFO [09-10|19:06:07.004] Using pebble as the backing database 
INFO [09-10|19:06:07.004] Allocated cache and file handles         database=/home/rag/.etherprivate-ethash/geth/chaindata cache=2.00GiB handles=262,144
INFO [09-10|19:06:07.066] Opened ancient database                  database=/home/rag/.etherprivate-ethash/geth/chaindata/ancient/chain readonly=false
INFO [09-10|19:06:07.067] Disk storage enabled for ethash caches   dir=/home/rag/.etherprivate-ethash/geth/ethash count=3
INFO [09-10|19:06:07.067] Disk storage enabled for ethash DAGs     dir=/home/rag/.ethash                   count=2
INFO [09-10|19:06:07.067] Initialising Ethereum protocol           network=1 dbversion=8
INFO [09-10|19:06:07.067]  
INFO [09-10|19:06:07.067] --------------------------------------------------------------------------------------------------------------------------------------------------------- 
INFO [09-10|19:06:07.067] Chain ID:  786 (unknown) 
INFO [09-10|19:06:07.067] Consensus: Ethash (proof-of-work) 
INFO [09-10|19:06:07.067]  
INFO [09-10|19:06:07.067] Pre-Merge hard forks (block based): 
INFO [09-10|19:06:07.067]  - Homestead:                   #0        (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/homestead.md) 
INFO [09-10|19:06:07.067]  - Tangerine Whistle (EIP 150): #0        (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/tangerine-whistle.md) 
INFO [09-10|19:06:07.067]  - Spurious Dragon/1 (EIP 155): #0        (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/spurious-dragon.md) 
INFO [09-10|19:06:07.067]  - Spurious Dragon/2 (EIP 158): #0        (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/spurious-dragon.md) 
INFO [09-10|19:06:07.067]  - Byzantium:                   #0        (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/byzantium.md) 
INFO [09-10|19:06:07.067]  - Constantinople:              #0        (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/constantinople.md) 
INFO [09-10|19:06:07.067]  - Petersburg:                  #0        (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/petersburg.md) 
INFO [09-10|19:06:07.067]  - Istanbul:                    #0        (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/istanbul.md) 
INFO [09-10|19:06:07.067]  - Berlin:                      #0        (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/berlin.md) 
INFO [09-10|19:06:07.067]  - London:                      #<nil> (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/london.md) 
INFO [09-10|19:06:07.067]  
INFO [09-10|19:06:07.067] The Merge is not yet available for this network! 
INFO [09-10|19:06:07.067]  - Hard-fork specification: https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/paris.md 
INFO [09-10|19:06:07.067]  
INFO [09-10|19:06:07.067] Post-Merge hard forks (timestamp based): 
INFO [09-10|19:06:07.067]  
INFO [09-10|19:06:07.067] --------------------------------------------------------------------------------------------------------------------------------------------------------- 
INFO [09-10|19:06:07.067]  
INFO [09-10|19:06:07.068] Loaded most recent local block           number=33 hash=193b06..bc9c89 td=4,360,192 age=21m43s
INFO [09-10|19:06:07.073] Loaded local transaction journal         transactions=0 dropped=0
INFO [09-10|19:06:07.074] Regenerated local transaction journal    transactions=0 accounts=0
WARN [09-10|19:06:07.074] Switch sync mode from snap sync to full sync 
INFO [09-10|19:06:07.076] Gasprice oracle is ignoring threshold set threshold=2
WARN [09-10|19:06:07.077] Engine API enabled                       protocol=eth
WARN [09-10|19:06:07.077] Engine API started but chain not configured for merge yet 
INFO [09-10|19:06:07.077] Starting peer-to-peer node               instance=Geth/RAGEtherPrivate/v1.11.6-stable-ea9e62ca/linux-amd64/go1.21.1
INFO [09-10|19:06:07.111] New local node record                    seq=1,726,003,870,539 id=3eabcf4667e9d0bc ip=127.0.0.1 udp=30303 tcp=30303
INFO [09-10|19:06:07.111] Started P2P networking                   self=enode://d5c0dbca4edd303126eb0bdbc448848390f0998843381703ca91a4850e63e9e561899e03834e0c9c7e60e357acb34351d9e9da9a59b403faa7559938188bf78b@127.0.0.1:30303
INFO [09-10|19:06:07.112] IPC endpoint opened                      url=/home/rag/.etherprivate-ethash/geth.ipc
INFO [09-10|19:06:07.112] Loaded JWT secret file                   path=/home/rag/.etherprivate-ethash/geth/jwtsecret crc32=0x3d38500f
INFO [09-10|19:06:07.113] WebSocket enabled                        url=ws://127.0.0.1:8551
INFO [09-10|19:06:07.113] HTTP server started                      endpoint=127.0.0.1:8551 auth=true prefix= cors=localhost vhosts=localhost
INFO [09-10|19:06:17.529] Looking for peers                        peercount=0 tried=13 static=0
INFO [09-10|19:06:27.770] Looking for peers                        peercount=0 tried=24 static=0
INFO [09-10|19:06:37.860] Looking for peers                        peercount=1 tried=37 static=0
INFO [09-10|19:06:47.862] Looking for peers                        peercount=0 tried=31 static=0
WARN [09-10|19:06:49.748] Served eth_coinbase                      reqid=3 duration="42.046us" err="etherbase must be explicitly specified"
INFO [09-10|19:06:58.194] Looking for peers                        peercount=0 tried=29 static=0
INFO [09-10|19:07:08.265] Looking for peers                        peercount=0 tried=35 static=0
INFO [09-10|19:07:16.871] Updated mining threads                   threads=16
INFO [09-10|19:07:16.872] Transaction pool price threshold updated price=1,000,000,000
ERROR[09-10|19:07:16.872] Cannot start mining without etherbase    err="etherbase must be explicitly specified"
WARN [09-10|19:07:16.872] Served miner_start                       reqid=11 duration="194.024us" err="etherbase missing: etherbase must be explicitly specified"

Com o protocolo ethash é preciso indicar uma conta para receber as recompensas de mineração, utilize o parâmetro --miner.etherbase=0x2db017e44b03b37755a4b15e14cd799f83de4c13 para indicar a conta principal que foi criada. O Código 5.VI apresenta a linha de comando atualizada.

Listing 5.VI: Execução da Nova Rede Privada Local
[.etherprivate-ethash]$ /home/rag/go-ethereum-1.11.6/build/bin/geth --networkid 786 --datadir ~/.etherprivate-ethash/ --syncmode full --allow-insecure-unlock --http --http.addr 127.0.0.1 --http.port 8559 --http.api "eth,net,web3,personal,engine,admin,debug" --keystore ~/.etherprivate-ethash/keystore --authrpc.addr localhost --authrpc.port 8551 --authrpc.vhosts localhost --authrpc.jwtsecret ~/.etherprivate-ethash/geth/jwtsecret --nodiscover --maxpeers 15 --miner.etherbase=0x2db017e44b03b37755a4b15e14cd799f83de4c13

5.5 Interagindo com a nova Rede

O console JavaScript pode ser utilizado na interação com a instância da nova rede em execução. O comando apresentado no Código 5.VII inicia uma console vinculado à instância do geth em execução.

Listing 5.VII: Execução da Nova Rede Privada Local
$ /home/rag/go-ethereum-1.11.6/build/bin/geth attach ~/.etherprivate-ethash/geth.ipc

5.6 Criando contas na nova Rede

Vamos criar duas contas para testes na nova rede. Utilizaremos para fins de teste a senha “admin12345”. O Código abaixo mostra a execução quando era possível utilizar o método personal.newAccount(...) via console JavaScript. Em versões anteriores era possível criar contas diretamente no console conforme (Código Listing 5.VIII).

Listing 5.VIII: Criando Contas pelo Console
> personal.newAccount("admin12345")
"0xedbc36d74d5a1cd64db36e53798bd1781f0c4955"

> eth.accounts
["0xedbc36d74d5a1cd64db36e53798bd1781f0c4955"]

>  personal.newAccount("admin12345")

"0x1478d95f8754b3ba7127100dd0bb46578fe7d22a"

> eth.accounts
["0xedbc36d74d5a1cd64db36e53798bd1781f0c4955", "0x1478d95f8754b3ba7127100dd0bb46578fe7d22a"]

Na versão utilizada na prática e seguintes isso não é mais possível, pois o personal foi depreciado:

>  personal.newAccount("admin12345")
ReferenceError: personal is not defined
        at <eval>:1:2(0)

Com a depreciação do personal é recomendado utilizar o clef com o parâmetro newaccount. É importante indicar o diretório keystore do .etherprivate-ethash.

Se seguimos a opção de criar uma conta antes para configurar o genesis file nossa base já terá uma conta. Essa conta pode ser verificada utilizando o geth --networkid 786 --datadir ~/.etherprivate-ethash/ account ou o comando do clef conforme apresentado no Código 5.IX.

Listing 5.IX: Iniciando o clef
$ /home/rag/go-ethereum-1.11.6/build/bin/clef list-accounts --keystore ~/.etherprivate-ethash/keystore

WARNING!

Clef is an account management tool. It may, like any software, contain bugs.

Please take care to
- backup your keystore files,
- verify that the keystore(s) can be opened with your password.

Clef is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.

Enter 'ok' to proceed:
> ok

0x2db017E44b03B37755A4b15e14Cd799f83DE4c13 (keystore:///home/rag/.etherprivate-ethash/keystore/UTC--2023-04-17T12-22-11.261468773Z--2db017e44b03b37755a4b15e14cd799f83de4c13)

A conta 0x2db017E44b03B37755A4b15e14Cd799f83DE4c13 que foi gerada, utilizei a senha admin12345. Uma segunda conta pode ser criada com o mesmo comando conforme apresentado no Código 5.X.

Listing 5.X: Criando uma nova conta com o clef
[.etherprivate-ethash]$ clef newaccount --keystore keystore

WARNING!

Clef is an account management tool. It may, like any software, contain bugs.

Please take care to
- backup your keystore files,
- verify that the keystore(s) can be opened with your password.

Clef is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.

Enter 'ok' to proceed:
> ok

## New account password

Please enter a password for the new account to be created (attempt 0 of 3)
> 
-----------------------
INFO [04-17|09:28:56.607] Your new key was generated               address=0x7A7686aD451d2865A2246E239B674aeFd4c6c27c
WARN [04-17|09:28:56.607] Please backup your key file!             path=/home/rag/.etherprivate-ethash/keystore/UTC--2023-04-17T12-28-54.934614755Z--7a7686ad451d2865a2246e239b674aefd4c6c27c
WARN [04-17|09:28:56.607] Please remember your password! 
Generated account 0x7A7686aD451d2865A2246E239B674aeFd4c6c27c
[.etherprivate-ethash]$

É para termos duas contas criadas, que na minha máquina são: 0x2db017E44b03B37755A4b15e14Cd799f83DE4c13 e 0x7A7686aD451d2865A2246E239B674aeFd4c6c27c, ambas com a senha admin12345.

Verifiquemos no console JavaScript se elas são listadas:

[.etherprivate-ethash]$ /home/rag/go-ethereum-1.11.6//build/bin/geth attach ~/.etherprivate-ethash/geth.ipc
Welcome to the Geth JavaScript console!

instance: Geth/v1.11.5-stable-a38f4108/linux-amd64/go1.20.2
at block: 0 (Wed Dec 31 1969 21:00:00 GMT-0300 (-03))
 datadir: /home/rag/.etherprivate-ethash
 modules: admin:1.0 debug:1.0 engine:1.0 eth:1.0 ethash: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
["0x2db017e44b03b37755a4b15e14cd799f83de4c13", "0x7a7686ad451d2865a2246e239b674aefd4c6c27c"]
> 

5.7 Verificando o Saldo das Carteiras

Vamos verificar os valores em cada uma das carteiras:

[.etherprivate-ethash]$ ~/go-ethereum-1.11.6/build/bin/geth attach ~/.etherprivate-ethash/geth.ipc
Welcome to the Geth JavaScript console!

instance: Geth/v1.11.6-stable-ea9e62ca/linux-amd64/go1.21.1
coinbase: 0x2db017e44b03b37755a4b15e14cd799f83de4c13
at block: 90 (Tue Sep 10 2024 19:15:48 GMT-0300 (-03))
 datadir: /home/rag/.etherprivate-ethash
 modules: admin:1.0 debug:1.0 engine:1.0 eth:1.0 ethash: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
["0x2db017e44b03b37755a4b15e14cd799f83de4c13", "0x7a7686ad451d2865a2246e239b674aefd4c6c27c"]
>
> web3.fromWei(eth.getBalance("0x2db017e44b03b37755a4b15e14cd799f83de4c13"), "ether")
0
> web3.fromWei(eth.getBalance("0x7a7686ad451d2865a2246e239b674aefd4c6c27c"), "ether")
0
> 

Se criamos a primeira conta antes da configuração do genesis file, alocamos para ela \(300000\) então a consulta de valores iniciais terá resultado diferente.

> eth.accounts
["0x2db017e44b03b37755a4b15e14cd799f83de4c13", "0x7a7686ad451d2865a2246e239b674aefd4c6c27c"]
> eth.getBalance(eth.accounts[0])
300000
> eth.getBalance(eth.accounts[1])
0
> web3.fromWei(eth.getBalance("0x2db017e44b03b37755a4b15e14cd799f83de4c13"), "ether")
3e-13
> web3.fromWei(eth.getBalance("0x7a7686ad451d2865a2246e239b674aefd4c6c27c"), "ether")
0
> 

5.8 Gerar algum Saldo para as Carteiras

Se não alocamos nenhuma valor para alguma conta criada antes da inicialização da rede, para acumular algum valor é necessário minerar.

Vamos iniciar o geth indicando a carteira que irá receber as recompensas pela mineração utilizando o parâmetro --miner.etherbase, utilizei aqui a primeira conta criada 0x2db017e44b03b37755a4b15e14cd799f83de4c13. Note que é possível colocar uma identificação para sua rede com o parâmetro --identity "RAGEtherPrivate".

[.etherprivate-ethash]$ ~/go-ethereum-1.11.6/build/bin/geth --networkid 786 --datadir ~/.etherprivate-ethash/ --syncmode full --allow-insecure-unlock --http --http.addr 127.0.0.1 --http.port 8559 --http.api "eth,net,web3,personal,engine,admin,debug" --keystore ~/.etherprivate-ethash/keystore --authrpc.addr localhost --authrpc.port 8551 --authrpc.vhosts localhost --authrpc.jwtsecret ~/.etherprivate-ethash/geth/jwtsecret --nodiscover --maxpeers 15 --miner.etherbase=0x2db017e44b03b37755a4b15e14cd799f83de4c13

O cliente geth irá iniciar normalmente.

Em um console JavaScript vamos verificar o saldo inicial e iniciar a mineração.

[.etherprivate-ethash]$ ~/go-ethereum-1.11.6/build/bin/geth attach ~/.etherprivate-ethash/geth.ipc
Welcome to the Geth JavaScript console!

instance: Geth/v1.11.6-stable-ea9e62ca/linux-amd64/go1.21.1
coinbase: 0x2db017e44b03b37755a4b15e14cd799f83de4c13
at block: 90 (Tue Sep 10 2024 19:15:48 GMT-0300 (-03))
 datadir: /home/rag/.etherprivate-ethash
 modules: admin:1.0 debug:1.0 engine:1.0 eth:1.0 ethash: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

["0x2db017e44b03b37755a4b15e14cd799f83de4c13", "0x7a7686ad451d2865a2246e239b674aefd4c6c27c"]
> web3.fromWei(eth.getBalance("0x2db017e44b03b37755a4b15e14cd799f83de4c13"), "ether")
0
> miner.start()

null
> web3.fromWei(eth.getBalance("0x2db017e44b03b37755a4b15e14cd799f83de4c13"), "ether")
2890
>

5.9 Transferências entre as Carteiras

Vamos enviar \(100\) ethers da primeira para a segunda carteira.

> eth.sendTransaction({from: "0x2db017e44b03b37755a4b15e14cd799f83de4c13", to: "0x7a7686ad451d2865a2246e239b674aefd4c6c27c", value: 100})
[.etherprivate-ethash]$ /home/rag/go-ethereum-1.11.6/build/bin/geth attach ~/.etherprivate-ethash/geth.ipc
Welcome to the Geth JavaScript console!

instance: Geth/v1.11.6-stable-ea9e62ca/linux-amd64/go1.21.1
coinbase: 0x2db017e44b03b37755a4b15e14cd799f83de4c13
at block: 90 (Tue Sep 10 2024 19:15:48 GMT-0300 (-03))
 datadir: /home/rag/.etherprivate-ethash
 modules: admin:1.0 debug:1.0 engine:1.0 eth:1.0 ethash: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

["0x2db017e44b03b37755a4b15e14cd799f83de4c13", "0x7a7686ad451d2865a2246e239b674aefd4c6c27c"]
> web3.fromWei(eth.getBalance("0x2db017e44b03b37755a4b15e14cd799f83de4c13"), "ether")
0
> miner.start()

null
> web3.fromWei(eth.getBalance("0x2db017e44b03b37755a4b15e14cd799f83de4c13"), "ether")
2890
> miner.stop()

null
> web3.fromWei(eth.getBalance("0x7a7686ad451d2865a2246e239b674aefd4c6c27c"), "ether")
0
> web3.fromWei(eth.getBalance("0x7a7686ad451d2865a2246e239b674aefd4c6c27c"), "ether")
0
> web3.fromWei(eth.getBalance("0x2db017e44b03b37755a4b15e14cd799f83de4c13"), "ether")
4335
> eth.sendTransaction({from: "0x2db017e44b03b37755a4b15e14cd799f83de4c13", to: "0x7a7686ad451d2865a2246e239b674aefd4c6c27c", value: 100})
Error: authentication needed: password or unlock
        at web3.js:6365:9(39)
        at send (web3.js:5099:62(29))
        at <eval>:1:20(9)

> personal.unlockAccount(eth.accounts[0])


ReferenceError: personal is not defined
        at <eval>:1:1(0)

> eth.accounts
["0x2db017e44b03b37755a4b15e14cd799f83de4c13", "0x7a7686ad451d2865a2246e239b674aefd4c6c27c"]
> eth.sendTransaction({to: '0x7a7686ad451d2865a2246e239b674aefd4c6c27c', from: eth.accounts[0], value: 100});
Error: authentication needed: password or unlock
        at web3.js:6365:9(39)
        at send (web3.js:5099:62(29))
        at <eval>:1:20(12)

> eth.sendTransaction({
  to: '0x7a7686ad451d2865a2246e239b674aefd4c6c27c',
  from: eth.accounts[0],
> eth.accounts

["0x2db017e44b03b37755a4b15e14cd799f83de4c13", "0x7a7686ad451d2865a2246e239b674aefd4c6c27c"]

O erro “Error: authentication needed: password or unlock” ocorre por que precisamos autorizar a transação. Em versões anteriores era possível desbloquear as contas via console JavaScript, conforme tentamos no Código acima personal.unlockAccount(eth.accounts[0]). Como o personal foi depreciado não pode ser mais utilizado.

É preciso utilizar o clef para fazer a autenticação em um console. Sendo assim, em um outro terminal inicie a instância do clef com o comando:

[.etherprivate-ethash]$ /home/rag/go-ethereum-1.11.6/build/bin/clef --chainid 786 --keystore ~/.etherprivate-ethash/keystore --configdir ~/.etherprivate-ethash/clef --http

WARNING!

Clef is an account management tool. It may, like any software, contain bugs.

Please take care to
- backup your keystore files,
- verify that the keystore(s) can be opened with your password.

Clef is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.

Enter 'ok' to proceed:
> ok

INFO [04-17|10:23:09.630] Using CLI as UI-channel 
INFO [04-17|10:23:10.050] Loaded 4byte database                    embeds=268,621 locals=0 local=./4byte-custom.json
WARN [04-17|10:23:10.050] Failed to open master, rules disabled    err="failed stat on /home/rag/.etherprivate-ethash/clef/masterseed.json: stat /home/rag/.etherprivate-ethash/clef/masterseed.json: no such file or directory"
INFO [04-17|10:23:10.050] Starting signer                          chainid=786 keystore=/home/rag/.etherprivate-ethash/keystore light-kdf=false advanced=false
INFO [04-17|10:23:10.052] Smartcard socket file missing, disabling err="stat /run/pcscd/pcscd.comm: no such file or directory"
INFO [04-17|10:23:10.052] Audit logs configured                    file=audit.log
INFO [04-17|10:23:10.053] HTTP endpoint opened                     url=http://127.0.0.1:8550/
INFO [04-17|10:23:10.053] IPC endpoint opened                      url=/home/rag/.etherprivate-ethash/clef/clef.ipc

------- Signer info -------
* extapi_version : 6.1.0
* extapi_http : http://127.0.0.1:8550/
* extapi_ipc : /home/rag/.etherprivate-ethash/clef/clef.ipc
* intapi_version : 7.0.1

------- Available accounts -------
0. 0x2db017E44b03B37755A4b15e14Cd799f83DE4c13 at keystore:///home/rag/.etherprivate-ethash/keystore/UTC--2023-04-17T12-22-11.261468773Z--2db017e44b03b37755a4b15e14cd799f83de4c13
1. 0x7A7686aD451d2865A2246E239B674aeFd4c6c27c at keystore:///home/rag/.etherprivate-ethash/keystore/UTC--2023-04-17T12-28-54.934614755Z--7a7686ad451d2865a2246e239b674aefd4c6c27c
-------- List Account request--------------
A request has been made to list all accounts. 
You can select which accounts the caller can see
  [x] 0x2db017E44b03B37755A4b15e14Cd799f83DE4c13
    URL: keystore:///home/rag/.etherprivate-ethash/keystore/UTC--2023-04-17T12-22-11.261468773Z--2db017e44b03b37755a4b15e14cd799f83de4c13
  [x] 0x7A7686aD451d2865A2246E239B674aeFd4c6c27c
    URL: keystore:///home/rag/.etherprivate-ethash/keystore/UTC--2023-04-17T12-28-54.934614755Z--7a7686ad451d2865a2246e239b674aefd4c6c27c
-------------------------------------------

E volte ao terminal onde iniciou o geth e indique que as autentificações serão via clef com o parâmetro --signer=/home/rag/.etherprivate-ethash/clef/clef.ipc passando o caminho dado pelo clef.

[.etherprivate-ethash]$ geth --networkid 786 --datadir ~/.etherprivate-ethash/ --syncmode full --allow-insecure-unlock  --identity "RAGEtherPrivate"  --http --http.addr 127.0.0.1 --http.port 8559 --http.api "eth,net,web3,personal,engine,admin,debug" --keystore ~/.etherprivate-ethash/keystore --authrpc.addr localhost --authrpc.port 8551 --authrpc.vhosts localhost --authrpc.jwtsecret ~/.etherprivate-ethash/geth/jwtsecret --nodiscover --maxpeers 15 --miner.etherbase=0x2db017e44b03b37755a4b15e14cd799f83de4c13 --signer=/home/rag/.etherprivate-ethash/clef/clef.ipc

Cada transação executada no console JavaScript deverá ser autorizada no console do clef.


> eth.sendTransaction({
  to: '0x7a7686ad451d2865a2246e239b674aefd4c6c27c',
  from: eth.accounts[0],
> eth.accounts

["0x2db017e44b03b37755a4b15e14cd799f83de4c13", "0x7a7686ad451d2865a2246e239b674aefd4c6c27c"]
> eth.sendTransaction({
  to: '0x7a7686ad451d2865a2246e239b674aefd4c6c27c',
  from: eth.accounts[0],
  value: 100
});
"0xb579cc595601e4aca546ce4e46bdcded7841bd7f50a0a78c505e839dd039b8b9"
> eth.sendTransaction({
  to: '0x7a7686ad451d2865a2246e239b674aefd4c6c27c',
  from: eth.accounts[0],
> eth.sendTransaction({
  to: '0x7a7686ad451d2865a2246e239b674aefd4c6c27c',
  from: eth.accounts[0],
> eth.getBalance(eth.accounts[1])
0

No console do clef é possível autorizar e ver a transação assinada com hash: 0xb579cc595601e4aca546ce4e46bdcded7841bd7f50a0a78c505e839dd039b8b9 que é o mesmo id devolvido no console JavaScript.

-------- List Account request--------------
A request has been made to list all accounts. 
You can select which accounts the caller can see
  [x] 0x2db017E44b03B37755A4b15e14Cd799f83DE4c13
    URL: keystore:///home/rag/.etherprivate-ethash/keystore/UTC--2023-04-17T12-22-11.261468773Z--2db017e44b03b37755a4b15e14cd799f83de4c13
  [x] 0x7A7686aD451d2865A2246E239B674aeFd4c6c27c
    URL: keystore:///home/rag/.etherprivate-ethash/keystore/UTC--2023-04-17T12-28-54.934614755Z--7a7686ad451d2865a2246e239b674aefd4c6c27c
-------------------------------------------
Request context:
        NA -> ipc -> NA

Additional HTTP header data, provided by the external caller:
        User-Agent: ""
        Origin: ""
Approve? [y/N]:
> y
-------- List Account request--------------
A request has been made to list all accounts. 
You can select which accounts the caller can see
  [x] 0x2db017E44b03B37755A4b15e14Cd799f83DE4c13
    URL: keystore:///home/rag/.etherprivate-ethash/keystore/UTC--2023-04-17T12-22-11.261468773Z--2db017e44b03b37755a4b15e14cd799f83de4c13
  [x] 0x7A7686aD451d2865A2246E239B674aeFd4c6c27c
    URL: keystore:///home/rag/.etherprivate-ethash/keystore/UTC--2023-04-17T12-28-54.934614755Z--7a7686ad451d2865a2246e239b674aefd4c6c27c
-------------------------------------------
Request context:
        NA -> ipc -> NA

Additional HTTP header data, provided by the external caller:
        User-Agent: ""
        Origin: ""
Approve? [y/N]:
> y
--------- Transaction request-------------
to:    0x7A7686aD451d2865A2246E239B674aeFd4c6c27c
from:               0x2db017E44b03B37755A4b15e14Cd799f83DE4c13 [chksum ok]
value:              100 wei
gas:                0x5208 (21000)
gasprice: 1000000000 wei
nonce:    0x0 (0)
chainid:  0x312

Request context:
        NA -> ipc -> NA

Additional HTTP header data, provided by the external caller:
        User-Agent: ""
        Origin: ""
-------------------------------------------
Approve? [y/N]:
> y
\#\# Account password

Please enter the password for account 0x2db017E44b03B37755A4b15e14Cd799f83DE4c13
> 
-----------------------
Transaction signed:
 {
    "type": "0x0",
    "nonce": "0x0",
    "gasPrice": "0x3b9aca00",
    "maxPriorityFeePerGas": null,
    "maxFeePerGas": null,
    "gas": "0x5208",
    "value": "0x64",
    "input": "0x",
    "v": "0x648",
    "r": "0xe497ab329bf31af61f371e2eb251ca979ec8ba45e099318d44468e8703358418",
    "s": "0x518b4e7e5906e4abc86e486523a8ad290727529f240a201905acc84c5f95417f",
    "to": "0x7a7686ad451d2865a2246e239b674aefd4c6c27c",
    "hash": "0xb579cc595601e4aca546ce4e46bdcded7841bd7f50a0a78c505e839dd039b8b9"
  }

No console JavaScript é possível recuperar o recibo da transação:

eth.getTransactionReceipt("0xb579cc595601e4aca546ce4e46bdcded7841bd7f50a0a78c505e839dd039b8b9")
{
  blockHash: "0x6756c8d89be5a01ff3d300eab5c50add20a2bca691221c4690fc663336ef2cf8",
  blockNumber: 868,
  contractAddress: null,
  cumulativeGasUsed: 21000,
  effectiveGasPrice: 1000000000,
  from: "0x2db017e44b03b37755a4b15e14cd799f83de4c13",
  gasUsed: 21000,
  logs: [],
  logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  root: "0x9d1d510b5517e7c772e36c67e99d47de6d10c25ba9d24311d39eb85b7db6c071",
  to: "0x7a7686ad451d2865a2246e239b674aefd4c6c27c",
  transactionHash: "0xb579cc595601e4aca546ce4e46bdcded7841bd7f50a0a78c505e839dd039b8b9",
  transactionIndex: 0,
  type: "0x0"
}

É preciso minerar para a transação ser efetivada:

> miner.start()
null
> eth.getBalance(eth.accounts[1])
100
> miner.stop()
null

Ao enviar outra quantida para a segunda conta é preciso autorizar a transação no console do clef e minerar novamente para ela ser efetivada.


> eth.sendTransaction({from: "0x2db017e44b03b37755a4b15e14cd799f83de4c13", to: "0x7a7686ad451d2865a2246e239b674aefd4c6c27c", value: 100})
"0xa4cdfb3d4f5fcd98db211bab41eb15b2eace3cd938250faec9d2c4feac242980"
> eth.getBalance(eth.accounts[1])

100
> miner.start()
null
> eth.getBalance(eth.accounts[1])
200
> miner.stop()

Console do clefpara a segunda transação:

-------- List Account request--------------
A request has been made to list all accounts. 
You can select which accounts the caller can see
  [x] 0x2db017E44b03B37755A4b15e14Cd799f83DE4c13
    URL: keystore:///home/rag/.etherprivate-ethash/keystore/UTC--2023-04-17T12-22-11.261468773Z--2db017e44b03b37755a4b15e14cd799f83de4c13
  [x] 0x7A7686aD451d2865A2246E239B674aeFd4c6c27c
    URL: keystore:///home/rag/.etherprivate-ethash/keystore/UTC--2023-04-17T12-28-54.934614755Z--7a7686ad451d2865a2246e239b674aefd4c6c27c
-------------------------------------------
Request context:
        NA -> ipc -> NA

Additional HTTP header data, provided by the external caller:
        User-Agent: ""
        Origin: ""
Approve? [y/N]:
> y
-------- List Account request--------------
A request has been made to list all accounts. 
You can select which accounts the caller can see
  [x] 0x2db017E44b03B37755A4b15e14Cd799f83DE4c13
    URL: keystore:///home/rag/.etherprivate-ethash/keystore/UTC--2023-04-17T12-22-11.261468773Z--2db017e44b03b37755a4b15e14cd799f83de4c13
  [x] 0x7A7686aD451d2865A2246E239B674aeFd4c6c27c
    URL: keystore:///home/rag/.etherprivate-ethash/keystore/UTC--2023-04-17T12-28-54.934614755Z--7a7686ad451d2865a2246e239b674aefd4c6c27c
-------------------------------------------
Request context:
        NA -> ipc -> NA

Additional HTTP header data, provided by the external caller:
        User-Agent: ""
        Origin: ""
Approve? [y/N]:
> y
--------- Transaction request-------------
to:    0x7A7686aD451d2865A2246E239B674aeFd4c6c27c
from:               0x2db017E44b03B37755A4b15e14Cd799f83DE4c13 [chksum ok]
value:              100 wei
gas:                0x5208 (21000)
gasprice: 1000000000 wei
nonce:    0x1 (1)
chainid:  0x312

Request context:
        NA -> ipc -> NA

Additional HTTP header data, provided by the external caller:
        User-Agent: ""
        Origin: ""
-------------------------------------------
Approve? [y/N]:
> y
\#\# Account password

Please enter the password for account 0x2db017E44b03B37755A4b15e14Cd799f83DE4c13
> 
-----------------------
Transaction signed:
 {
    "type": "0x0",
    "nonce": "0x1",
    "gasPrice": "0x3b9aca00",
    "maxPriorityFeePerGas": null,
    "maxFeePerGas": null,
    "gas": "0x5208",
    "value": "0x64",
    "input": "0x",
    "v": "0x647",
    "r": "0x33d621389272cdbee73d2c50d91b846b325bb2d7b94f2c32d726c6fa21151f9a",
    "s": "0x5510f0a5611c8c7640904b5a489422352fae1517eb7307bb6496468cff545726",
    "to": "0x7a7686ad451d2865a2246e239b674aefd4c6c27c",
    "hash": "0xa4cdfb3d4f5fcd98db211bab41eb15b2eace3cd938250faec9d2c4feac242980"
  }
-------- List Account request--------------
A request has been made to list all accounts. 
You can select which accounts the caller can see
  [x] 0x2db017E44b03B37755A4b15e14Cd799f83DE4c13
    URL: keystore:///home/rag/.etherprivate-ethash/keystore/UTC--2023-04-17T12-22-11.261468773Z--2db017e44b03b37755a4b15e14cd799f83de4c13
  [x] 0x7A7686aD451d2865A2246E239B674aeFd4c6c27c
    URL: keystore:///home/rag/.etherprivate-ethash/keystore/UTC--2023-04-17T12-28-54.934614755Z--7a7686ad451d2865a2246e239b674aefd4c6c27c
-------------------------------------------
Request context:
        NA -> ipc -> NA

Additional HTTP header data, provided by the external caller:
        User-Agent: ""
        Origin: ""
Approve? [y/N]:
> y
-------- List Account request--------------
A request has been made to list all accounts. 
You can select which accounts the caller can see
  [x] 0x2db017E44b03B37755A4b15e14Cd799f83DE4c13
    URL: keystore:///home/rag/.etherprivate-ethash/keystore/UTC--2023-04-17T12-22-11.261468773Z--2db017e44b03b37755a4b15e14cd799f83de4c13
  [x] 0x7A7686aD451d2865A2246E239B674aeFd4c6c27c
    URL: keystore:///home/rag/.etherprivate-ethash/keystore/UTC--2023-04-17T12-28-54.934614755Z--7a7686ad451d2865a2246e239b674aefd4c6c27c
-------------------------------------------
Request context:
        NA -> ipc -> NA

Additional HTTP header data, provided by the external caller:
        User-Agent: ""
        Origin: ""
Approve? [y/N]:
> y

A transação 0xa4cdfb3d4f5fcd98db211bab41eb15b2eace3cd938250faec9d2c4feac242980 foi autorizada e podemos verificar o saldo das carteiras:

> eth.getTransactionReceipt("0xa4cdfb3d4f5fcd98db211bab41eb15b2eace3cd938250faec9d2c4feac242980")
{
  blockHash: "0x89dd3dd5175ca3d85549aeb8387be343ef1cecfd2a96134148f39618c4b587fd",
  blockNumber: 1021,
  contractAddress: null,
  cumulativeGasUsed: 21000,
  effectiveGasPrice: 1000000000,
  from: "0x2db017e44b03b37755a4b15e14cd799f83de4c13",
  gasUsed: 21000,
  logs: [],
  logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  root: "0xfbaf589acffe7f4f701301e31e7549e99e102bfd36145c7f55a38800e3714194",
  to: "0x7a7686ad451d2865a2246e239b674aefd4c6c27c",
  transactionHash: "0xa4cdfb3d4f5fcd98db211bab41eb15b2eace3cd938250faec9d2c4feac242980",
  transactionIndex: 0,
  type: "0x0"
}
> web3.fromWei(eth.getBalance("0x2db017e44b03b37755a4b15e14cd799f83de4c13"), "ether")
5484.9999999999999998
> web3.fromWei(eth.getBalance("0x7a7686ad451d2865a2246e239b674aefd4c6c27c"), "ether")
2e-16
> 

Mais detalhes de como implantar uma rede privada local do Ethereum podem ser visto em Private Networks.

5.10 Comandos Finais

A Figura 9.I apresenta os comandos para cada um dos terminais.

Figure 5.I: Terminais

O comando para o terminal do clef:

[clef]$ /home/rag/go-ethereum-1.11.6/build/bin/clef --chainid 786 --keystore ~/.etherprivate-ethash/keystore --configdir ~/.etherprivate-ethash/clef --http

O comando para o terminal do Geth:

[.etherprivate-ethash]$ /home/rag/go-ethereum-1.11.6/build/bin/geth --networkid 786 --datadir ~/.etherprivate-ethash/ --syncmode full --allow-insecure-unlock  --identity "RAGEtherPrivate"  --http --http.addr 127.0.0.1 --http.port 8559 --http.api "eth,net,web3,personal,engine,admin,debug" --keystore ~/.etherprivate-ethash/keystore --authrpc.addr localhost --authrpc.port 8551 --authrpc.vhosts localhost --authrpc.jwtsecret ~/.etherprivate-ethash/geth/jwtsecret --nodiscover --maxpeers 15 --miner.etherbase=0x2db017e44b03b37755a4b15e14cd799f83de4c13 --signer=/home/rag/.etherprivate-ethash/clef/clef.ipc

O comando para o terminal do prysm: Não precisa!

O comando para o console do JavaScript:

[.etherprivate-ethash]$ /home/rag/go-ethereum-1.11.6/build/bin/geth attach ~/.etherprivate-ethash/geth.ipc 
Welcome to the Geth JavaScript console!

instance: Geth/RAGEtherPrivate/v1.11.6-stable-ea9e62ca/linux-amd64/go1.21.0
coinbase: 0x2db017e44b03b37755a4b15e14cd799f83de4c13
at block: 1476 (Tue Sep 12 2023 17:04:22 GMT-0300 (-03))
 datadir: /home/rag/.etherprivate-ethash
 modules: admin:1.0 debug:1.0 engine:1.0 eth:1.0 ethash: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
> 

5.11 Leitura Recomendada

6 Referências

7 Word Cloud

7.1 Referências