'blockchain'에 해당되는 글 4건

  1. 2018.12.06 Powershell의 curl 명령어 대안
  2. 2018.12.06 geth 명령어들
  3. 2018.12.05 geth genesis.json (181205 기준)
  4. 2018.12.05 Windows PowerShell 에서 UNIX tail 명령어

Linux

> curl http://localhost:8545 -H "Content-Type:application/json" -X POST --data '{"jsonrpc":"2.0","method":"web3_clientVersion
","params":[],"id":1}'



Windows Powershell

> curl http://localhost:8545 -contenttype "application/json" -method post -body '{"jsonrpc":"2.0","method":"web3_clientVersio
n","params":[],"id":1}'


-H 헤더내 ContentType → -contenttype 

-X → -method

--data → -body



응용


> curl http://localhost:8545 -contenttype "application/json" -method post -body '{"jsonrpc":"2.0","method":"web3_sha3","param
s":["0x68656c6c6f20776f726c64"],"id":1}'


StatusCode : 200
StatusDescription : OK
Content : {"jsonrpc":"2.0","id":1,"result":"0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad"}

RawContent : HTTP/1.1 200 OK
Vary: Origin
Content-Length: 103
Content-Type: application/json
Date: Thu, 06 Dec 2018 04:46:27 GMT

{"jsonrpc":"2.0","id":1,"result":"0x47173285a8d7341e5e972fc677286384f802f8ef4...
Forms : {}
Headers : {[Vary, Origin], [Content-Length, 103], [Content-Type, application/json], [Date, Thu, 06 Dec 2018 04:46:27 GMT]}
Images : {}
InputFields : {}
Links : {}
ParsedHtml : System.__ComObject
RawContentLength : 103



> curl http://localhost:8545 -contenttype "application/json" -method post -body '{"jsonrpc":"2.0","method":"eth_getBalance","
params":["0x8d6259c5c7fab5f494399443faa531278f9dcb2c", "latest"],"id":1}'


StatusCode : 200
StatusDescription : OK
Content : {"jsonrpc":"2.0","id":1,"result":"0x144b7f2ef9eadd80000"}

RawContent : HTTP/1.1 200 OK
Vary: Origin
Content-Length: 58
Content-Type: application/json
Date: Thu, 06 Dec 2018 04:48:41 GMT

{"jsonrpc":"2.0","id":1,"result":"0x144b7f2ef9eadd80000"}

Forms : {}
Headers : {[Vary, Origin], [Content-Length, 58], [Content-Type, application/json], [Date, Thu, 06 Dec 2018 04:48:41 GMT]}
Images : {}
InputFields : {}
Links : {}
ParsedHtml : System.__ComObject
RawContentLength : 58


'blockchain' 카테고리의 다른 글

geth 명령어들  (0) 2018.12.06
geth genesis.json (181205 기준)  (0) 2018.12.05
Windows PowerShell 에서 UNIX tail 명령어  (0) 2018.12.05
Posted by 아마루아00
,

geth 명령어들

blockchain 2018. 12. 6. 00:58
//geth init
> geth --datadir .\node1_data_dir\ init .\node1_data_dir\genesis.json
//genesis.json 필요

//콘솔 실행
> geth --networkid 8484 --nodiscover --maxpeers 0 --datadir .\node1_data_dir\ console 2>> .\node1_data_dir\geth.l
og
//nodiscover 생성자 노드를 다른 노드에서 검색할 수 없게 하는 옵션
//maxpeers n 피어 접속 최대 수치
//datadir 데이터 디렉토리 data_testnet
//console 콘솔 실행, 로그

//콘솔 실행 2
> geth --networkid 8484 --nodiscover --maxpeers 0 --rpc --rpcaddr "0.0.0.0" --rpcport 8545 --rpccorsdomain "*" --data
dir .\node1_data_dir console 2>> .\node1_data_dir\geth.log

//원격접속
> geth attach rpc:http://localhost:8545




- remix로 compile 한 contract를 geth로 불러와서 실행해보기


1. Remix [Compile]에 [Details] 클릭


2. abi를 복사하는데, "WEB3DEPLOY"항목의 var helloworldContract = web3.eth.contract([{"constant":true,"inputs":[],"name":"say","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_greeting","type":"string"}],"name":"setGreeting","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"greeting","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_greeting","type":"string"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"}]);

이 부분이 공백없는 abi니까 복사하면 됨


3. geth로 가서 다음과 같이 코딩

> abi = '[{"constant":true,"inputs":[],"name":"say","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"
},{"constant":false,"inputs":[{"name":"_greeting","type":"string"}],"name":"setGreeting","outputs":[],"payable":false,"stateMutability":"nonpayable","
type":"function"},{"constant":true,"inputs":[],"name":"greeting","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","typ
e":"function"},{"inputs":[{"name":"_greeting","type":"string"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"}]';

> contract = eth.contract(JSON.parse(abi)).at("0xb6eb1c592e03639685513669ae7a877f51fc469a");

at에 들어가는 파라메터는 remix에서 Deployed Contract 의 주소임


4. 테스트

> contract.say.hello()






'blockchain' 카테고리의 다른 글

Powershell의 curl 명령어 대안  (0) 2018.12.06
geth genesis.json (181205 기준)  (0) 2018.12.05
Windows PowerShell 에서 UNIX tail 명령어  (0) 2018.12.05
Posted by 아마루아00
,
{
"config":{
"chainId": 1,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
},
"coinbase": "0x0000000000000000000000000000000000000000",
"difficulty": "0x05",
"extraData": "0x00",
"gasLimit": "0x80000000",
"nonce": "0x0000000000000000",
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp" : "0x00",
"alloc": {
}
}


'blockchain' 카테고리의 다른 글

Powershell의 curl 명령어 대안  (0) 2018.12.06
geth 명령어들  (0) 2018.12.06
Windows PowerShell 에서 UNIX tail 명령어  (0) 2018.12.05
Posted by 아마루아00
,

> Get-Content .\geth.log -Wait -Tail 1000

'blockchain' 카테고리의 다른 글

Powershell의 curl 명령어 대안  (0) 2018.12.06
geth 명령어들  (0) 2018.12.06
geth genesis.json (181205 기준)  (0) 2018.12.05
Posted by 아마루아00
,