台中自由軟體愛好者社群 - 區塊鏈技術分享

練習指令

講者:李麒傑 (James Li)

2018/03/03

使用 Docker compose 建立單節點 Ethereum 環境
取得節點所有帳戶

URL: 127.0.0.1:8545(post)

header: Content-Type:application/json

body(raw):

{

  "jsonrpc": "2.0",

  "method": "eth_accounts",

  "params": [],

  "id": 1

}

 

建立帳戶

URL: 127.0.0.1:8545(post)

header: Content-Type:application/json

body(raw):

{

  "method": "personal_newAccount",

  "params": ["密碼"],

  "id": "1"

}

 

取得帳戶餘額

URL: 127.0.0.1:8545(post)

header: Content-Type:application/json

body(raw):

{

  "jsonrpc": "2.0",

  "method": "eth_getBalance",

  "params": ["帳戶", "latest"],

  "id": 1

}

進制轉換
解鎖帳戶

URL: 127.0.0.1:8545(post)

header: Content-Type:application/json

body(raw):

{

  "jsonrpc": "2.0",

  "method": "personal_unlockAccount",

  "params": ["帳戶", "密碼", 時效(秒)],

  "id": 1

}

 

交易

URL: 127.0.0.1:8545(post)

header: Content-Type:application/json

body(raw):

{

  "jsonrpc": "2.0",

  "method": "eth_sendTransaction",

  "params": [{
    "from": "帳戶A",
    "to": "帳戶B",
    "value": "交易金額(十六進制)"
  }],

  "id": 1

}

 

交易資訊

URL: 127.0.0.1:8545(post)

header: Content-Type:application/json

body(raw):

{

  "jsonrpc": "2.0",

  "method": "eth_getTransactionByHash",

  "params": ["交易代號"],

  "id": 1

}

 

區塊資訊

URL: 127.0.0.1:8545(post)

header: Content-Type:application/json

body(raw):

{

  "jsonrpc": "2.0",

  "method": "eth_getBlockByHash",

  "params": ["區塊代號", true],

  "id": 1

}


deck

By James

deck

  • 770