{
"config": {
"chainId": 123456,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
},
"difficulty": "200000",
"gasLimit": "8000000",
"alloc": {}
}
https://geth.ethereum.org/downloads/
C:\Users\NIPA-55\Desktop\ether_test> geth --datadir ./ init ./genesis.json
// chainId와 NETWORKID 동일
geth --rpc --rpcaddr localhost --rpcport 8545 --rpccorsdomain "*" --rpcapi net,web3,eth,db,miner,admin,personal --datadir ./ -networkid 123456 --nodiscover
C:\Users\NIPA-55>geth attach http://localhost:8545
Welcome to the Geth JavaScript console!
modules: admin:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 web3:1.0
// 계정 확인
> eth.accounts
["0x5b83c0df816de4a36e778e806f82ba8eb39caf81", "0xc136decefd36bc06f08f341acae647222e93f2e9"]
// 마이닝 계정 설정
> miner.setEtherbase(eth.accounts[0])
true
// 계정 unlock
> personal.unlockAccount(eth.accounts[0])
Unlock account 0x5b83c0df816de4a36e778e806f82ba8eb39caf81
Passphrase:
true
// 마이닝 start
> miner.start()
null
// 마이닝 중
INFO [08-01|10:41:00.166] 🔗 block reached canonical chain number=15 hash=86c0eb…84d931
INFO [08-01|10:41:00.186] 🔨 mined potential block number=22 hash=94fff7…505f20
INFO [08-01|10:41:00.199] Commit new mining work number=23 sealhash=9a2428…6fc844 uncles=0 txs=0 gas=0 fees=0 elapsed=32.913ms
INFO [08-01|10:41:01.689] Successfully sealed new block number=23 sealhash=9a2428…6fc844 hash=3f873c…63fa51 elapsed=1.521s
INFO [08-01|10:41:01.694] 🔗 block reached canonical chain number=16 hash=4f8977…ea0202
INFO [08-01|10:41:01.702] 🔨 mined potential block number=23 hash=3f873c…63fa51
INFO [08-01|10:41:01.715] Commit new mining work
// 마이닝 stop
> miner.stop()
null
// 블럭 확인
> eth.blockNumber
55
// 이더 확인
> eth.getBalance(eth.accounts[0])
275000000000000000000
// 송금
> eth.sendTransaction({from: eth.accounts[0], to: eth.accounts[1] , value : 1000000000000000000})
"0x00b56a8e0af608ccab711595d2d0b2524f4eb351a634c537fe9edf8a818999f9"
> eth.getBalance(eth.accounts[0])
275000000000000000000
> eth.getBalance(eth.accounts[1])
0
> miner.start()
null
> miner.stop()
null
// 마이닝 후
> eth.getBalance(eth.accounts[1])
1000000000000000000
> eth.getBalance(eth.accounts[0])
344000000000000000000
>
// 트랜잭션 정보
> eth.getTransaction("0x00b56a8e0af608ccab711595d2d0b2524f4eb351a634c537fe9edf8a818999f9")
{
blockHash: "0x13a9ca6bbd609e6c209aa4ab20aab40ad72e223fa1f25a98ddbe788c5278ff11",
blockNumber: 56,
from: "0x5b83c0df816de4a36e778e806f82ba8eb39caf81",
gas: 90000,
gasPrice: 1000000000,
hash: "0x00b56a8e0af608ccab711595d2d0b2524f4eb351a634c537fe9edf8a818999f9",
input: "0x",
nonce: 0,
r: "0x9ed83d8871b49c090e3217c15c1dac475e55f0d384d6b42fa304594cf2e43f22",
s: "0x5e2912260174e50a801bd20ae437517928653e0727483c2ae1f082d67a281a4a",
to: "0xc136decefd36bc06f08f341acae647222e93f2e9",
transactionIndex: 0,
v: "0x3c4a3",
value: 1000000000000000000
}
pragma solidity ^0.5.0;
contract test {
string a;
function set(string memory _a) public {
a=_a;
}
function get() public view returns(string memory){
return a;
}
}