티스토리 뷰

이더리움 클라이언트 : Geth

https://ethereum.github.io/go-ethereum/downloads/
Geth(Go Ethereum) : CLI기반의 메인 이더리움 클라이언트 설치

로컬 폴더(C:\Ethereum\data) 생성후, 계좌 생성 :

cmd> geth --datadir "C:\\Ethereum\\data" account new  
cmd> 비밀번호 4자리 이상  

계좌 확인 (40자리16진수 계좌주소)

cmd> geth --datadir "C:\\Ethereum\\data" account list  

Genesis 블록 파일 생성
C:\Ethereum\CustomGenesis.json

{
    "config": {
        "chainId": 15,
        "homesteadBlock": 0,
        "eip155Block": 0,
        "eip158Block": 0
    },

    "nonce": "0x00000004",
    "timestamp": "0x00",
    "gasLimit": "0x800000",
    "difficulty": "0x400",
    "alloc": {
        "0x438cc81218840f4dadc5a31c7cdcb5c0fd9d0636" : {
            "balance": "30000000000000000000"
        }
    }
}

(나머지 field들은 default로 자동생성되게)

cmd> geth --datadir "C:\\Ethereum\\data" init "C:\\Ethereum\\CustomGenesis.json"  

Ethereum Private Network 실행, 콘솔 접근

cmd> geth --identity “privateNetwork” --datadir “c:\\ethereum\\data” --port 30303 --rpc --rpcaddr 0.0.0.0 --rpcport 8123 --rpccorsdomain “\*” --nodiscover --networkid 1900 --nat “any” --rpcapi “db,eth,net,web3,miner,personal” console  

계좌조회

geth> eth.accounts  

Wei(최소)단위 잔고확인

geth> eth.getBalance(eth.accounts\[0\])  
geth> eth.getBalance(eth.coinbase)  

Ether단위 잔고확인

geth> web3.fromWei(eth.getBalance(eth.coinbase), "ether")  

채굴

geth> miner.start()

  • 관련 내용이 지속적으로 업데이트되어 명령어 입력이 어려워지므로, Ctrl C를 연사해 종료시키거나, 다른 새로운 콘솔에서 attach로 접근해 miner.stop() 등으로 채굴중지
    new cmd> geth attach [http://localhost:8123](http://localhost:8123/)

Mist Browser

Mist Browser : Ether&DApp 도와주는 GUI기반 Wallet
https: //github.com/ethereum/mist/releases
(Ethereum-Wallet말고 Mist-installer버전으로 테스트)

  • geth 먼저 접속,실행 후 Mist 접속해야 public아닌 private Network로 접속한다. 확인할것.

이후로는 계정추가, 송금, 컨트랙트 등 GUI기반으로 콘솔보다 편리함. 단 거래 생성후 geth에서 마이닝 돌려야 검증과정을 거쳐 실제로 거래가 수행됨.

Contract Ex. Greeter

pragma solidity ^0.4.18;

contract Mortal {
    address owner;

    function Mortal() public { owner = msg.sender; }
    function kill() public { if(msg.sender == owner) selfdestruct(owner); }
}

contract Greeter is Mortal {
    string greeting;

    function Greeter(string _greeting) public {
        greeting = _greeting;
    }

    function greet() public constant returns (string) {
        return greeting;
    }
}

string ex. Hello World 입력

'Security&Hacking > Blockchain' 카테고리의 다른 글

이더리움) Solidity & dApp 기본 예제  (0) 2019.09.11
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
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
글 보관함