Este projeto cria uma rede Ethereum privada usando o Geth com consenso Proof of Authority (Clique).
- Go Ethereum (geth) instalado — https://geth.ethereum.org/docs/install-and-build/installing-geth
- Sistema com pelo menos 2GB de RAM (idealmente 3GB ou mais)
- Terminal com bash ou zsh
- Python 3 para gerar o arquivo genesis
/ethereum-poa
├── data/ # Diretório dos dados da blockchain
├── genesis.json # Arquivo de configuração da rede
├── senha.txt # Senha da conta a ser desbloqueada
├── gera_genesis.py # Scripts úteis, como o de geração do genesis
└── README.md
Você pode gerar o arquivo genesis.json automaticamente com o script Python abaixo.
python3 gera_genesis.py
Atenção: Substitua
"ENDEREÇO_DA_SUA_WALLET"pelo endereço real da sua conta (sem0x).
import json
signer = "ENDEREÇO_DA_SUA_WALLET"
extraData = "0x" + "00" * 32 + signer + "00" * 65
genesis = {
"config": {
"chainId": 1337,
"homesteadBlock": 0,
"eip150Block": 0,
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock": 0,
"berlinBlock": 0,
"londonBlock": 0,
"terminalTotalDifficulty": 1152921504606846976,
"clique": {
"period": 5,
"epoch": 30000
}
},
"nonce": "0x0",
"timestamp": "0x0",
"extraData": extraData,
"gasLimit": "0x1C9C380",
"difficulty": "0x1",
"mixHash": "0x" + "00" * 32,
"coinbase": "0x0000000000000000000000000000000000000000",
"alloc": {
"0x" + signer: {
"balance": "0x56bc75e2d63100000"
}
},
"number": "0x0",
"gasUsed": "0x0",
"parentHash": "0x" + "00" * 32
}
with open("genesis.json", "w") as f:
json.dump(genesis, f, indent=2)
print("Arquivo genesis.json criado com sucesso.")geth --datadir ./data init genesis.json
geth --datadir ./data --networkid 1337 --http --http.addr 0.0.0.0 --http.port 8545 \
--http.api eth,net,web3,miner,admin --unlock 0xENDEREÇO_DA_SUA_WALLET --password senha.txt --mine --allow-insecure-unlock
geth attach ipc:./data/geth.ipc
ou
geth attach http://localhost:8545
eth.getBalance("0xENDEREÇO_DA_SUA_WALLET")
eth.sendTransaction({
from: "0xENDEREÇO_DA_SUA_WALLET",
to: "0xENDEREÇO_DA_WALLET_DESTINO",
value: web3.toWei(1, "ether")
})
// Listar contas disponíveis
eth.accounts
// Ver saldo
eth.getBalance("0xSEU_ENDERECO")
// Ver informações da rede
net.version
eth.blockNumber
// Ver transações de um bloco
eth.getBlock("latest", true)
"alloc": {
"0xENDERECO1": { "balance": "0xDE0B6B3A7640000" },
"0xENDERECO2": { "balance": "0xDE0B6B3A7640000" }
}
- Documentação Geth https://geth.ethereum.org/docs
- Clique PoA https://geth.ethereum.org/docs/interface/consensus/clique
Desenvolvido por Leonardo Toledo
📧 leotoledo010@gmail.com
🔗 github.com/leonardotoledo0
Este projeto está licenciado sob a Licença MIT.
Veja o arquivo LICENSE para detalhes completos.