The below is commands when I start to learn Ethereum/Solidity . Assume that we installed Geth and Solidity Compiler in our machine.
Install Ethereum
1 2 3 4 |
apt-get install software-properties-common add-apt-repository -y ppa:ethereum/ethereum apt-get update apt-get install -y ethereum |
Install NodeJS
1 2 3 |
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - apt-get install -y nodejs npm install -g npm@latest |
Install Solc
1 |
npm install -g solc |
Run an Ethereum Node in testnet:
1 |
geth --testnet --rpc --fast |
Run an Ethereum Node in Ropsten Testnet:
1 |
geth --testnet --fast --bootnodes "enode://20c9ad97c081d63397d7b685a412227a40e23c8bdc6688c6f37e97cfbc22d2b4d[email protected]52.169.14.227:30303,enode://6ce05930c72abc632c58e2e4324f7c7ea478cec0ed4fa2528982cf34483094e9c[email protected]13.84.180.240:30303 |
Run a private blockchain:
1 |
geth --dev --datadir privatechain --rpc --rpcaddr 127.0.0.1 --rpcport 8545 --targetgaslimit 200000000000 --etherbase 0x4119f7b4537e0f761c27c6268cbfd7e7118a899d --mine |
Open another terminal, connect to the exist node:
1 |
geth attach ~/.ethereum/testnet/geth.ipc |
Mining
Strart mining
1 |
miner.start() |
Check hashrate
1 |
eth.hashrate |
Stop mining
1 |
miner.stop() |
Sync status
1 |
eth.syncing |
Remove Ethereum Database
1 2 |
geth removedb Remove local database? [y/N] |
Check balance in Ether
1 |
web3.fromWei(web3.eth.getBalance(eth.accounts[0])) |
Send a transaction:
1 |
eth.sendTransaction({from: eth.accounts[0], to: '0x9ea9070c543d57b28fcf7fdff79cad79817d9e4e', value: web3.toWei(1, 'ether')}) |
Send with gas, gasPrice:
1 |
eth.sendTransaction({from: eth.accounts[3], to: '0x62bc7cc17100330631c00d9a0876177d9444fd4c', value: web3.toWei(1, 'ether'), gas: 200000, gasPrice: 20000000000 }) |
ERC20
Specification: https://theethereum.wiki/w/index.php/ERC20_Token_Standard#Approve_And_TransferFrom_Token_Balance