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.3 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. ## JSONRPC/HTTP
  31. JSONRPC requests can be POST'd to the root RPC endpoint via HTTP (e.g. `http://localhost:26657/`).
  32. ```json
  33. {
  34. "method": "broadcast_tx_sync",
  35. "jsonrpc": "2.0",
  36. "params": [ "abc" ],
  37. "id": "dontcare"
  38. }
  39. ```
  40. ## JSONRPC/websockets
  41. 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.
  42. ## More Examples
  43. See the various bash tests using curl in `test/`, and examples using the `Go` API in `rpc/client/`.
  44. ## Get the list
  45. An HTTP Get request to the root RPC endpoint shows a list of available endpoints.
  46. ```bash
  47. curl 'localhost:26657'
  48. ```
  49. > Response:
  50. ```plain
  51. Available endpoints:
  52. /abci_info
  53. /dump_consensus_state
  54. /genesis
  55. /net_info
  56. /num_unconfirmed_txs
  57. /status
  58. /health
  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. /dial_persistent_peers?persistent_peers=_
  73. /subscribe?event=_
  74. /tx?hash=_&prove=_
  75. /unsafe_start_cpu_profiler?filename=_
  76. /unsafe_write_heap_profile?filename=_
  77. /unsubscribe?event=_
  78. ```
  79. # Endpoints
  80. */
  81. package core