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.

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