Tendermint RPC


Requests that return multiple items will be paginated to 30 items by default. You can specify further pages with the ?page parameter. You can also set a custom page size up to 100 with the ?per_page parameter.

Subscribing to events

The user can subscribe to events emitted by Tendermint, using /subscribe. If the maximum number of clients is reached or the client has too many subscriptions, an error will be returned. The subscription timeout is 5 sec. Each subscription has a buffer to accommodate short bursts of events or some slowness in clients. If the buffer gets full, the subscription will be canceled ("client is not pulling messages fast enough"). If Tendermint exits, all subscriptions are canceled ("Tendermint exited"). The user can unsubscribe using either /unsubscribe or /unsubscribe_all.

Expand ▾ Collapse ▴



    Package core defines the Tendermint RPC endpoints.

    Tendermint ships with its own JSONRPC library -

    ## Get the list

    An HTTP Get request to the root RPC endpoint shows a list of available endpoints.

    “`bash curl 'localhost:26657' “`

    > Response:

    “`plain Available endpoints: /abci_info /dump_consensus_state /genesis /net_info /num_unconfirmed_txs /status /health /unconfirmed_txs /unsafe_flush_mempool /validators

    Endpoints that require arguments: /abci_query?path=_&data=_&prove=_ /block?height=_ /blockchain?minHeight=_&maxHeight=_ /broadcast_tx_async?tx=_ /broadcast_tx_commit?tx=_ /broadcast_tx_sync?tx=_ /commit?height=_ /dial_seeds?seeds=_ /dial_persistent_peers?persistent_peers=_ /subscribe?event=_ /tx?hash=_&prove=_ /unsubscribe?event=_ “`



    View Source
    const (
    	// SubscribeTimeout is the maximum time we wait to subscribe for an event.
    	// must be less than the server's write timeout (see rpcserver.DefaultConfig)
    	SubscribeTimeout = 5 * time.Second


    View Source
    var Routes = map[string]*rpc.RPCFunc{
    	"subscribe":       rpc.NewWSRPCFunc(Subscribe, "query"),
    	"unsubscribe":     rpc.NewWSRPCFunc(Unsubscribe, "query"),
    	"unsubscribe_all": rpc.NewWSRPCFunc(UnsubscribeAll, ""),
    	"health":               rpc.NewRPCFunc(Health, ""),
    	"status":               rpc.NewRPCFunc(Status, ""),
    	"net_info":             rpc.NewRPCFunc(NetInfo, ""),
    	"blockchain":           rpc.NewRPCFunc(BlockchainInfo, "minHeight,maxHeight"),
    	"genesis":              rpc.NewRPCFunc(Genesis, ""),
    	"block":                rpc.NewRPCFunc(Block, "height"),
    	"block_by_hash":        rpc.NewRPCFunc(BlockByHash, "hash"),
    	"block_results":        rpc.NewRPCFunc(BlockResults, "height"),
    	"commit":               rpc.NewRPCFunc(Commit, "height"),
    	"check_tx":             rpc.NewRPCFunc(CheckTx, "tx"),
    	"tx":                   rpc.NewRPCFunc(Tx, "hash,prove"),
    	"tx_search":            rpc.NewRPCFunc(TxSearch, "query,prove,page,per_page,order_by"),
    	"validators":           rpc.NewRPCFunc(Validators, "height,page,per_page"),
    	"dump_consensus_state": rpc.NewRPCFunc(DumpConsensusState, ""),
    	"consensus_state":      rpc.NewRPCFunc(ConsensusState, ""),
    	"consensus_params":     rpc.NewRPCFunc(ConsensusParams, "height"),
    	"unconfirmed_txs":      rpc.NewRPCFunc(UnconfirmedTxs, "limit"),
    	"num_unconfirmed_txs":  rpc.NewRPCFunc(NumUnconfirmedTxs, ""),
    	"broadcast_tx_commit": rpc.NewRPCFunc(BroadcastTxCommit, "tx"),
    	"broadcast_tx_sync":   rpc.NewRPCFunc(BroadcastTxSync, "tx"),
    	"broadcast_tx_async":  rpc.NewRPCFunc(BroadcastTxAsync, "tx"),
    	"abci_query": rpc.NewRPCFunc(ABCIQuery, "path,data,height,prove"),
    	"abci_info":  rpc.NewRPCFunc(ABCIInfo, ""),
    	"broadcast_evidence": rpc.NewRPCFunc(BroadcastEvidence, "evidence"),

      Routes is a map of available routes.


      func ABCIInfo

      func ABCIInfo(ctx *rpctypes.Context) (*ctypes.ResultABCIInfo, error)

        ABCIInfo gets some info about the application. More:

        func ABCIQuery

        func ABCIQuery(
        	ctx *rpctypes.Context,
        	path string,
        	data bytes.HexBytes,
        	height int64,
        	prove bool,
        ) (*ctypes.ResultABCIQuery, error)

          ABCIQuery queries the application for some information. More:

          func AddUnsafeRoutes

          func AddUnsafeRoutes()

            AddUnsafeRoutes adds unsafe routes.

            func Block

            func Block(ctx *rpctypes.Context, heightPtr *int64) (*ctypes.ResultBlock, error)

              Block gets block at a given height. If no height is provided, it will fetch the latest block. More:

              func BlockByHash

              func BlockByHash(ctx *rpctypes.Context, hash []byte) (*ctypes.ResultBlock, error)

                BlockByHash gets block by hash. More:

                func BlockResults

                func BlockResults(ctx *rpctypes.Context, heightPtr *int64) (*ctypes.ResultBlockResults, error)

                  BlockResults gets ABCIResults at a given height. If no height is provided, it will fetch results for the latest block.

                  Results are for the height of the block containing the txs. Thus response.results.deliver_tx[5] is the results of executing getBlock(h).Txs[5] More:

                  func BlockchainInfo

                  func BlockchainInfo(ctx *rpctypes.Context, minHeight, maxHeight int64) (*ctypes.ResultBlockchainInfo, error)

                    BlockchainInfo gets block headers for minHeight <= height <= maxHeight. Block headers are returned in descending order (highest first). More:

                    func BroadcastEvidence

                    func BroadcastEvidence(ctx *rpctypes.Context, ev types.Evidence) (*ctypes.ResultBroadcastEvidence, error)

                      BroadcastEvidence broadcasts evidence of the misbehavior. More:

                      func BroadcastTxAsync

                      func BroadcastTxAsync(ctx *rpctypes.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error)

                        BroadcastTxAsync returns right away, with no response. Does not wait for CheckTx nor DeliverTx results. More:

                        func BroadcastTxCommit

                        func BroadcastTxCommit(ctx *rpctypes.Context, tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error)

                          BroadcastTxCommit returns with the responses from CheckTx and DeliverTx. More:

                          func BroadcastTxSync

                          func BroadcastTxSync(ctx *rpctypes.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error)

                            BroadcastTxSync returns with the response from CheckTx. Does not wait for DeliverTx result. More:

                            func CheckTx

                            func CheckTx(ctx *rpctypes.Context, tx types.Tx) (*ctypes.ResultCheckTx, error)

                              CheckTx checks the transaction without executing it. The transaction won't be added to the mempool either. More:

                              func Commit

                              func Commit(ctx *rpctypes.Context, heightPtr *int64) (*ctypes.ResultCommit, error)

                                Commit gets block commit at a given height. If no height is provided, it will fetch the commit for the latest block. More:

                                func ConsensusParams

                                func ConsensusParams(ctx *rpctypes.Context, heightPtr *int64) (*ctypes.ResultConsensusParams, error)

                                  ConsensusParams gets the consensus parameters at the given block height. If no height is provided, it will fetch the latest consensus params. More:

                                  func ConsensusState

                                  func ConsensusState(ctx *rpctypes.Context) (*ctypes.ResultConsensusState, error)

                                    ConsensusState returns a concise summary of the consensus state. UNSTABLE More:

                                    func DumpConsensusState

                                    func DumpConsensusState(ctx *rpctypes.Context) (*ctypes.ResultDumpConsensusState, error)

                                      DumpConsensusState dumps consensus state. UNSTABLE More:

                                      func Genesis

                                      func Genesis(ctx *rpctypes.Context) (*ctypes.ResultGenesis, error)

                                        Genesis returns genesis file. More:

                                        func Health

                                        func Health(ctx *rpctypes.Context) (*ctypes.ResultHealth, error)

                                          Health gets node health. Returns empty result (200 OK) on success, no response - in case of an error. More:

                                          func NetInfo

                                          func NetInfo(ctx *rpctypes.Context) (*ctypes.ResultNetInfo, error)

                                            NetInfo returns network info. More:

                                            func NumUnconfirmedTxs

                                            func NumUnconfirmedTxs(ctx *rpctypes.Context) (*ctypes.ResultUnconfirmedTxs, error)

                                              NumUnconfirmedTxs gets number of unconfirmed transactions. More:

                                              func SetEnvironment

                                              func SetEnvironment(e *Environment)

                                                SetEnvironment sets up the given Environment. It will race if multiple Node call SetEnvironment.

                                                func Status

                                                func Status(ctx *rpctypes.Context) (*ctypes.ResultStatus, error)

                                                  Status returns Tendermint status including node info, pubkey, latest block hash, app hash, block height and time. More:

                                                  func Subscribe

                                                  func Subscribe(ctx *rpctypes.Context, query string) (*ctypes.ResultSubscribe, error)

                                                    Subscribe for events via WebSocket. More:

                                                    func Tx

                                                    func Tx(ctx *rpctypes.Context, hash []byte, prove bool) (*ctypes.ResultTx, error)

                                                      Tx allows you to query the transaction results. `nil` could mean the transaction is in the mempool, invalidated, or was not sent in the first place. More:

                                                      func TxSearch

                                                      func TxSearch(ctx *rpctypes.Context, query string, prove bool, pagePtr, perPagePtr *int, orderBy string) (
                                                      	*ctypes.ResultTxSearch, error)

                                                        TxSearch allows you to query for multiple transactions results. It returns a list of transactions (maximum ?per_page entries) and the total count. More:

                                                        func UnconfirmedTxs

                                                        func UnconfirmedTxs(ctx *rpctypes.Context, limitPtr *int) (*ctypes.ResultUnconfirmedTxs, error)

                                                          UnconfirmedTxs gets unconfirmed transactions (maximum ?limit entries) including their number. More:

                                                          func UnsafeDialPeers

                                                          func UnsafeDialPeers(ctx *rpctypes.Context, peers []string, persistent, unconditional, private bool) (
                                                          	*ctypes.ResultDialPeers, error)

                                                            UnsafeDialPeers dials the given peers (comma-separated id@IP:PORT), optionally making them persistent.

                                                            func UnsafeDialSeeds

                                                            func UnsafeDialSeeds(ctx *rpctypes.Context, seeds []string) (*ctypes.ResultDialSeeds, error)

                                                              UnsafeDialSeeds dials the given seeds (comma-separated id@IP:PORT).

                                                              func UnsafeFlushMempool

                                                              func UnsafeFlushMempool(ctx *rpctypes.Context) (*ctypes.ResultUnsafeFlushMempool, error)

                                                                UnsafeFlushMempool removes all transactions from the mempool.

                                                                func Unsubscribe

                                                                func Unsubscribe(ctx *rpctypes.Context, query string) (*ctypes.ResultUnsubscribe, error)

                                                                  Unsubscribe from events via WebSocket. More:

                                                                  func UnsubscribeAll

                                                                  func UnsubscribeAll(ctx *rpctypes.Context) (*ctypes.ResultUnsubscribe, error)

                                                                    UnsubscribeAll from all events via WebSocket. More:

                                                                    func Validators

                                                                    func Validators(ctx *rpctypes.Context, heightPtr *int64, pagePtr, perPagePtr *int) (*ctypes.ResultValidators, error)

                                                                      Validators gets the validator set at the given block height.

                                                                      If no height is provided, it will fetch the latest validator set. Note the validators are sorted by their voting power - this is the canonical order for the validators in the set as used in computing their Merkle root.



                                                                      type Consensus

                                                                      type Consensus interface {
                                                                      	GetState() sm.State
                                                                      	GetValidators() (int64, []*types.Validator)
                                                                      	GetLastHeight() int64
                                                                      	GetRoundStateJSON() ([]byte, error)
                                                                      	GetRoundStateSimpleJSON() ([]byte, error)

                                                                      type Environment

                                                                      type Environment struct {
                                                                      	// external, thread safe interfaces
                                                                      	ProxyAppQuery   proxy.AppConnQuery
                                                                      	ProxyAppMempool proxy.AppConnMempool
                                                                      	// interfaces defined in types and above
                                                                      	StateStore     sm.Store
                                                                      	BlockStore     sm.BlockStore
                                                                      	EvidencePool   sm.EvidencePool
                                                                      	ConsensusState Consensus
                                                                      	P2PPeers       peers
                                                                      	P2PTransport   transport
                                                                      	// objects
                                                                      	PubKey           crypto.PubKey
                                                                      	GenDoc           *types.GenesisDoc // cache the genesis structure
                                                                      	TxIndexer        txindex.TxIndexer
                                                                      	ConsensusReactor *consensus.Reactor
                                                                      	EventBus         *types.EventBus // thread safe
                                                                      	Mempool          mempl.Mempool
                                                                      	Logger log.Logger
                                                                      	Config cfg.RPCConfig

                                                                        ---------------------------------------------- Environment contains objects and interfaces used by the RPC. It is expected to be setup once during startup.


                                                                        Path Synopsis