Skip to main content

Transaction Methods

Transaction Methods (v0.38.x)

Download OpenAPI specification:Download

Overview

The Node RPC endpoints are intended for working with the blockchain consensus layer directly. These endpoints return information about the blocks, validators, and network layer itself while the API endpoints work at a higher level and are used to return information at the blockchain Application layer.

The RPC service would typically be used by users and applications that wish to retrieve information about raw blocks being produced or monitor for transactions and network activity.

The Node RPC service supports the following communication protocols:

  • URI over HTTP
  • JSONRPC over HTTP
  • JSONRPC over websockets

Authentication

A bearer token is required for all requests.

Exchange client id and client secret for a token:

curl -XPOST https://dev-v6yakh57b7z3ngqo.us.auth0.com/oauth/token \
-H \"content-type: application/json\" \
-d '{\"client_id\":\"<id>\",\"client_secret\":\"<secret>\",\"audience\":\"https://api.provlabs.com\",\"grant_type\":\"client_credentials\"}'

The returned token can then be used to make API calls:

curl -XGET -H \"Authorization: Bearer <token>\" https://pio-mainnet-1-rpc.provlabs.com/block?height=5

Arguments

Arguments which expect strings or byte arrays may be passed as quoted strings, like "abc" or as 0x-prefixed strings, like 0x616263.

URI/HTTP

A REST like interface.

curl https://pio-mainnet-1-rpc.provlabs.com/block?height=5

JSONRPC/HTTP

JSONRPC requests can be POST'd to the root RPC endpoint via HTTP.

curl --header "Content-Type: application/json" --request POST --data '{"method": "block", "params": ["5"], "id": 1}' https://pio-mainnet-1-rpc.provlabs.com

JSONRPC/websockets

JSONRPC requests can be also made via websocket. The websocket endpoint is at /websocket, e.g. https://pio-mainnet-1-rpc.provlabs.com/websocket. Asynchronous RPC functions like event subscribe and unsubscribe are only available via websockets.

For example using the websocat tool, you can subscribe for 'NewBlock` events with the following command:

echo '{ "jsonrpc": "2.0","method": "subscribe","id": 0,"params": {"query": "tm.event='"'NewBlock'"'"} }' | websocat -n -t wss://pio-mainnet-1-rpc.provlabs.com/websocket

Returns with the response from CheckTx. Does not wait for DeliverTx result.

If you want to be sure that the transaction is included in a block, you can subscribe for the result using JSONRPC via a websocket. See https://docs.cometbft.com/v0.38.x/core/subscription.html If you haven't received anything after a couple of blocks, resend it. If the same happens again, send it to some other node. A few reasons why it could happen:

  1. malicious node can drop or pretend it had committed your tx
  2. malicious proposer (not necessary the one you're communicating with) can drop transactions, which might become valid in the future (https://github.com/tendermint/tendermint/issues/3322)

Please refer to formatting/encoding rules for additional details

query Parameters
tx
required
string
Example: tx=456

The transaction

Responses

Response samples

Content type
application/json
{
  • "jsonrpc": "2.0",
  • "id": 0,
  • "result": {
    },
  • "error": ""
}

Returns right away, with no response. Does not wait for CheckTx nor DeliverTx results.

If you want to be sure that the transaction is included in a block, you can subscribe for the result using JSONRPC via a websocket. See https://docs.cometbft.com/v0.38.x/core/subscription.html If you haven't received anything after a couple of blocks, resend it. If the same happens again, send it to some other node. A few reasons why it could happen:

  1. malicious node can drop or pretend it had committed your tx
  2. malicious proposer (not necessary the one you're communicating with) can drop transactions, which might become valid in the future (https://github.com/tendermint/tendermint/issues/3322)
  3. node can be offline

Please refer to formatting/encoding rules for additional details

query Parameters
tx
required
string
Example: tx=123

The transaction

Responses

Response samples

Content type
application/json
{
  • "jsonrpc": "2.0",
  • "id": 0,
  • "result": {
    },
  • "error": ""
}

Returns with the responses from CheckTx and DeliverTx.

IMPORTANT: use only for testing and development. In production, use BroadcastTxSync or BroadcastTxAsync. You can subscribe for the transaction result using JSONRPC via a websocket. See https://docs.cometbft.com/v0.38.x/core/subscription.html

CONTRACT: only returns error if mempool.CheckTx() errs or if we timeout waiting for tx to commit.

If CheckTx or DeliverTx fail, no error will be returned, but the returned result will contain a non-OK ABCI code.

Please refer to formatting/encoding rules for additional details

query Parameters
tx
required
string
Example: tx=785

The transaction

Responses

Response samples

Content type
application/json
{
  • "error": "",
  • "result": {
    },
  • "id": 0,
  • "jsonrpc": "2.0"
}

Checks the transaction without executing it.

The transaction won't be added to the mempool.

Please refer to formatting/encoding rules for additional details

Upon success, the Cache-Control header will be set with the default maximum age.

query Parameters
tx
required
string
Example: tx=785

The transaction

Responses

Response samples

Content type
application/json
{
  • "error": "",
  • "result": {
    },
  • "id": 0,
  • "jsonrpc": "2.0"
}