Skip to content

jongkwang/blockchain-lecture

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

15 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Blockchain - Lecture

Geth ๊ณผ์ •์— ์‚ฌ์šฉ๋˜๋Š” ๋ช…๋ น์–ด๋“ค

๊ต์žฌ์˜ Code ๋ฅผ Copy&Paste ํ•  ๋•Œ ๋งˆ๋‹ค PDF Reader ์— ๋”ฐ๋ผ ๊ฐ’์ด ๋‹ฌ๋ผ์ง€๋Š” ๊ฒฝ์šฐ ๋ฐœ์ƒ (์ค„๋ฐ”๋€œ ๋ฐ ๋„์–ด์“ฐ๊ธฐ ๋ฐœ์ƒ) ์•„๋ž˜ ์ฝ”๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์„ธ์š”

// ํด๋” ๋งŒ๋“ค๊ณ  ์ด๋™ํ•˜๊ธฐ
mkdir MyNetwork
cd MyNetwork

// puppeth ํ†ตํ•ด์„œ ์ œ๋„ค์‹œ์Šค ๋ธ”๋ก ์…‹ํŒ…ํ•˜๊ธฐ
puppeth
// ์ดํ›„ ์„ค์ •์€ ๊ต์žฌ ์ฐธ์กฐ

#### puppeth ์‹คํ–‰์ด ์•ˆ๋˜๋Š” ๊ฒฝ์šฐ - Windows
- geth-alltools ์„ค์น˜์‹œ ์ž๋™์œผ๋กœ Path ์— ์ถ”๊ฐ€ ๋ฉ๋‹ˆ๋‹ค
- CMD ์ฐฝ์„ ๋‹ซ์•˜๋‹ค ์ƒˆ๋กœ ์—ด์–ด๋ณด์„ธ์š”
#### puppeth ์‹คํ–‰์ด ์•ˆ๋˜๋Š” ๊ฒฝ์šฐ - macOS
- ํŽธ์ง‘๊ธฐ ์—ด๊ณ  : vi ~/.bash_profile
- ๋‹ค์Œ ๋‚ด์šฉ ์ถ”๊ฐ€(JongKwang ๊ฒฝ๋กœ ์ˆ˜์ •ํ•„์š”) : export PATH=$PATH:/Users/JongKwang/bin/geth-alltools-1.8.15
- terminal ์„ ์ƒˆ๋กœ ์—ฝ๋‹ˆ๋‹ค

// MyNetwork.json ์œผ๋กœ ๋ธ”๋ก ์ƒ์„ฑํ•˜๊ธฐ
geth --datadir . init MyNetwork.json

// Account ์ƒ์„ฑ ๋ฐ ์กฐํšŒ
geth --datadir . account new
geth --datadir . account list

// ๋น„๋ฐ€๋ฒˆํ˜ธ ํŒŒ์ผ ์ƒ์„ฑํ•˜๊ธฐ
code password.txt
12341234

// ๋ธ”๋ก์ฒด์ธ ์‹œ์ž‘ ํŒŒ์ผ ์ƒ์„ฑ
code startblockchain.bat
geth --datadir . --networkid 9999 --nodiscover --rpc --rpcport 8545 --rpccorsdomain "*" --rpcapi "eth,web3,personal,net" --nat any --unlock 0 --password ./password.txt
#### macOS์˜ ๊ฒฝ์šฐ
- ํŒŒ์ผ ์ƒ์„ฑ : code startblockchain.sh
- ๊ถŒํ•œ ๋ถ€์—ฌ : chmod 755 startblockchain.sh


// ๋ธ”๋ก์ฒด์ธ ์‹œ์ž‘
startblockchain.bat
#### macOS์˜ ๊ฒฝ์šฐ : startblockchain.sh

// Geth Console ๋ฐฐ์น˜ํŒŒ์ผ ์ƒ์„ฑ
code startgethconsole.bat
geth attach ipc:\\.\pipe\geth.ipc
#### macOS์˜ ๊ฒฝ์šฐ
- ํŒŒ์ผ ์ƒ์„ฑ : code startgethconsole.sh
- ๊ถŒํ•œ ๋ถ€์—ฌ : chmod 755 startgethconsole.sh

// Geth Console ์‹œ์ž‘
startgethconsole.bat #### macOS์˜ ๊ฒฝ์šฐ : startgethconsole.sh

// Mist ์‹คํ–‰ ํŒŒ์ผ ์ƒ์„ฑ
code startmist.bat
"c:\Program Files\Mist\Mist.exe" --ipc \\\\.\\pipe\\geth.ipc
#### macOS์˜ ๊ฒฝ์šฐ
- code startmist.sh
- /Applications/Mist.app/Contents/MacOS/Mist --ipc \\\\.\\pipe\\geth.ipc

// Mist ์‹คํ–‰
startmist.bat #### macOS์˜ ๊ฒฝ์šฐ : startmist.sh

Geth ์ฃผ์š” ๋ช…๋ น์–ด

๊ณ„์ • ๊ด€๋ จ

  • ๊ณ„์ • ๋ชฉ๋ก : eth.accounts
  • 1๋ฒˆ์งธ ๊ณ„์ • ์ฃผ์†Œ : eth.accounts[0]
  • ์‹ ๊ทœ ๊ณ„์ • ์ƒ์„ฑ : personal.newAccount()
  • ๊ณ„์ • ์ž ๊ธˆ ํ•ด์ œ : personal.unlockAccount

์ฑ„๊ตด

  • ์ฑ„๊ตด ์‹œ์ž‘ : miner.start(1)
  • ์ฑ„๊ตด ์ค‘์ง€ : miner.stop()

์กฐํšŒ

  • ๋Œ€๊ธฐ์ค‘์ธ ํŠธ๋žœ์ ์…˜ : eth.pendingTransactions
  • ํŠธ๋žœ์ ์…˜ ID ๋กœ ์ƒ์„ธ์กฐํšŒ : eth.getTransaction("ํŠธ๋žœ์žญ์…˜ID")
  • ํ˜„์žฌ ๋ธ”๋ก ๋„˜๋ฒ„ : eth.blockNumber
    • web3.eth.getBlock('latest') // ๋งˆ์ง€๋ง‰ ๋ธ”๋ก ์ •๋ณด

๊ธฐํƒ€

  • debug.verbosity(2) // (0=silent, 1=error, 2=warn, 3=info, 4=core, 5=debug, 6=debug detail)

Solidity Code

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors