Chain
Block chain RPC interface¶
Used to obtain block information
1. chain_getBlock¶
- Usage:
Used to obtain block information
- Params:
1. height usage: Current block height
-
Return:Block detail information
-
Example:
shell:
curl http://localhost:10085 -X POST --data '{"jsonrpc":"2.0","method":"chain_getBlock","params":[1000], "id": 3}' -H "Content-Type:application/json"
cli:
drep-cli 127.0.0.1:10085 chain_getBlock 1000 3
- Response:
{
"jsonrpc":"2.0",
"id":3,
"result":{
"Header":{
"ChainId":0,
"Version":1,
"PreviousHash":"0x1fbae528a8eed0f09201bfd2c7e52fef66f5f35619e9868cd6d02dabac60e4e6",
"GasLimit":18000000,
"GasUsed":0,
"Height":1,
"Timestamp":1592365562,
"StateRoot":"UpMnHA5WmmTxU4T4jFQvpt6bFwigN+fg1Jx0fSD91MA=",
"TxRoot":null,
"MinerAddr":"0x8ae8964357772abf03e2d6b13a4a8de804433014",
"ReceiptRoot":"0x0000000000000000000000000000000000000000000000000000000000000000",
"Bloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
},
"Data":{
"TxCount":0,
"TxList":null
},
"Proof":{
"Type":0,
"Evidence":"MEUCIQDIZnsow/WbAmQ7jJ21EcVxzQkKA33LJfw8anhzkNjBzAIgMexycsYJlYEv0rbPvleoAx1iahzUx6FrMNZhh8uq6Lg="
}
}
}
2. chain_getMaxHeight¶
- Usage:
To get the current highest block
- Params:
null
-
Return:Current maximum block height value
-
Example:
shell:
curl http://localhost:10085 -X POST --data '{"jsonrpc":"2.0","method":"chain_getMaxHeight","params":[], "id": 3}' -H "Content-Type:application/json"
cli:
drep-cli 127.0.0.1:10085 chain_getMaxHeight 3
- Response:
{"jsonrpc":"2.0","id":3,"result":1000}
3. chain_getBlockGasInfo¶
- Usage:
Obtain gas related information
- Params:
null
-
Return:Gas minimum value and maximum value required by the system; And the maximum gas value that the current block is set to
-
Example:
shell:
curl http://localhost:10085 -X POST --data '{"jsonrpc":"2.0","method":"chain_getBlockGasInfo","params":[], "id": 3}' -H "Content-Type:application/json"
cli:
drep-cli 127.0.0.1:10085 chain_getBlockGasInfo 3
- Response:
{"jsonrpc":"2.0","id":3,"result":193005}
4. chain_getBalance¶
- Usage:
Query address balance
- Params:
1. Query address
-
Return:The account balance in the address
-
Example:
shell:
curl http://localhost:10085 -X POST --data '{"jsonrpc":"2.0","method":"chain_getBalance","params":["0x8a8e541ddd1272d53729164c70197221a3c27486"], "id": 3}' -H "Content-Type:application/json"
cli:
drep-cli 127.0.0.1:10085 chain_getBalance 0x8a8e541ddd1272d53729164c70197221a3c27486 3
- Response:
{"jsonrpc":"2.0","id":3,"result":9987999999999984000000}
5. chain_getNonce¶
- Usage:
Query the nonce whose address is on the chain
- Params:
1. Query address
-
Return:nonce
-
Example:
shell:
curl http://localhost:10085 -X POST --data '{"jsonrpc":"2.0","method":"chain_getNonce","params":["0x8a8e541ddd1272d53729164c70197221a3c27486"], "id": 3}' -H "Content-Type:application/json"
cli:
drep-cli 127.0.0.1:10085 chain_getNonce 0x8a8e541ddd1272d53729164c70197221a3c27486 3
- Response:
{"jsonrpc":"2.0","id":3,"result":0}
6. chain_getReputation¶
- Usage:
Query the reputation value of the address
- Params:
1. Query address
-
Return:The reputation value corresponding to the address
-
Example:
shell:
curl http://localhost:10085 -X POST --data '{"jsonrpc":"2.0","method":"chain_getReputation","params":["0x8a8e541ddd1272d53729164c70197221a3c27486"], "id": 3}' -H "Content-Type:application/json"
cli:
drep-cli 127.0.0.1:10085 chain_getReputation 0x8a8e541ddd1272d53729164c70197221a3c27486 3
- Response:
{"jsonrpc":"2.0","id":3,"result":1}
7. chain_getTransactionByBlockHeightAndIndex¶
- Usage:
Gets a particular sequence of transactions in a block
- Params:
1. block height 2. Transaction sequence
-
Return:transaction
-
Example:
shell:
curl http://localhost:10085 -X POST --data '{"jsonrpc":"2.0","method":"chain_getTransactionByBlockHeightAndIndex","params":[10000,1], "id": 3}' -H "Content-Type:application/json"
cli:
drep-cli 127.0.0.1:10085 chain_getTransactionByBlockHeightAndIndex [100,1] 3
- Response:
{
"jsonrpc": "2.0",
"id": 3,
"result": {
"Hash": "0xfa5c34114ff459b4c97e7cd268c507c0ccfcfc89d3ccdcf71e96402f9899d040",
"From": "0x7923a30bbfbcb998a6534d56b313e68c8e0c594a",
"Version": 1,
"Nonce": 15632,
"Type": 0,
"To": "0x7923a30bbfbcb998a6534d56b313e68c8e0c594a",
"ChainId": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"Amount": "0x111",
"GasPrice": "0x110",
"GasLimit": "0x30000",
"Timestamp": 1559322808,
"Data": null,
"Sig": "0x20f25b86c4bf73aa4fa0bcb01e2f5731de3a3917c8861d1ce0574a8d8331aedcf001e678000f6afc95d35a53ef623a2055fce687f85c2fd752dc455ab6db802b1f"
}
}
8. chain_getAliasByAddress¶
- Usage:
Gets the alias corresponding to the address according to the address
- Params:
1. address
-
Return:Address the alias
-
Example:
shell:
curl http://localhost:10085 -X POST --data '{"jsonrpc":"2.0","method":"chain_getAliasByAddress","params":["0x8a8e541ddd1272d53729164c70197221a3c27486"], "id": 3}' -H "Content-Type:application/json"
cli:
drep-cli 127.0.0.1:10085 chain_getAliasByAddress 0x8a8e541ddd1272d53729164c70197221a3c27486 3
- Response:
{"jsonrpc":"2.0","id":3,"result":"tom"}
9. chain_getAddressByAlias¶
- Usage:
Gets the address corresponding to the alias based on the alias
- Params:
1. Alias to be queried
-
Return:The address corresponding to the alias
-
Example:
shell:
curl http://localhost:10085 -X POST --data '{"jsonrpc":"2.0","method":"chain_getAddressByAlias","params":["tom"], "id": 3}' -H "Content-Type:application/json"
cli:
drep-cli 127.0.0.1:10085 chain_getAddressByAlias tom 3
- Response:
{"jsonrpc":"2.0","id":3,"result":"0x8a8e541ddd1272d53729164c70197221a3c27486"}
10. chain_getReceipt¶
- Usage:
Get the receipt information based on txhash
- Params:
1. txhash
-
Return:receipt
-
Example:
shell:
curl http://localhost:10085 -X POST --data '{"jsonrpc":"2.0","method":"chain_getReceipt","params":["0x7d9dd32ca192e765ff2abd7c5f8931cc3f77f8f47d2d52170c7804c2ca2c5dd9"], "id": 3}' -H "Content-Type:application/json"
cli:
drep-cli 127.0.0.1:10085 chain_getReceipt 0x7d9dd32ca192e765ff2abd7c5f8931cc3f77f8f47d2d52170c7804c2ca2c5dd9 3
- Response:
{"jsonrpc":"2.0","id":3,"result":""}
11. chain_getLogs¶
- Usage:
Get the transaction log information based on txhash
- Params:
1. txhash
-
Return:[]log
-
Example:
shell:
curl http://localhost:10085 -X POST --data '{"jsonrpc":"2.0","method":"chain_getLogs","params":["0x7d9dd32ca192e765ff2abd7c5f8931cc3f77f8f47d2d52170c7804c2ca2c5dd9"], "id": 3}' -H "Content-Type:application/json"
cli:
drep-cli 127.0.0.1:10085 chain_getLogs 0x7d9dd32ca192e765ff2abd7c5f8931cc3f77f8f47d2d52170c7804c2ca2c5dd9 3
- Response:
{"jsonrpc":"2.0","id":3,"result":None}
12. chain_getCancelCreditDetailByTXHash¶
- Usage:
Get the back pledge or back vote information according to txhash
- Params:
1. txhash
-
Return:{}
-
Example:
shell:
curl http://localhost:10085 -X POST --data '{"jsonrpc":"2.0","method":"chain_getCancelCreditDetailByTXHash","params":["0x7d9dd32ca192e765ff2abd7c5f8931cc3f77f8f47d2d52170c7804c2ca2c5dd9"], "id": 3}' -H "Content-Type:application/json"
cli:
drep-cli 127.0.0.1:10085 chain_getCancelCreditDetailByTXHash 0x7d9dd32ca192e765ff2abd7c5f8931cc3f77f8f47d2d52170c7804c2ca2c5dd9 3
- Response:
{"jsonrpc":"2.0","id":3,"result":None}
13. chain_getByteCode¶
- Usage:
Get bytecode by address
- Params:
1. address
-
Return:bytecode
-
Example:
shell:
curl http://localhost:10085 -X POST --data '{"jsonrpc":"2.0","method":"chain_getByteCode","params":["0x8a8e541ddd1272d53729164c70197221a3c27486"], "id": 3}' -H "Content-Type:application/json"
cli:
drep-cli 127.0.0.1:10085 chain_getByteCode 0x8a8e541ddd1272d53729164c70197221a3c27486 3
- Response:
{"jsonrpc":"2.0","id":3,"result":"0x00"}
14. chain_getCreditDetails¶
- Usage:
Get all the details of the stake according to the address
- Params:
1. address
-
Return:bytecode
-
Example:
shell:
curl http://localhost:10085 -X POST --data '{"jsonrpc":"2.0","method":"chain_getCreditDetails","params":["0x8a8e541ddd1272d53729164c70197221a3c27486"], "id": 3}' -H "Content-Type:application/json"
cli:
drep-cli 127.0.0.1:10085 chain_getCreditDetails 0x8a8e541ddd1272d53729164c70197221a3c27486 3
- Response:
{"jsonrpc":"2.0","id":3,"result":"[{\"Addr\":\"DREPd05d5f324ada3c418e14cd6b497f2f36d60ba607\",\"HeightValues\":[{\"CreditHeight\":1329,\"CreditValue\":\"0x11135\"}]}]"}
15. chain_getCancelCreditDetails¶
- Usage:
Get the details of all refund requests
- Params:
1. address
-
Return:bytecode
-
Example:
shell:
curl http://localhost:10085 -X POST --data '{"jsonrpc":"2.0","method":"chain_getCancelCreditDetails","params":["0x8a8e541ddd1272d53729164c70197221a3c27486"], "id": 3}' -H "Content-Type:application/json"
cli:
drep-cli 127.0.0.1:10085 chain_getCancelCreditDetails 0x8a8e541ddd1272d53729164c70197221a3c27486 3
- Response:
{"jsonrpc":"2.0","id":3,"result":"{\"DREP300fc5a14e578be28c64627c0e7e321771c58cd4\":\"0x3641100\"}"}
16. chain_getCandidateAddrs¶
- Usage:
Gets the addresses of all candidate nodes and the corresponding trust values
- Params:
1. address
-
Return:[]
-
Example:
shell:
curl http://localhost:10085 -X POST --data '{"jsonrpc":"2.0","method":"chain_getCandidateAddrs","params":[""], "id": 3}' -H "Content-Type:application/json"
cli:
drep-cli 127.0.0.1:10085 chain_getCandidateAddrs 3
- Response:
{"jsonrpc":"2.0","id":3,"result":"{\"0x300fc5a14e578be28c64627c0e7e321771c58cd4\":\"0x3641100\"}"}
17. chain_getChangeCycle¶
- Usage:
Gets the transition period of the out - of - block node
- Params:
null
-
Return:Transition period
-
Example:
shell:
curl http://localhost:10085 -X POST --data '{"jsonrpc":"2.0","method":"chain_getChangeCycle","params":"", "id": 3}' -H "Content-Type:application/json"
cli:
drep-cli 127.0.0.1:10085 chain_getChangeCycle 3
- Response:
{"jsonrpc":"2.0","id":3,"result":"{100}"}