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.

111 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 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. RPC can be configured by tuning parameters under `[rpc]` table in the `$TMHOME/config/config.toml` file or by using the `--rpc.X` command-line flags.
  11. Default rpc listen address is `tcp://0.0.0.0:26657`. To set another address, set the `laddr` config parameter to desired value.
  12. CORS (Cross-Origin Resource Sharing) can be enabled by setting `cors_allowed_origins`, `cors_allowed_methods`, `cors_allowed_headers` config parameters.
  13. ## Arguments
  14. Arguments which expect strings or byte arrays may be passed as quoted strings, like `"abc"` or as `0x`-prefixed strings, like `0x616263`.
  15. ## URI/HTTP
  16. ```bash
  17. curl 'localhost:26657/broadcast_tx_sync?tx="abc"'
  18. ```
  19. > Response:
  20. ```json
  21. {
  22. "error": "",
  23. "result": {
  24. "hash": "2B8EC32BA2579B3B8606E42C06DE2F7AFA2556EF",
  25. "log": "",
  26. "data": "",
  27. "code": "0"
  28. },
  29. "id": "",
  30. "jsonrpc": "2.0"
  31. }
  32. ```
  33. ## JSONRPC/HTTP
  34. JSONRPC requests can be POST'd to the root RPC endpoint via HTTP (e.g. `http://localhost:26657/`).
  35. ```json
  36. {
  37. "method": "broadcast_tx_sync",
  38. "jsonrpc": "2.0",
  39. "params": [ "abc" ],
  40. "id": "dontcare"
  41. }
  42. ```
  43. ## JSONRPC/websockets
  44. 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.
  45. ## More Examples
  46. See the various bash tests using curl in `test/`, and examples using the `Go` API in `rpc/client/`.
  47. ## Get the list
  48. An HTTP Get request to the root RPC endpoint shows a list of available endpoints.
  49. ```bash
  50. curl 'localhost:26657'
  51. ```
  52. > Response:
  53. ```plain
  54. Available endpoints:
  55. /abci_info
  56. /dump_consensus_state
  57. /genesis
  58. /net_info
  59. /num_unconfirmed_txs
  60. /status
  61. /health
  62. /unconfirmed_txs
  63. /unsafe_flush_mempool
  64. /unsafe_stop_cpu_profiler
  65. /validators
  66. Endpoints that require arguments:
  67. /abci_query?path=_&data=_&prove=_
  68. /block?height=_
  69. /blockchain?minHeight=_&maxHeight=_
  70. /broadcast_tx_async?tx=_
  71. /broadcast_tx_commit?tx=_
  72. /broadcast_tx_sync?tx=_
  73. /commit?height=_
  74. /dial_seeds?seeds=_
  75. /dial_persistent_peers?persistent_peers=_
  76. /subscribe?event=_
  77. /tx?hash=_&prove=_
  78. /unsafe_start_cpu_profiler?filename=_
  79. /unsafe_write_heap_profile?filename=_
  80. /unsubscribe?event=_
  81. ```
  82. # Endpoints
  83. */
  84. package core