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