블로그 이미지
Flying Mr.Cheon youGom

Recent Comment»

Recent Post»

Recent Trackback»

« 2024/5 »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

Excute BlockChain - Hello World

보안/기술 정보 | 2019. 1. 24. 16:54 | Posted by youGom

[ Step 0 : Install : MAC ] - 리눅스일경우 다른 방법으로 설치하거나 빌드하면됨

$ brew tap ethereum/ethereum

$ brew install ethereum


[ Step 1 : Create Genesis Block ]

$ mkdir -p ethereum-tutorial && cd ethereum-tutorial

$ mkdir -p private && cd private

$ puppeth

 > anyname

 > 2. Configure new genesis

 > 1. Create new genesis from scratch

 > 1. Ethash - proof of work

 > 0x100000000000

 > (blank:Default pre-funded with 1wei )

 > 12345 ( networkID)

      << loop answer >>

 > 2. Manage existing genesis

 > 2. Export genesis configuration

 > ( Ctrl + C : breake process )

there are 4 files; 

anyname.json, 

anyname-parity.json 

anyname-harmony.json 

anyname-aleth.json


[Step 2 : Initialize the genesis block]

$ geth --data ~/.ethereum-tutorial/private init anyname.json


[Step 3: Creating accounts]

$ geth --datadir . account new

$ geth --datadir . account list


[Step 4: Write a Shell Script to Start Blockchain]

$ vi startnode.sh

geth --networkid 4224 --mine --minerthreads 1 --datadir "~/Desktop/Playground/ethereum-tutorial/private" --nodiscover --rpc --rpcport "8545" --port "30303" --rpccorsdomain "*" --nat "any" --rpcapi eth,web3,personal,net --unlock 0 --password ~/ethereum-tutorial/private/password.sec --ipcpath "~/Library/Ethereum/geth.ipc"

  << Create another file named password.sec in private folder. >>

$ chmod +x startnode.sh

$ ./startnode.sh


[Step 5: Connect to running geth]

$ geth attach --datadir ~/ethereum-tutorial


[Step 6: Query the blockchain]

> eth.accounts

> eth.getBalance(eth.accounts[0])

> web3.fromWei(eth.getBalance(eth.accounts[0]), "ether")


$ miner.stop()

$ miner.start()


[Step 7: Make transactions]

> eth.sendTransaction({from: eth.coinbase, to: eth.accounts[1], value: web3.toWei(10, "ether")})

> web3.fromWei(eth.getBalance(eth.accounts[1]), "ether")



: