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.

108 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 which contains its own set of documentation and tests.
  8. See it here: https://github.com/tendermint/tendermint/tree/master/rpc/lib
  9. ## Configuration
  10. 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`.
  11. ## Arguments
  12. Arguments which expect strings or byte arrays may be passed as quoted strings, like `"abc"` or as `0x`-prefixed strings, like `0x616263`.
  13. ## URI/HTTP
  14. ```bash
  15. curl 'localhost:26657/broadcast_tx_sync?tx="abc"'
  16. ```
  17. > Response:
  18. ```json
  19. {
  20. "error": "",
  21. "result": {
  22. "hash": "2B8EC32BA2579B3B8606E42C06DE2F7AFA2556EF",
  23. "log": "",
  24. "data": "",
  25. "code": "0"
  26. },
  27. "id": "",
  28. "jsonrpc": "2.0"
  29. }
  30. ```
  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