> curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"net_listening", "params":[],"id":1}' 39.107.236.48:8545
#{"jsonrpc":"2.0","id":1,"result":true}
> curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":67}' 39.107.236.48:8545
# {"jsonrpc":"2.0","id":67,"result":"Geth/g1/v1.8.1-stable-1e67410e/linux-amd64/go1.9.4”} 查看geth版本
3.web3_sha3 把數據轉換成SHA3格式
> curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"web3_sha3","params":["0x68656c6c6f20776f726c64"],"id":64}' 39.107.236.48:8545
#{"jsonrpc":"2.0","id":64,"result":"0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad"}
4.net_version 返回當前網絡ID
curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"net_version","params":["0x68656c6c6f20776f726c64"],"id":64}' 39.107.236.48:8545
#{"jsonrpc":"2.0","id":64,"result":"100"}
"1"
: Ethereum Mainnet"2"
: Morden Testnet (deprecated)"3"
: Ropsten Testnet"4"
: Rinkeby Testnet"42"
: Kovan Testnet- "100":等其它數字為個人自定義私有網絡
5.net_peerCount 返回當前節點的peers數量
curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"net_peerCount","params":[],"id":64}' 39.107.236.48:8545
#{"jsonrpc":"2.0","id":64,"result":"0x2"} //2
6.eth_protocolVersion 返回當前ethereum 協議版本
curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_protocolVersion","params":[],"id":64}' 39.107.236.48:8545
#{"jsonrpc":"2.0","id":64,"result":"0x3f"} //63
7.eth_syncing 返回包含有關同步狀態的對象或false.
curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":64}' 39.107.236.48:8545
#{"jsonrpc":"2.0","id":64,"result":false}
// Result 正在同步的情況下返回
{ "id":1, "jsonrpc": "2.0", "result": { startingBlock: '0x384', currentBlock: '0x386', highestBlock: '0x454' } } // Or when not syncing 同步完成或沒有同步返回 { "id":1, "jsonrpc": "2.0", "result": false }
8.eth_coinbase 獲取第一個賬號的地址
curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_coinbase","params":[],"id":64}' 39.107.236.48:8545
#{"jsonrpc":"2.0","id":64,"result":"0x2216bbda225f67fed72b416329a29664535104d9"}
9.eth_mining 獲取挖礦狀態
curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_mining","params":[],"id":64}' 39.107.236.48:8545
#{"jsonrpc":"2.0","id":64,"result":false}
10.eth_hashrate 獲取當前節點的挖礦算力
curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_hashrate","params":[],"id":64}' 39.107.236.48:8545
#{"jsonrpc":"2.0","id":64,"result":"0x1084"}
11.eth_gasPrice 返回每wei的gas價格
curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_gasPrice","params":[],"id":64}' 39.107.236.48:8545
#{"jsonrpc":"2.0","id":64,"result":"0x430e23400"} //18000000000
12.eth_accounts 返回客戶端地址列表
curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_accounts","params":[],"id":64}' 39.107.236.48:8545
#{"jsonrpc":"2.0","id":64,"result":["0x2216bbda225f67fed72b416329a29664535104d9","0x9ee25a5378f29633087936c507e8226ed5ea27fd"]}
13.eth_blockNumber 返回塊數
curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":64}' 39.107.236.48:8545
#{"jsonrpc":"2.0","id":64,"result":"0xb838"} //2014
14.eth_getBalance 獲取余額
curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getBalance","params":["0x2216bbda225f67fed72b416329a29664535104d9","latest"],"id":64}' 39.107.236.48:8545
#{"jsonrpc":"2.0","id":64,"result":"0x52b9fa1ddb74470c8daf00"} //100010168845190000246624828
參考:https://github.com/ethereum/wiki/wiki/JSON-RPC#the-default-block-parameter
The following methods have an extra default block parameter:
When requests are made that act on the state of ethereum, the last default block parameter determines the height of the block.
The following options are possible for the defaultBlock parameter:
HEX String
- an integer block numberString "earliest"
for the earliest/genesis blockString "latest"
- for the latest mined blockString "pending"
- for the pending state/transactions
15.eth_getStorageAt 返回給定地址的存儲位置的值
curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getStorageAt","params":["0x2216bbda225f67fed72b416329a29664535104d9","0x0","latest"],"id":64}' 39.107.236.48:8545
16.eth_getTransactionCount 返回從地址發送的交易數量
curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getTransactionCount","params":["0x2216bbda225f67fed72b416329a29664535104d9","latest"],"id":1}' 39.107.236.48:8545
17.eth_getBlockTransactionCountByHash 返回交易所在的塊號