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.

109 lines
2.5 KiB

  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) which contains its own set of documentation and tests.
  8. ## Configuration
  9. Set the `laddr` config parameter under `[rpc]` table in the `$TMHOME/config/config.toml` file or the `--rpc.laddr` command-line flag to the desired protocol://host:port setting. Default: `tcp://0.0.0.0:26657`.
  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:26657/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:26657/`).
  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:26657/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:26657'
  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. /health
  60. /unconfirmed_txs
  61. /unsafe_flush_mempool
  62. /unsafe_stop_cpu_profiler
  63. /validators
  64. Endpoints that require arguments:
  65. /abci_query?path=_&data=_&prove=_
  66. /block?height=_
  67. /blockchain?minHeight=_&maxHeight=_
  68. /broadcast_tx_async?tx=_
  69. /broadcast_tx_commit?tx=_
  70. /broadcast_tx_sync?tx=_
  71. /commit?height=_
  72. /dial_seeds?seeds=_
  73. /dial_persistent_peers?persistent_peers=_
  74. /subscribe?event=_
  75. /tx?hash=_&prove=_
  76. /unsafe_start_cpu_profiler?filename=_
  77. /unsafe_write_heap_profile?filename=_
  78. /unsubscribe?event=_
  79. ```
  80. # Endpoints
  81. */
  82. package core