github.com/okex/exchain@v1.8.0/libs/tendermint/rpc/core/doc.go (about)

     1  /*
     2  # Introduction
     3  
     4  Tendermint supports the following RPC protocols:
     5  
     6  * URI over HTTP
     7  * JSONRPC over HTTP
     8  * JSONRPC over websockets
     9  
    10  Tendermint RPC is built using our own RPC library which contains its own set of documentation and tests.
    11  See it here: https://github.com/tendermint/tendermint/tree/master/rpc/lib
    12  
    13  ## Configuration
    14  
    15  RPC can be configured by tuning parameters under `[rpc]` table in the `$TMHOME/config/config.toml` file
    16  or by using the `--rpc.X` command-line flags.
    17  
    18  Default rpc listen address is `tcp://0.0.0.0:26657`.
    19  To set another address, set the `laddr` config parameter to desired value.
    20  CORS (Cross-Origin Resource Sharing) can be enabled by setting
    21  `cors_allowed_origins`, `cors_allowed_methods`, `cors_allowed_headers` config parameters.
    22  
    23  ## Arguments
    24  
    25  Arguments which expect strings or byte arrays may be passed as quoted strings,
    26  like `"abc"` or as `0x`-prefixed strings, like `0x616263`.
    27  
    28  ## URI/HTTP
    29  
    30  ```bash
    31  curl 'localhost:26657/broadcast_tx_sync?tx="abc"'
    32  ```
    33  
    34  > Response:
    35  
    36  ```json
    37  {
    38  	"error": "",
    39  	"result": {
    40  		"hash": "2B8EC32BA2579B3B8606E42C06DE2F7AFA2556EF",
    41  		"log": "",
    42  		"data": "",
    43  		"code": "0"
    44  	},
    45  	"id": "",
    46  	"jsonrpc": "2.0"
    47  }
    48  ```
    49  
    50  ## JSONRPC/HTTP
    51  
    52  JSONRPC requests can be POST'd to the root RPC endpoint via HTTP (e.g. `http://localhost:26657/`).
    53  
    54  ```json
    55  {
    56  	"method": "broadcast_tx_sync",
    57  	"jsonrpc": "2.0",
    58  	"params": [ "abc" ],
    59  	"id": "dontcare"
    60  }
    61  ```
    62  
    63  ## JSONRPC/websockets
    64  
    65  JSONRPC requests can be made via websocket.
    66  The websocket endpoint is at `/websocket`, e.g. `localhost:26657/websocket`.
    67  Asynchronous RPC functions like event `subscribe` and `unsubscribe` are only available via websockets.
    68  
    69  
    70  ## More Examples
    71  
    72  See the various bash tests using curl in `test/`, and examples using the `Go` API in `rpc/client/`.
    73  
    74  ## Get the list
    75  
    76  An HTTP Get request to the root RPC endpoint shows a list of available endpoints.
    77  
    78  ```bash
    79  curl 'localhost:26657'
    80  ```
    81  
    82  > Response:
    83  
    84  ```plain
    85  Available endpoints:
    86  /abci_info
    87  /dump_consensus_state
    88  /genesis
    89  /net_info
    90  /num_unconfirmed_txs
    91  /status
    92  /health
    93  /unconfirmed_txs
    94  /unsafe_flush_mempool
    95  /unsafe_stop_cpu_profiler
    96  /validators
    97  
    98  Endpoints that require arguments:
    99  /abci_query?path=_&data=_&prove=_
   100  /block?height=_
   101  /blockchain?minHeight=_&maxHeight=_
   102  /broadcast_tx_async?tx=_
   103  /broadcast_tx_commit?tx=_
   104  /broadcast_tx_sync?tx=_
   105  /commit?height=_
   106  /dial_seeds?seeds=_
   107  /dial_persistent_peers?persistent_peers=_
   108  /subscribe?event=_
   109  /tx?hash=_&prove=_
   110  /unsafe_start_cpu_profiler?filename=_
   111  /unsafe_write_heap_profile?filename=_
   112  /unsubscribe?event=_
   113  ```
   114  
   115  # Endpoints
   116  */
   117  package core