티스토리 뷰
geth설치
geth는 이더리움 실행을 위한 CLI
사전 golang-go설치
# 패키지를 이용한 설치
$ sudo apt-get install golang-go
잘못 설치한경우이거나 버전이 안맞는경우
-필자의 경우는 apt-get으로 설치시 버전문제로 수동 설치하였다
$ sudo apt-get remove golang-go
바이너리를 이용한 설치
$ wget https://dl.google.com/go/go1.10.3.linux-amd64.tar.gz
$ tar zxvf go1.10.3.linux-amd64.tar.gz
$ cd go
$ export GOROOT=$(pwd)
$ export PATH=$PATH:$GOROOT/bin
$ go version
go version go1.10.3 linux/amd64
실제 geth 설치
$ git clone https://github.com/ethereum/go-ethereum.git
$ cd go-ethereum
$ make
$ sudo cp build/bin/geth /usr/local/bin/
$ geth version
Geth
Version: 1.8.14-unstable
Git Commit: 45eaef24319897f5b1679c9d1aa7d88702cce905
Architecture: amd64
Protocol Versions: [63 62]
Network Id: 1
Go Version: go1.10.3
Operating System: linux
GOPATH=
GOROOT=/home/jbshin/ehtereum-workspace/go
Private network설치
$ mkdir -p ~/ethereum-workspace/privnet
$ cd ~/ethereum-workspace/privnet
채굴및 기본설정파일인 genesis..json파일
{
"config": {
"chainId": 2018,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
},
"nonce": "0x0000000000000033",
"timestamp": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x8000000",
"difficulty": "0x100",
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x3333333333333333333333333333333333333333",
"alloc": {}
}
초기화
$ geth --datadir ./data init genesis.json
노드 실행
$ geth --rpc --datadir ./data --nodiscover --rpcapi db,eth,net,web3,admin.personal console
Geth사용하기
> eth.accounts
[]
계정생성
> personal.newAccount('ccc')
"Oxdlkfjapoe8iroj1239jflkdb89" # 키생성
> eth.accounts
["Oxdlkfjapoe8iroj1239jflkdb89
"]
키값입력이 힘든경우 배열로 [0]로 입력가능
> eth.getBalance(eth.accounts[0]) # eth.getBalance('키값')
0
채굴 시작 - 어느정도 시간이 지나면 채굴이 된다.
> miner.start()
.
.
.
INFO [08-10|17:39:54.979] 🔨 mined potential block number=1 hash=5a2077…0eb665
cles=0 elapsed=316.197µs
채굴 중단은 miner.stop()
송금을 하려는데 하려면 우선 unlock해야 한다.
> personal.unlockAccount(eth.accounts[0])
Unlock account 0x12312312312378bdfh1238
Passphrase: //여기에는 계정생성시 입력한 값을 입력('ccc')
true
unlock이 완료되면 송금을 시도한다.
-우선 계정을 하나더 생성한다.
> personal.newAccount('ddd')
"Ox123123sdkjfsdi2" # 키생성
송금을 진행하자
[0]에서 1번으로 1eth를 송금
> eth.sendTransaction({from: eth.accounts[0], to: eth.accounts[1], value: web3.toWei(1, 'ether')})
INFO [08-10|19:59:50.985] Submitted transaction fullhash=0x1a5fa277634a504a10ff4f33a6a29c208e90c113d54b40c5b4bcc99e84fd1a63 recipient=0xc07f222C6312473FC5694fD2ae1cf1E78410b58C
"0x12312312312378bdfh1238
"
채굴된 결과 확인은
>eth.getBalance(eth.accounts[10])
노드정보는
> admin.nodeInfo
{
enode: "enode://6b98677005fa17215d9a6f00b29cc67dcc721bb21aa827df17f69c9d4a15fbcccd19bfd3daeb6787b723494aae04b2403f3a48244f74a99484edf3dfaeaebf88@127.0.0.1:30303?discport=0",
enr: "0xf895b84058968ed044b6ccf5f23228b68cea8dc88e97e42c38062df824dd966cd462577770d4a1cc2cf43f4479507720333a345d8d390e4f9d18a7cdf6a552b27b490e640283636170ccc5836574683ec5836574683f826964827634826970847f00000189736563703235366b31a1026b98677005fa17215d9a6f00b29cc67dcc721bb21aa827df17f69c9d4a15fbcc8374637082765f",
id: "4383d500ae0af79c5fb60223e3fdde47c7ef6a0537f7e097f9b93bdec74a1292",
ip: "127.0.0.1",
listenAddr: "[::]:30303",
name: "Geth/v1.9.0-unstable-d596bea2/linux-amd64/go1.10.3",
ports: {
discovery: 0,
listener: 30303
},
protocols: {
eth: {
config: {
chainId: 2018,
eip150Hash: "0x0000000000000000000000000000000000000000000000000000000000000000",
eip155Block: 0,
eip158Block: 0,
homesteadBlock: 0
},
difficulty: 36590273,
genesis: "0x5704d029fe80f4fb605c0cb5e31d591511f10a46a0cb8166f97d8d559f9bc5b0",
head: "0x59dabde05ef381897e614d62063c907bfc927b5f7fe2e6353ccbabd440360e19",
network: 1
}
}
}
> exit
$ geth --rpc --rpcaddr 0.0.0.0 --datadir ./data --nodiscover --rpcapi db,eth,net,web3,admin.personal console
다른 서버(노드)를 추가 가능
> admin.addPeer('enode://9bb90c172175f636faa6d1670607c88d23524080ee38f63a6d9347f5fa8d1e931a4a9e0423e7fab9f7816883d4a818474118aa41039e495f7f172d285d7a4df7@[::]:30303?discport=0')
true
참고: https://bum752.github.io/ethereum/geth/
- Total
- Today
- Yesterday
- FinOps
- 기술사
- 이더리움
- response.redirect
- 핀옵스
- 오픈소스DB
- joblib
- 고급개발자
- argocd
- ci/cd
- RegeneratorRuntime
- python성능
- atom git 연동
- 정보관리기술사
- 클라우드 비용절감
- SpringBoot
- 중급개발자
- SWA
- 클라우드 활용
- 모델저장
- 123회기술사
- 아이리포
- MariaDB
- 컴퓨터시스템응용기술사
- 프로젝트성공
- 두음신공
- 소프트웨어아키텍트
- 정보처리기술사
- mysql
- 핵심집중반
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |