JSON RPC API -1
JSON RPC API
PUT nodes accept HTTP requests using the JSON-RPC 2.0 specification.
To interact with a PUT node inside a JavaScript application, use the put-web3.js library, which gives a convenient interface for the RPC methods.
RPC HTTP Endpoint
Default port: 8899 e.g. http://localhost:8899, http://192.168.1.88:8899 RPC PubSub WebSocket Endpoint#
Default port: 8900 e.g. ws://localhost:8900, http://192.168.1.88:8900
Methods
getAccountInfo
getBalance
getBlock
getBlockHeight
getBlockProduction
getBlockCommitment
getBlocks
getBlocksWithLimit
getBlockTime
getClusterNodes
getEpochInfo
getEpochSchedule
getFeeForMessage
getFirstAvailableBlock
getGenesisHash
getHealth
getHighestSnapshotSlot
getIdentity
getInflationGovernor
getInflationRate
getInflationReward
getLargestAccounts
getLatestBlockhash
getLeaderSchedule
getMaxRetransmitSlot
getMaxShredInsertSlot
getMinimumBalanceForRentExemption
getMultipleAccounts
getProgramAccounts
getRecentPerformanceSamples
getSignaturesForAddress
getSignatureStatuses
getSlot
getSlotLeader
getSlotLeaders
getStakeActivation
getStakeMinimumDelegation
getSupply
getTokenAccountBalance
getTokenAccountsByDelegate
getTokenAccountsByOwner
getTokenLargestAccounts
getTokenSupply
getTransaction
getTransactionCount
getVersion
getVoteAccounts
isBlockhashValid
minimumLedgerSlot
requestAirdrop
sendTransaction
simulateTransaction
Subscription Websocket
accountSubscribe
accountUnsubscribe
logsSubscribe
logsUnsubscribe
programSubscribe
programUnsubscribe
signatureSubscribe
signatureUnsubscribe
slotSubscribe
slotUnsubscribeUnstable Methods
Unstable methods may see breaking changes in patch releases and may not be supported in perpetuity.
Deprecated Methods
Request Formatting
To make a JSON-RPC request, send an HTTP POST request with a Content-Type: application/json header. The JSON request data should contain 4 fields:
Example using curl:
The response output will be a JSON object with the following fields:
Requests can be sent in batches by sending an array of JSON-RPC request objects as the data for a single POST.
Definitions
Configuring State Commitment
For preflight checks and transaction processing, PUT nodes choose which bank state to query based on a commitment requirement set by the client. The commitment describes how finalized a block is at that point in time. When querying the ledger state, it's recommended to use lower levels of commitment to report progress and higher levels to ensure the state will not be rolled back.
In descending order of commitment (most finalized to least finalized), clients may specify:
For processing many dependent transactions in series, it's recommended to use "confirmed" commitment, which balances speed with rollback safety. For total safety, it's recommended to use"finalized" commitment.
Example#
The commitment parameter should be included as the last element in the params array:
Default:#
If commitment configuration is not provided, the node will default to "finalized" commitment
Only methods that query bank state accept the commitment parameter. They are indicated in the API Reference below.
RpcResponse Structure#
Many methods that take a commitment parameter return an RpcResponse JSON object comprised of two parts:
Parsed Responses#
Some methods support an encoding parameter, and can return account or instruction data in parsed JSON format if "encoding":"jsonParsed" is requested and the node has a parser for the owning program. PUT nodes currently support JSON parsing for the following native and SPL programs:
The list of account parsers can be found here, and instruction parsers here.
Health Check
Although not a JSON RPC API, a GET /health at the RPC HTTP Endpoint provides a health-check mechanism for use by load balancers or other network infrastructure. This request will always return a HTTP 200 OK response with a body of "ok", "behind" or "unknown" based on the following conditions:
JSON RPC API Reference#
getAccountInfo
Returns all information associated with the account of provided Pubkey
Parameters:#
Results:#
The result will be an RpcResponse JSON object with value equal to:
Example:#
Request:
Response:
Example:#
Request:
Response:
getBalance
Returns the balance of the account of provided Pubkey Parameters:#
Results:#
Example:#
Request:
Result:
getBlock
Returns identity and transaction information about a confirmed block in the ledger Parameters:#
Results:#
The result field will be an object with the following fields:
Example:#
Request:
Result:
Example:#
Request:
Result:
Transaction Structure#
Transactions are quite different from those on other blockchains. Be sure to review Anatomy of a Transaction to learn about transactions on PUT.
The JSON structure of a transaction is defined as follows:
Inner Instructions Structure#
The PUT runtime records the cross-program instructions that are invoked during transaction processing and makes these available for greater transparency of what was executed on-chain per transaction instruction. Invoked instructions are grouped by the originating transaction instruction and are listed in order of processing.
The JSON structure of inner instructions is defined as a list of objects in the following structure:
Token Balances Structure#
The JSON structure of token balances is defined as a list of objects in the following structure:
getBlockHeight
Returns the current block height of the node Parameters:#
Results:#
Example:#
Request:
Result:
getBlockProduction
Returns recent block production information from the current or previous epoch.
Parameters:#
Results:#
The result will be an RpcResponse JSON object with value equal to:
Example:#
Request:
Result:
Example:#
Request:
Result:
getBlockCommitment
Returns commitment for particular block Parameters:#
Results:#
The result field will be a JSON object containing:
Example:#
Request:
Result:
getBlocks
Returns a list of confirmed blocks between two slots
Parameters:#
Results:#
The result field will be an array of u64 integers listing confirmed blocks between start_slot and either end_slot, if provided, or latest confirmed block, inclusive. Max range allowed is 500,000 slots.
Example:#
Request:
Result: { "jsonrpc": "2.0", "result": [5, 6, 7, 8, 9, 10], "id": 1 }
getBlocksWithLimit#
Returns a list of confirmed blocks starting at the given slot
Parameters:#
Results:#
The result field will be an array of u64 integers listing confirmed blocks starting at start_slot for up to limit blocks, inclusive.
Example:#
Request:
Result:
getBlockTime
Returns the estimated production time of a block.
Each validator reports their UTC time to the ledger on a regular interval by intermittently adding a timestamp to a Vote for a particular block. A requested block's time is calculated from the stake-weighted mean of the Vote timestamps in a set of recent blocks recorded on the ledger.
Parameters:#
Results:#
Example:#
Request:
Result:
getClusterNodes
Returns information about all the nodes participating in the cluster
Parameters:#
None
Results:#
The result field will be an array of JSON objects, each with the following sub fields:
Example:#
Request:
Result:
getEpochInfo
Returns information about the current epoch
Parameters:#
Results:#
The result field will be an object with the following fields:
Example:#
Request:
Result:
getEpochInfo
Returns information about the current epoch
Parameters:#
Results:#
The result field will be an object with the following fields:
Example:#
Request:
Result:
getEpochSchedule
Returns epoch schedule information from this cluster's genesis config
Parameters:#
None
Results:#
The result field will be an object with the following fields:
Example:#
Request:
Result:
getFeeForMessage
NEW: This method is only available in put-core v1.9 or newer. Please use getFees for put-core v1.8
Get the fee the network will charge for a particular Message
Parameters:#
Results:#
Example:#
Request:
Result:
getFirstAvailableBlock
Returns the slot of the lowest confirmed block that has not been purged from the ledger
Parameters:#
None
Results:#
Example:#
Request:
Result:
getGenesisHash
Returns the genesis hash
Parameters:#
None
Results:#
Example:#
Request:
Result:
getHealth
Returns the current health of the node.
If one or more --known-validator arguments are provided to put-validator, "ok" is returned when the node has within HEALTH_CHECK_SLOT_DISTANCE slots of the highest known validator, otherwise an error is returned. "ok" is always returned if no known validators are provided.
Parameters:#
None
Results:#
If the node is healthy: "ok" If the node is unhealthy, a JSON RPC error response is returned. The specifics of the error response are UNSTABLE and may change in the future
Example:#
Request:
Healthy Result:
Unhealthy Result (generic):
Unhealthy Result (if additional information is available)
getHighestSnapshotSlot
NEW: This method is only available in put-core v1.9 or newer. Please use getSnapshotSlot for put-core v1.8
Returns the highest slot information that the node has snapshots for.
This will find the highest full snapshot slot, and the highest incremental snapshot slot based on the full snapshot slot, if there is one.
Parameters:#
None
Results:#
Example:#
Request:
Result:
Result when the node has no snapshot:
getIdentity
Returns the identity pubkey for the current node
Parameters:#
None
Results:#
The result field will be a JSON object with the following fields:
Example:#
Request:
Result:
getInflationGovernor
Returns the current inflation governor
Parameters:#
Results:#
The result field will be a JSON object with the following fields:
Example:#
Request:
Result:
getInflationRate
Returns the specific inflation values for the current epoch
Parameters:#
None
Results:#
The result field will be a JSON object with the following fields:
Example:#
Request:
Result:
getInflationReward
Returns the inflation / staking reward for a list of addresses for an epoch
Parameters:#
Results#
The result field will be a JSON array with the following fields:
Example#
Request:
Response:
getLargestAccounts
Returns the 20 largest accounts, by lamport balance (results may be cached up to two hours)
Parameters:#
Results:#
The result will be an RpcResponse JSON object with value equal to an array of:
Example:#
Request:
Result:
getLatestBlockhash#
NEW: This method is only available in put-core v1.9 or newer. Please use getRecentBlockhash for put-core v1.8
Returns the latest blockhash Parameters:#
Results:#
Example:#
Request:
Result:
getLeaderSchedule
Returns the leader schedule for an epoch Parameters:#
Results:#
Example:#
Request:
Result:
Example:#
Request:
Result:
getMaxRetransmitSlot
Get the max slot seen from retransmit stage.
Results:#
Example:#
Request:
Result:
getMaxShredInsertSlot
Get the max slot seen from after shred insert. Results:#
Example:#
Request:
Result:
getMinimumBalanceForRentExemption
Returns minimum balance required to make account rent exempt.
Parameters:#
Results:#
Example:#
Request:
Result:
getMultipleAccounts
Returns the account information for a list of Pubkeys.
Parameters:#
Results:#
The result will be an RpcResponse JSON object with value equal to:
An array of:
Example:#
Request:
'
Result:
}
Example:#
Request:
'
Result:
getProgramAccounts
Returns all accounts owned by the provided program Pubkey
Parameters:#
Filters:#
Results:#
By default the result field will be an array of JSON objects. If withContext flag is set the array will be wrapped in an RpcResponse JSON object.
The array will contain:
Example:#
Request:
Result:
Example:#
Request:
Result:
}
getRecentPerformanceSamples
Returns a list of recent performance samples, in reverse slot order. Performance samples are taken every 60 seconds and include the number of transactions and slots that occur in a given time window.
Parameters:#
Results:#
An array of:
Example:#
Request:
Result:
getSignaturesForAddress
Returns signatures for confirmed transactions that include the given address in their accountKeys list. Returns signatures backwards in time from the provided signature or most recent confirmed block
Parameters:#
Results:#
The result field will be an array of transaction signature information, ordered from newest to oldest transaction:
Example:#
Request:
Result:
getSignatureStatuses
Returns the statuses of a list of signatures. Unless the searchTransactionHistory configuration parameter is included, this method only searches the recent status cache of signatures, which retains statuses for all active slots plus MAX_RECENT_BLOCKHASHES rooted slots.
Parameters:#
Results:#
An RpcResponse containing a JSON object consisting of an array of TransactionStatus objects.
An array of:
Example:#
Request:
'
Result:
Example:#
Request:
Result:
getSlot
Returns the slot that has reached the given or default commitment level Parameters:#
Results:#
Example:#
Request:
Result:
getSlotLeader
Returns the current slot leader
Parameters:#
Results:#
Example:#
Request:
Result:
getSlotLeaders
Returns the slot leaders for a given slot range Parameters:#
Results:#
Example:#
If the current slot is #99, query the next 10 leaders with the following request:
Request:
Result:
The first leader returned is the leader for slot #100:
getStakeActivation
Returns epoch activation information for a stake account
Parameters:#
Results:#
The result will be a JSON object with the following fields:
Example:#
Request:
Result:
Example:#
Request:
Result:
getStakeMinimumDelegation
Returns the stake minimum delegation, in lamports.
Parameters:#
Results:#
The result will be an RpcResponse JSON object with value equal to:
Example:#
Request:
Result:
getSupply#
Returns information about the current supply.
Parameters:#
Results:#
The result will be an RpcResponse JSON object with value equal to a JSON object containing:
Example:#
Request:
Result:
getTokenAccountBalance
Returns the token balance of an SPL Token account.
Parameters:#
Results:#
The result will be an RpcResponse JSON object with value equal to a JSON object containing:
For more details on returned data: The Token Balances Structure response from getBlock follows a similar structure. Example:#
Request:
Result:
getTokenAccountsByDelegate
Returns all SPL Token accounts by approved Delegate.
Parameters:#
Results:#
The result will be an RpcResponse JSON object with value equal to an array of JSON objects, which will contain:
When the data is requested with the jsonParsed encoding a format similar to that of the Token Balances Structure can be expected inside the structure, both for the tokenAmount and the delegatedAmount, with the latter being an optional object.
Example:#
Result:
getTokenAccountsByOwner#
Returns all SPL Token accounts by token owner.
Parameters:#
Results:#
The result will be an RpcResponse JSON object with value equal to an array of JSON objects, which will contain:
When the data is requested with the jsonParsed encoding a format similar to that of the Token Balances Structure can be expected inside the structure, both for the tokenAmount and the delegatedAmount, with the latter being an optional object.
Example:#
Result:
getTokenLargestAccounts#
Returns the 20 largest accounts of a particular SPL Token type. Parameters:#
Results:#
The result will be an RpcResponse JSON object with value equal to an array of JSON objects containing:
Example:#
Result:
getTokenSupply
Returns the total supply of an SPL Token type.
Parameters:#
Results:#
The result will be an RpcResponse JSON object with value equal to a JSON object containing:
Example:#
Result:
getTransaction
Returns transaction details for a confirmed transaction
Parameters:#
Results:#
Example:#
Request:
Result:
Example:#
Request:
Result:
getTransactionCount
Returns the current Transaction count from the ledger Parameters:#
Results:#
Example:#
Result: { "jsonrpc": "2.0", "result": 268, "id": 1 }
getVersion#
Returns the current PUT versions running on the node
Parameters:#
None
Results:#
The result field will be a JSON object with the following fields:
Example:#
Request: curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' {"jsonrpc":"2.0","id":1, "method":"getVersion"} '
Result: { "jsonrpc": "2.0", "result": { "put-core": "1.14.3" }, "id": 1 }
getVoteAccounts#
Returns the account info and associated stake for all the voting accounts in the current bank.
Parameters:#
Results:#
The result field will be a JSON object of current and delinquent accounts, each containing an array of JSON objects with the following sub fields:
Example:#
Request:
Result:
Example: Restrict results to a single validator vote account#
Request:
Result:
isBlockhashValid
NEW: This method is only available in put-core v1.9 or newer. Please use getFeeCalculatorForBlockhash for put-core v1.8
Returns whether a blockhash is still valid or not
Parameters:#
Results:#
Example:#
Request:
Result:
minimumLedgerSlot
Returns the lowest slot that the node has information about in its ledger. This value may increase over time if the node is configured to purge older ledger data
Parameters:#
None
Results:#
Example:#
Result:
requestAirdrop
Requests an airdrop of lamports to a Pubkey
Parameters:#
Results:#
Example:#
Result:
sendTransaction
Submits a signed transaction to the cluster for processing.
This method does not alter the transaction in any way; it relays the transaction created by clients to the node as-is.
If the node's rpc service receives the transaction, this method immediately succeeds, without waiting for any confirmations. A successful response from this method does not guarantee the transaction is processed or confirmed by the cluster.
While the rpc service will reasonably retry to submit it, the transaction could be rejected if transaction's recent_blockhash expires before it lands.
Use getSignatureStatuses to ensure a transaction is processed and confirmed.
Before submitting, the following preflight checks are performed:
The returned signature is the first signature in the transaction, which is used to identify the transaction (transaction id). This identifier can be easily extracted from the transaction data before submission.
Parameters:#
Results:#
Example:#
Result:
simulateTransaction
Simulate sending a transaction
Parameters:#
Results:#
An RpcResponse containing a TransactionStatus object The result will be an RpcResponse JSON object with value set to a JSON object with the following fields:
Example:#
Result:
Last updated