You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

107 lines
2.5 KiB

7 years ago
  1. /*
  2. # Introduction
  3. Tendermint supports the following RPC protocols:
  4. * URI over HTTP
  5. * JSONRPC over HTTP
  6. * JSONRPC over websockets
  7. Tendermint RPC is built using [our own RPC library](https://github.com/tendermint/tendermint/tree/master/rpc/lib). Documentation and tests for that library could be found at `tendermint/rpc/lib` directory.
  8. ## Configuration
  9. Set the `laddr` config parameter under `[rpc]` table in the `$TMHOME/config.toml` file or the `--rpc.laddr` command-line flag to the desired protocol://host:port setting. Default: `tcp://0.0.0.0:46657`.
  10. ## Arguments
  11. Arguments which expect strings or byte arrays may be passed as quoted strings, like `"abc"` or as `0x`-prefixed strings, like `0x616263`.
  12. ## URI/HTTP
  13. ```bash
  14. curl 'localhost:46657/broadcast_tx_sync?tx="abc"'
  15. ```
  16. > Response:
  17. ```json
  18. {
  19. "error": "",
  20. "result": {
  21. "hash": "2B8EC32BA2579B3B8606E42C06DE2F7AFA2556EF",
  22. "log": "",
  23. "data": "",
  24. "code": 0
  25. },
  26. "id": "",
  27. "jsonrpc": "2.0"
  28. }
  29. ```
  30. The first entry in the result-array (`96`) is the method this response correlates with. `96` refers to "ResultTypeBroadcastTx", see [responses.go](https://github.com/tendermint/tendermint/blob/master/rpc/core/types/responses.go) for a complete overview.
  31. ## JSONRPC/HTTP
  32. JSONRPC requests can be POST'd to the root RPC endpoint via HTTP (e.g. `http://localhost:46657/`).
  33. ```json
  34. {
  35. "method": "broadcast_tx_sync",
  36. "jsonrpc": "2.0",
  37. "params": [ "abc" ],
  38. "id": "dontcare"
  39. }
  40. ```
  41. ## JSONRPC/websockets
  42. JSONRPC requests can be made via websocket. The websocket endpoint is at `/websocket`, e.g. `localhost:46657/websocket`. Asynchronous RPC functions like event `subscribe` and `unsubscribe` are only available via websockets.
  43. ## More Examples
  44. See the various bash tests using curl in `test/`, and examples using the `Go` API in `rpc/client/`.
  45. ## Get the list
  46. An HTTP Get request to the root RPC endpoint shows a list of available endpoints.
  47. ```bash
  48. curl 'localhost:46657'
  49. ```
  50. > Response:
  51. ```plain
  52. Available endpoints:
  53. /abci_info
  54. /dump_consensus_state
  55. /genesis
  56. /net_info
  57. /num_unconfirmed_txs
  58. /status
  59. /unconfirmed_txs
  60. /unsafe_flush_mempool
  61. /unsafe_stop_cpu_profiler
  62. /validators
  63. Endpoints that require arguments:
  64. /abci_query?path=_&data=_&prove=_
  65. /block?height=_
  66. /blockchain?minHeight=_&maxHeight=_
  67. /broadcast_tx_async?tx=_
  68. /broadcast_tx_commit?tx=_
  69. /broadcast_tx_sync?tx=_
  70. /commit?height=_
  71. /dial_seeds?seeds=_
  72. /subscribe?event=_
  73. /tx?hash=_&prove=_
  74. /unsafe_start_cpu_profiler?filename=_
  75. /unsafe_write_heap_profile?filename=_
  76. /unsubscribe?event=_
  77. ```
  78. # Endpoints
  79. */
  80. package core