I setup my own Ethereum-based blockchain this morning and mined some ether. I created two accounts (wallets) and passed Wei (ether “pennies”) back and forth to each other and performed mining in-between to verify the transactions (aka move the money).
- Download geth
- Unzip it
- Initialize geth using this genesis.json file (strip the .zip extension off the filename)
geth –datadir=./datadir init genesis.json
4. Create an account:
geth –datadir=./datadir account new
5. Start the java console:
geth –datadir=./datadir console
Mine some ether!
miner.start(1)
INFO [01-23|11:45:55] Updated mining threads threads=1
INFO [01-23|11:45:55] Transaction pool price threshold updated price=18000000000
null
> INFO [01-23|11:45:55] Starting mining operation
INFO [01-23|11:45:55] Commit new mining work number=1 txs=0 uncles=0 elapsed=88.981µs
INFO [01-23|11:46:04] Generating DAG in progress epoch=0 percentage=0 elapsed=7.167s
INFO [01-23|11:46:11] Generating DAG in progress epoch=0 percentage=1 elapsed=14.543s
INFO [01-23|11:46:18] Generating DAG in progress epoch=0 percentage=2 elapsed=21.008s
INFO [01-23|11:46:24] Generating DAG in progress epoch=0 percentage=3 elapsed=27.073s
INFO [01-23|11:55:54] Generated ethash verification cache epoch=0 elapsed=9m57.721s
INFO [01-23|11:56:00] Successfully sealed new block number=1 hash=9c9452…2b3045
INFO [01-23|11:58:51] 🔨 mined potential block number=18 hash=c0b3d4…823d41
INFO [01-23|11:58:51] Commit new mining work number=19 txs=0 uncles=0 elapsed=205.898µs
INFO [01-23|11:58:52] Successfully sealed new block number=19 hash=8940d2…e026a6
INFO [01-23|11:58:52] 🔗 block reached canonical chain number=14 hash=e08f17…b69966
INFO [01-23|11:58:52] 🔨 mined potential block number=19 hash=8940d2…e026a6
INFO [01-23|11:58:52] Commit new mining work number=20 txs=0 uncles=0 elapsed=116.913µs
miner.stop()
You should have some ether in your wallet now!
Check your balance:
eth.accounts
get string
eth.getBalance(“paste string”)
or to see balance in ether:
web3.fromWei(eth.getBalance(eth.accounts[0]), “ether”)
240
Create a second wallet:
personal.newAccount(“abc123”)
Make sure the new wallet exists:
> eth.accounts
[“0x28a3a7967d16e51b3a38c7ae12c9e036472e07ad”, “0x2765108503bbda744203d8c9d3d744 c355f2453d”]
Move 100 from wallet “0” to wallet “1”:
Unlock the sending wallet first:
(personal.unlockAccount(eth.accounts[0], “password_for_wallet“)
Send 100 ether:
eth.sendTransaction({from: eth.accounts[0], to: eth.accounts[1], value: web3.toWei(100, “ether”)})
Performed some more mining to move the money (verify)
> miner.start(1)
INFO [01-23|12:17:30] Updated mining threads threads=1
INFO [01-23|12:17:30] Transaction pool price threshold updated price=18000000000
null
INFO [01-23|12:17:30] Starting mining operation
INFO [01-23|12:17:30] Commit new mining work number=49 txs=1 uncles=0 elapsed=269.401µs
INFO [01-23|12:17:37] Successfully sealed new block number=49 hash=cdd60d…09413f
INFO [01-23|12:17:37] 🔗 block reached canonical chain number=44 hash=4f6fd6…898d8a
INFO [01-23|12:17:37] 🔨 mined potential block number=49 hash=cdd60d…09413f
INFO [01-23|12:17:37] Commit new mining work number=50 txs=0 uncles=0 elapsed=135.258µs
> miner.stop()
Check balances:
> web3.fromWei(eth.getBalance(eth.accounts[0]), “ether”)
155 (note 15 additional coins from mining work to vfy txn!)
> web3.fromWei(eth.getBalance(eth.accounts[1]), “ether”)
100
Voila!
Transaction details:
> eth.getTransaction(“0xef3f9391e569ff205768d3e27bf7cf73308c5e8de0859b4e8fe096c26ba53”)
{
blockHash: “0xcdd60d0b3722adc0fba3c4956a02f8e6120b717371d335f6ae6849a09413f”,
blockNumber: 49,
from: “0x28a3a7967d16e51b3a38c7ae12c9e036472e07ad”,
gas: 90000,
gasPrice: 18000000000,
hash: “0xef3f9391e569ff205768c68d3e27bf7cf73308c5e8de0859b4e8fe096c26ba53”,
input: “0x”,
nonce: 0,
r: “0xf5981cbee6da86dc162787a8814d8dc30a874f3777228cdc1d03a20de10776b2”,
s: “0x7e3606f0e791493e166212dbec20161aa0aa6cec594bfb82214ed91cb000ff”,
to: “0x2765108503bbda744203d9d3d744c355f2453d”,
transactionIndex: 0,
v: “0xed”,
value: 100000000000000000000
}
Block details:
> eth.getBlock(“0xcdd60d0b22adc0fba3c4956a02f8e64ed120b717371d335f6ae6849a09413f”)
{
difficulty: 131072,
extraData: “0xd7830107038467657487676f312e392e32856c696e7578”,
gasLimit: 329424,
gasUsed: 21000,
hash: “0xcdd60d0b3722adc0fba3c4956a02f8e64ed120b717371d335f6ae6849a09413f”,
logsBloom: “0x0000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000”,
miner: “0x28a3a79d16e51b3a38c7ae12c9e036472e07ad”,
mixHash: “0x52f1d43a0d0f20de558ae892bd0be8d4f39231f73569a03a70d9274be9f475”,
nonce: “0x736267a32012d9”,
number: 49,
parentHash: “0x823fe9ab5c194169a5321193bbe61357cf56f958ed77f5d23ad9018b0b602b”,
receiptsRoot: “0xb91d6e796beda886fc0ea068b01d824a2a57f9ab48457046c3410feeaa0198”,
sha3Uncles: “0x1dcc4de8dec75d7aab85b567ccd41ad312451b948a7413f0a142fd40d49347”,
size: 651,
stateRoot: “0xfdc68f56dfd304be1405ccecc0f25eb70b5db2bf78f173e12022dbbd39bf20f9”,
timestamp: 151672750,
totalDifficulty: 644896,
transactions: [“0xef3f9391e569ff205768c68d3e27bf7cf7335e8de0859b4e8fe096c26ba53”],
transactionsRoot: “0x356c5cacb2a696f43a194473badaa8fa5ec1c2fef6e0e1b9cc341e569ec1”,
uncles: []
}
This is step one for creating my own DAPP. Hopefully this helps you.
If you have any questions, comments, or suggestions, let me know.
Thanks!