Installation
Docker
Dockerfile
https://hub.docker.com/r/forkblockchain/fork-ethereum/
docker pull forkblockchain/fork-ethereum:latest
or
Docker compose
docker-compose up -d
then
./enter-docker.sh
cd /ethereum
Vagrant
vagrant up --provision
cd /home/ethereum/
Initialization of Chain
geth Commands
./init-genesis.sh
./start-geth.sh
./connect-geth.sh
Account Setup Commands
Create New Account
personal.newAccount();
or (need to specify passpharse as argument in container)
personal.newAccount("YOUR PASSPHRASE");
Show Balance
eth.getBalance(eth.accounts[0]);
Generate DAG and mine coins
miner.start();
miner.stop();
Smart Contract Example
Contract Commands
loadScript("simple.js")
var parsedSimpleContract = web3.eth.contract(JSON.parse(simpleContract.contracts["simple.sol:Simple"].abi));
personal.unlockAccount(eth.accounts[0], "YOUR PASSPHRASE");
Log mined contract
var simpleContract = parsedSimpleContract.new({ from: eth.accounts[0], data: "0x" + simpleContract.contracts["simple.sol:Simple"].bin, gas: 4700000},
function (e, contract) {
console.log(e, contract);
if (typeof contract.address !== 'undefined') {
console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);
}
}
);
Mine contract miner.start();
miner.stop();
Execute locally
simpleContract.multiply.call(9,2);
Execute on evm
simpleContract.multiply.sendTransaction(2,2,{from:eth.accounts[0]})
Process smart contract transaction
miner.start();
miner.stop();
View Logged Events
var simpleContractEvents = simpleContract.allEvents({fromBlock: 0, toBlock: 'latest'});
simpleContractEvents.get(function(error, logs) {
logs.forEach( function(log,error) {
console.log(JSON.stringify(log.args));
})
});
References
Puppeth https://modalduality.org/posts/puppeth/
Private Network https://github.com/ethereum/go-ethereum/wiki/Private-network
Default Bootnodes https://github.com/ethereum/go-ethereum/blob/master/params/bootnodes.go
https://ethereum.stackexchange.com/questions/15435/how-to-compile-solidity-contracts-with-geth-v1-6