diff --git a/docs/src/developing/clients/jsonrpc-api.md b/docs/src/developing/clients/jsonrpc-api.md index c6f54aea87..b2d3df6011 100644 --- a/docs/src/developing/clients/jsonrpc-api.md +++ b/docs/src/developing/clients/jsonrpc-api.md @@ -10,11 +10,11 @@ gives a convenient interface for the RPC methods. ## RPC HTTP Endpoint -**Default port:** 8899 eg. [http://localhost:8899](http://localhost:8899), [http://192.168.1.88:8899](http://192.168.1.88:8899) +**Default port:** 8899 e.g. [http://localhost:8899](http://localhost:8899), [http://192.168.1.88:8899](http://192.168.1.88:8899) ## RPC PubSub WebSocket Endpoint -**Default port:** 8900 eg. ws://localhost:8900, [http://192.168.1.88:8900](http://192.168.1.88:8900) +**Default port:** 8900 e.g. ws://localhost:8900, [http://192.168.1.88:8900](http://192.168.1.88:8900) ## Methods @@ -107,8 +107,7 @@ Unstable methods may see breaking changes in patch releases and may not be suppo ## 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: +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: - `jsonrpc: `, set to `"2.0"` - `id: `, a unique client-generated identifying integer @@ -149,7 +148,7 @@ Requests can be sent in batches by sending an array of JSON-RPC request objects For preflight checks and transaction processing, Solana 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 +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. @@ -157,15 +156,15 @@ In descending order of commitment (most finalized to least finalized), clients may specify: - `"finalized"` - the node will query the most recent block confirmed by supermajority -of the cluster as having reached maximum lockout, meaning the cluster has -recognized this block as finalized + of the cluster as having reached maximum lockout, meaning the cluster has + recognized this block as finalized - `"confirmed"` - the node will query the most recent block that has been voted on by supermajority of the cluster. - It incorporates votes from gossip and replay. - It does not count votes on descendants of a block, only direct votes on that block. - This confirmation level also upholds "optimistic confirmation" guarantees in release 1.3 and onwards. - `"processed"` - the node will query its most recent block. Note that the block -may still be skipped by the cluster. + may still be skipped by the cluster. For processing many dependent transactions in series, it's recommended to use `"confirmed"` commitment, which balances speed with rollback safety. @@ -227,9 +226,9 @@ Returns all information associated with the account of provided Pubkey - `` - Pubkey of account to query, as base-58 encoded string - `` - (optional) Configuration object containing the following optional -fields: + fields: - (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment) - - `encoding: ` - encoding for Account data, either "base58" (*slow*), "base64", "base64+zstd", or "jsonParsed". + - `encoding: ` - encoding for Account data, either "base58" (_slow_), "base64", "base64+zstd", or "jsonParsed". "base58" is limited to Account data of less than 129 bytes. "base64" will return base64 encoded data for Account data of any size. "base64+zstd" compresses the Account data using [Zstandard](https://facebook.github.io/zstd/) and base64-encodes the result. @@ -251,6 +250,7 @@ The result will be an RpcResponse JSON object with `value` equal to: #### Example: Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' { @@ -266,7 +266,9 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' } ' ``` + Response: + ```json { "jsonrpc": "2.0", @@ -290,7 +292,9 @@ Response: ``` #### Example: + Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' { @@ -306,7 +310,9 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' } ' ``` + Response: + ```json { "jsonrpc": "2.0", @@ -352,6 +358,7 @@ Returns the balance of the account of provided Pubkey #### Example: Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' {"jsonrpc":"2.0", "id":1, "method":"getBalance", "params":["83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri"]} @@ -359,8 +366,13 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json -{"jsonrpc":"2.0","result":{"context":{"slot":1},"value":0},"id":1} +{ + "jsonrpc": "2.0", + "result": { "context": { "slot": 1 }, "value": 0 }, + "id": 1 +} ``` ### getBlock @@ -371,8 +383,8 @@ Returns identity and transaction information about a confirmed block in the ledg - `` - slot, as u64 integer - `` - (optional) Configuration object containing the following optional fields: - - (optional) `encoding: ` - encoding for each returned Transaction, either "json", "jsonParsed", "base58" (*slow*), "base64". If parameter not provided, the default encoding is "json". - "jsonParsed" encoding attempts to use program-specific instruction parsers to return more human-readable and explicit data in the `transaction.message.instructions` list. If "jsonParsed" is requested but a parser cannot be found, the instruction falls back to regular JSON encoding (`accounts`, `data`, and `programIdIndex` fields). + - (optional) `encoding: ` - encoding for each returned Transaction, either "json", "jsonParsed", "base58" (_slow_), "base64". If parameter not provided, the default encoding is "json". + "jsonParsed" encoding attempts to use program-specific instruction parsers to return more human-readable and explicit data in the `transaction.message.instructions` list. If "jsonParsed" is requested but a parser cannot be found, the instruction falls back to regular JSON encoding (`accounts`, `data`, and `programIdIndex` fields). - (optional) `transactionDetails: ` - level of transaction detail to return, either "full", "signatures", or "none". If parameter not provided, the default detail level is "full". - (optional) `rewards: bool` - whether to populate the `rewards` array. If parameter not provided, the default includes rewards. - (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment); "processed" is not supported. If parameter not provided, the default is "finalized". @@ -413,6 +425,7 @@ The result field will be an object with the following fields: #### Example: Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' {"jsonrpc": "2.0","id":1,"method":"getBlock","params":[430, {"encoding": "json","transactionDetails":"full","rewards":false}]} @@ -420,6 +433,7 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json { "jsonrpc": "2.0", @@ -436,21 +450,9 @@ Result: "fee": 5000, "innerInstructions": [], "logMessages": [], - "postBalances": [ - 499998932500, - 26858640, - 1, - 1, - 1 - ], + "postBalances": [499998932500, 26858640, 1, 1, 1], "postTokenBalances": [], - "preBalances": [ - 499998937500, - 26858640, - 1, - 1, - 1 - ], + "preBalances": [499998937500, 26858640, 1, 1, 1], "preTokenBalances": [], "status": { "Ok": null @@ -472,12 +474,7 @@ Result: }, "instructions": [ { - "accounts": [ - 1, - 2, - 3, - 0 - ], + "accounts": [1, 2, 3, 0], "data": "37u9WtQpcm6ULa3WRQHmj49EPs4if7o9f1jSRVZpm2dvihR9C8jY4NqEwXUbLwx15HBSNcP1", "programIdIndex": 4 } @@ -496,7 +493,9 @@ Result: ``` #### Example: + Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' {"jsonrpc": "2.0","id":1,"method":"getBlock","params":[430, "base64"]} @@ -504,6 +503,7 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json { "jsonrpc": "2.0", @@ -521,21 +521,9 @@ Result: "fee": 5000, "innerInstructions": null, "logMessages": null, - "postBalances": [ - 499998932500, - 26858640, - 1, - 1, - 1 - ], + "postBalances": [499998932500, 26858640, 1, 1, 1], "postTokenBalances": [], - "preBalances": [ - 499998937500, - 26858640, - 1, - 1, - 1 - ], + "preBalances": [499998937500, 26858640, 1, 1, 1], "preTokenBalances": [], "status": { "Ok": null @@ -596,7 +584,6 @@ The JSON structure of token balances is defined as a list of objects in the foll - `uiAmount: ` - Token amount as a float, accounting for decimals. **DEPRECATED** - `uiAmountString: ` - Token amount as a string, accounting for decimals. - ### getBlockHeight Returns the current block height of the node @@ -612,6 +599,7 @@ Returns the current block height of the node #### Example: Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' {"jsonrpc":"2.0","id":1, "method":"getBlockHeight"} @@ -619,8 +607,9 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json -{"jsonrpc":"2.0","result":1233,"id":1} +{ "jsonrpc": "2.0", "result": 1233, "id": 1 } ``` ### getBlockProduction @@ -639,9 +628,10 @@ Returns recent block production information from the current or previous epoch. #### Results: The result will be an RpcResponse JSON object with `value` equal to: + - `` - `byIdentity: ` - a dictionary of validator identities, - as base-58 encoded strings. Value is a two element array containing the + as base-58 encoded strings. Value is a two element array containing the number of leader slots and the number of blocks produced. - `range: ` - Block production slot range - `firstSlot: ` - first slot of the block production information (inclusive) @@ -650,6 +640,7 @@ The result will be an RpcResponse JSON object with `value` equal to: #### Example: Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' {"jsonrpc":"2.0","id":1, "method":"getBlockProduction"} @@ -657,6 +648,7 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json { "jsonrpc": "2.0", @@ -666,14 +658,11 @@ Result: }, "value": { "byIdentity": { - "85iYT5RuzRTDgjyRa3cP8SYhM2j21fj7NhfJ3peu1DPr": [ - 9888, - 9886 - ] + "85iYT5RuzRTDgjyRa3cP8SYhM2j21fj7NhfJ3peu1DPr": [9888, 9886] }, "range": { "firstSlot": 0, - "lastSlot": 9887, + "lastSlot": 9887 } } }, @@ -684,6 +673,7 @@ Result: #### Example: Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' { @@ -704,6 +694,7 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json { "jsonrpc": "2.0", @@ -713,10 +704,7 @@ Result: }, "value": { "byIdentity": { - "85iYT5RuzRTDgjyRa3cP8SYhM2j21fj7NhfJ3peu1DPr": [ - 11, - 11 - ] + "85iYT5RuzRTDgjyRa3cP8SYhM2j21fj7NhfJ3peu1DPr": [11, 11] }, "range": { "firstSlot": 50, @@ -748,6 +736,7 @@ The result field will be a JSON object containing: #### Example: Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' {"jsonrpc":"2.0","id":1, "method":"getBlockCommitment","params":[5]} @@ -755,14 +744,18 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json { - "jsonrpc":"2.0", - "result":{ - "commitment":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,32], + "jsonrpc": "2.0", + "result": { + "commitment": [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 10, 32 + ], "totalStake": 42 }, - "id":1 + "id": 1 } ``` @@ -780,12 +773,12 @@ Returns a list of confirmed blocks between two slots 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. - +inclusive. Max range allowed is 500,000 slots. #### Example: Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' {"jsonrpc": "2.0","id":1,"method":"getBlocks","params":[5, 10]} @@ -793,8 +786,9 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json -{"jsonrpc":"2.0","result":[5,6,7,8,9,10],"id":1} +{ "jsonrpc": "2.0", "result": [5, 6, 7, 8, 9, 10], "id": 1 } ``` ### getBlocksWithLimit @@ -815,6 +809,7 @@ starting at `start_slot` for up to `limit` blocks, inclusive. #### Example: Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' {"jsonrpc": "2.0","id":1,"method":"getBlocksWithLimit","params":[5, 3]} @@ -822,8 +817,9 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json -{"jsonrpc":"2.0","result":[5,6,7],"id":1} +{ "jsonrpc": "2.0", "result": [5, 6, 7], "id": 1 } ``` ### getBlockTime @@ -841,12 +837,13 @@ in a set of recent blocks recorded on the ledger. #### Results: -* `` - estimated production time, as Unix timestamp (seconds since the Unix epoch) -* `` - timestamp is not available for this block +- `` - estimated production time, as Unix timestamp (seconds since the Unix epoch) +- `` - timestamp is not available for this block #### Example: Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' {"jsonrpc":"2.0","id":1, "method":"getBlockTime","params":[5]} @@ -854,8 +851,9 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json -{"jsonrpc":"2.0","result":1574721591,"id":1} +{ "jsonrpc": "2.0", "result": 1574721591, "id": 1 } ``` ### getClusterNodes @@ -881,6 +879,7 @@ The result field will be an array of JSON objects, each with the following sub f #### Example: Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' {"jsonrpc":"2.0", "id":1, "method":"getClusterNodes"} @@ -888,6 +887,7 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json { "jsonrpc": "2.0", @@ -926,6 +926,7 @@ The result field will be an object with the following fields: #### Example: Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' {"jsonrpc":"2.0","id":1, "method":"getEpochInfo"} @@ -933,6 +934,7 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json { "jsonrpc": "2.0", @@ -969,6 +971,7 @@ The result field will be an object with the following fields: #### Example: Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' {"jsonrpc":"2.0","id":1, "method":"getEpochSchedule"} @@ -976,6 +979,7 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json { "jsonrpc": "2.0", @@ -1009,6 +1013,7 @@ Get the fee the network will charge for a particular Message #### Example: Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' { @@ -1026,10 +1031,14 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: -```json -{"jsonrpc":"2.0","result":{"context":{"slot":5068},"value":5000},"id":1} -``` +```json +{ + "jsonrpc": "2.0", + "result": { "context": { "slot": 5068 }, "value": 5000 }, + "id": 1 +} +``` ### getFirstAvailableBlock @@ -1046,6 +1055,7 @@ None #### Example: Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' {"jsonrpc":"2.0","id":1, "method":"getFirstAvailableBlock"} @@ -1053,8 +1063,9 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json -{"jsonrpc":"2.0","result":250000,"id":1} +{ "jsonrpc": "2.0", "result": 250000, "id": 1 } ``` ### getGenesisHash @@ -1072,6 +1083,7 @@ None #### Example: Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' {"jsonrpc":"2.0","id":1, "method":"getGenesisHash"} @@ -1079,8 +1091,13 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json -{"jsonrpc":"2.0","result":"GH7ome3EiwEr7tu9JuTh2dpYWBJK3z69Xm1ZE3MEE6JC","id":1} +{ + "jsonrpc": "2.0", + "result": "GH7ome3EiwEr7tu9JuTh2dpYWBJK3z69Xm1ZE3MEE6JC", + "id": 1 +} ``` ### getHealth @@ -1090,7 +1107,7 @@ Returns the current health of the node. If one or more `--known-validator` arguments are provided to `solana-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 +an error is returned. "ok" is always returned if no known validators are provided. #### Parameters: @@ -1100,13 +1117,13 @@ None #### Results: If the node is healthy: "ok" -If the node is unhealthy, a JSON RPC error response is returned. The specifics +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: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' {"jsonrpc":"2.0","id":1, "method":"getHealth"} @@ -1114,11 +1131,13 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Healthy Result: + ```json -{"jsonrpc":"2.0","result": "ok","id":1} +{ "jsonrpc": "2.0", "result": "ok", "id": 1 } ``` Unhealthy Result (generic): + ```json { "jsonrpc": "2.0", @@ -1132,6 +1151,7 @@ Unhealthy Result (generic): ``` Unhealthy Result (if additional information is available) + ```json { "jsonrpc": "2.0", @@ -1166,10 +1186,10 @@ None - `full: ` - Highest full snapshot slot - `incremental: ` - Highest incremental snapshot slot _based on_ `full` - #### Example: Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' {"jsonrpc":"2.0","id":1,"method":"getHighestSnapshotSlot"} @@ -1177,13 +1197,19 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json -{"jsonrpc":"2.0","result":{"full":100,"incremental":110},"id":1} +{ "jsonrpc": "2.0", "result": { "full": 100, "incremental": 110 }, "id": 1 } ``` Result when the node has no snapshot: + ```json -{"jsonrpc":"2.0","error":{"code":-32008,"message":"No snapshot"},"id":1} +{ + "jsonrpc": "2.0", + "error": { "code": -32008, "message": "No snapshot" }, + "id": 1 +} ``` ### getIdentity @@ -1203,6 +1229,7 @@ The result field will be a JSON object with the following fields: #### Example: Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' {"jsonrpc":"2.0","id":1, "method":"getIdentity"} @@ -1210,8 +1237,13 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json -{"jsonrpc":"2.0","result":{"identity": "2r1F4iWqVcb8M1DbAjQuFpebkQHY9hcVU4WuW2DJBppN"},"id":1} +{ + "jsonrpc": "2.0", + "result": { "identity": "2r1F4iWqVcb8M1DbAjQuFpebkQHY9hcVU4WuW2DJBppN" }, + "id": 1 +} ``` ### getInflationGovernor @@ -1229,13 +1261,14 @@ The result field will be a JSON object with the following fields: - `initial: `, the initial inflation percentage from time 0 - `terminal: `, terminal inflation percentage - `taper: `, rate per year at which inflation is lowered. - Rate reduction is derived using the target slot time in genesis config + Rate reduction is derived using the target slot time in genesis config - `foundation: `, percentage of total inflation allocated to the foundation - `foundationTerm: `, duration of foundation pool inflation in years #### Example: Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' {"jsonrpc":"2.0","id":1, "method":"getInflationGovernor"} @@ -1243,6 +1276,7 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json { "jsonrpc": "2.0", @@ -1277,6 +1311,7 @@ The result field will be a JSON object with the following fields: #### Example: Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' {"jsonrpc":"2.0","id":1, "method":"getInflationRate"} @@ -1284,8 +1319,18 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json -{"jsonrpc":"2.0","result":{"epoch":100,"foundation":0.001,"total":0.149,"validator":0.148},"id":1} +{ + "jsonrpc": "2.0", + "result": { + "epoch": 100, + "foundation": 0.001, + "total": 0.149, + "validator": 0.148 + }, + "id": 1 +} ``` ### getInflationReward @@ -1293,10 +1338,12 @@ Result: Returns the inflation / staking reward for a list of addresses for an epoch #### Parameters: + - `` - An array of addresses to query, as base-58 encoded strings + * `` - (optional) Configuration object containing the following optional fields: - * (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment) - * (optional) `epoch: ` - An epoch for which the reward occurs. If omitted, the previous epoch will be used + - (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment) + - (optional) `epoch: ` - An epoch for which the reward occurs. If omitted, the previous epoch will be used #### Results @@ -1311,6 +1358,7 @@ The result field will be a JSON array with the following fields: #### Example Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' { @@ -1325,20 +1373,21 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Response: + ```json - { - "jsonrpc": "2.0", - "result": [ - { - "amount": 2500, - "effectiveSlot": 224, - "epoch": 2, - "postBalance": 499999442500 - }, - null - ], - "id": 1 - } +{ + "jsonrpc": "2.0", + "result": [ + { + "amount": 2500, + "effectiveSlot": 224, + "epoch": 2, + "postBalance": 499999442500 + }, + null + ], + "id": 1 +} ``` ### getLargestAccounts @@ -1362,6 +1411,7 @@ The result will be an RpcResponse JSON object with `value` equal to an array of: #### Example: Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' {"jsonrpc":"2.0","id":1, "method":"getLargestAccounts"} @@ -1369,6 +1419,7 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json { "jsonrpc": "2.0", @@ -1475,6 +1526,7 @@ Returns the latest blockhash #### Example: Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' { @@ -1491,19 +1543,20 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json { - "jsonrpc":"2.0", - "result":{ - "context":{ - "slot":2792 + "jsonrpc": "2.0", + "result": { + "context": { + "slot": 2792 }, - "value":{ - "blockhash":"EkSnNWid2cvwEVnVx9aBqawnmiCNiDgp3gUdkDPTKN1N", - "lastValidBlockHeight":3090 + "value": { + "blockhash": "EkSnNWid2cvwEVnVx9aBqawnmiCNiDgp3gUdkDPTKN1N", + "lastValidBlockHeight": 3090 } }, - "id":1 + "id": 1 } ``` @@ -1514,7 +1567,7 @@ Returns the leader schedule for an epoch #### Parameters: - `` - (optional) Fetch the leader schedule for the epoch that corresponds to the provided slot. - If unspecified, the leader schedule for the current epoch is fetched + If unspecified, the leader schedule for the current epoch is fetched - `` - (optional) Configuration object containing the following field: - (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment) - (optional) `identity: ` - Only return results for this validator identity (base-58 encoded) @@ -1529,6 +1582,7 @@ Returns the leader schedule for an epoch #### Example: Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' {"jsonrpc":"2.0","id":1, "method":"getLeaderSchedule"} @@ -1536,19 +1590,26 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json { - "jsonrpc":"2.0", - "result":{ - "4Qkev8aNZcqFNSRhQzwyLMFSsi94jHqE8WNVTJzTP99F":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63] + "jsonrpc": "2.0", + "result": { + "4Qkev8aNZcqFNSRhQzwyLMFSsi94jHqE8WNVTJzTP99F": [ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63 + ] }, - "id":1 + "id": 1 } ``` #### Example: Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' { @@ -1566,13 +1627,19 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json { - "jsonrpc":"2.0", - "result":{ - "4Qkev8aNZcqFNSRhQzwyLMFSsi94jHqE8WNVTJzTP99F":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63] + "jsonrpc": "2.0", + "result": { + "4Qkev8aNZcqFNSRhQzwyLMFSsi94jHqE8WNVTJzTP99F": [ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63 + ] }, - "id":1 + "id": 1 } ``` @@ -1587,6 +1654,7 @@ Get the max slot seen from retransmit stage. #### Example: Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' {"jsonrpc":"2.0","id":1, "method":"getMaxRetransmitSlot"} @@ -1594,8 +1662,9 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json -{"jsonrpc":"2.0","result":1234,"id":1} +{ "jsonrpc": "2.0", "result": 1234, "id": 1 } ``` ### getMaxShredInsertSlot @@ -1609,6 +1678,7 @@ Get the max slot seen from after shred insert. #### Example: Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' {"jsonrpc":"2.0","id":1, "method":"getMaxShredInsertSlot"} @@ -1616,8 +1686,9 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json -{"jsonrpc":"2.0","result":1234,"id":1} +{ "jsonrpc": "2.0", "result": 1234, "id": 1 } ``` ### getMinimumBalanceForRentExemption @@ -1636,6 +1707,7 @@ Returns minimum balance required to make account rent exempt. #### Example: Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' {"jsonrpc":"2.0", "id":1, "method":"getMinimumBalanceForRentExemption", "params":[50]} @@ -1643,8 +1715,9 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json -{"jsonrpc":"2.0","result":500,"id":1} +{ "jsonrpc": "2.0", "result": 500, "id": 1 } ``` ### getMultipleAccounts @@ -1656,14 +1729,13 @@ Returns the account information for a list of Pubkeys - `` - An array of Pubkeys to query, as base-58 encoded strings - `` - (optional) Configuration object containing the following optional fields: - (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment) - - `encoding: ` - encoding for Account data, either "base58" (*slow*), "base64", "base64+zstd", or "jsonParsed". + - `encoding: ` - encoding for Account data, either "base58" (_slow_), "base64", "base64+zstd", or "jsonParsed". "base58" is limited to Account data of less than 129 bytes. "base64" will return base64 encoded data for Account data of any size. "base64+zstd" compresses the Account data using [Zstandard](https://facebook.github.io/zstd/) and base64-encodes the result. "jsonParsed" encoding attempts to use program-specific state parsers to return more human-readable and explicit account state data. If "jsonParsed" is requested but a parser cannot be found, the field falls back to "base64" encoding, detectable when the `data` field is type ``. - (optional) `dataSlice: ` - limit the returned account data using the provided `offset: ` and `length: ` fields; only available for "base58", "base64" or "base64+zstd" encodings. - #### Results: The result will be an RpcResponse JSON object with `value` equal to: @@ -1681,6 +1753,7 @@ An array of: #### Example: Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' { @@ -1704,6 +1777,7 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json { "jsonrpc": "2.0", @@ -1713,20 +1787,14 @@ Result: }, "value": [ { - "data": [ - "AAAAAAEAAAACtzNsyJrW0g==", - "base64" - ], + "data": ["AAAAAAEAAAACtzNsyJrW0g==", "base64"], "executable": false, "lamports": 1000000000, "owner": "11111111111111111111111111111111", "rentEpoch": 2 }, { - "data": [ - "", - "base64" - ], + "data": ["", "base64"], "executable": false, "lamports": 5000000000, "owner": "11111111111111111111111111111111", @@ -1739,7 +1807,9 @@ Result: ``` #### Example: + Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' { @@ -1760,6 +1830,7 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json { "jsonrpc": "2.0", @@ -1779,10 +1850,7 @@ Result: "rentEpoch": 2 }, { - "data": [ - "", - "base58" - ], + "data": ["", "base58"], "executable": false, "lamports": 5000000000, "owner": "11111111111111111111111111111111", @@ -1803,7 +1871,7 @@ Returns all accounts owned by the provided program Pubkey - `` - Pubkey of program, as base-58 encoded string - `` - (optional) Configuration object containing the following optional fields: - (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment) - - `encoding: ` - encoding for Account data, either "base58" (*slow*), "base64", "base64+zstd", or "jsonParsed". + - `encoding: ` - encoding for Account data, either "base58" (_slow_), "base64", "base64+zstd", or "jsonParsed". "base58" is limited to Account data of less than 129 bytes. "base64" will return base64 encoded data for Account data of any size. "base64+zstd" compresses the Account data using [Zstandard](https://facebook.github.io/zstd/) and base64-encodes the result. @@ -1811,8 +1879,11 @@ Returns all accounts owned by the provided program Pubkey - (optional) `dataSlice: ` - limit the returned account data using the provided `offset: ` and `length: ` fields; only available for "base58", "base64" or "base64+zstd" encodings. - (optional) `filters: ` - filter results using various [filter objects](jsonrpc-api.md#filters); account must meet all filter criteria to be included in results - (optional) `withContext: bool` - wrap the result in an RpcResponse JSON object. + ##### Filters: + - `memcmp: ` - compares a provided series of bytes with program account data at a particular offset. Fields: + - `offset: ` - offset into program account data to start comparison - `bytes: ` - data to match, as base-58 encoded string and limited to less than 129 bytes @@ -1826,14 +1897,16 @@ The array will contain: - `pubkey: ` - the account Pubkey as base-58 encoded string - `account: ` - a JSON object, with the following sub fields: - - `lamports: `, number of lamports assigned to this account, as a u64 - - `owner: `, base-58 encoded Pubkey of the program this account has been assigned to - - `data: <[string,encoding]|object>`, data associated with the account, either as encoded binary data or JSON format `{: }`, depending on encoding parameter - - `executable: `, boolean indicating if the account contains a program \(and is strictly read-only\) - - `rentEpoch: `, the epoch at which this account will next owe rent, as u64 + - `lamports: `, number of lamports assigned to this account, as a u64 + - `owner: `, base-58 encoded Pubkey of the program this account has been assigned to + - `data: <[string,encoding]|object>`, data associated with the account, either as encoded binary data or JSON format `{: }`, depending on encoding parameter + - `executable: `, boolean indicating if the account contains a program \(and is strictly read-only\) + - `rentEpoch: `, the epoch at which this account will next owe rent, as u64 #### Example: + Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' {"jsonrpc":"2.0", "id":1, "method":"getProgramAccounts", "params":["4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T"]} @@ -1841,6 +1914,7 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json { "jsonrpc": "2.0", @@ -1861,7 +1935,9 @@ Result: ``` #### Example: + Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' { @@ -1889,6 +1965,7 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json { "jsonrpc": "2.0", @@ -1914,6 +1991,7 @@ Returns a list of recent performance samples, in reverse slot order. Performance include the number of transactions and slots that occur in a given time window. #### Parameters: + - `limit: ` - (optional) number of samples to return (maximum 720) #### Results: @@ -1929,6 +2007,7 @@ An array of: #### Example: Request: + ```bash // Request curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' @@ -1937,6 +2016,7 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json { "jsonrpc": "2.0", @@ -1972,32 +2052,36 @@ 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: -* `` - account address as base-58 encoded string -* `` - (optional) Configuration object containing the following fields: - * `limit: ` - (optional) maximum transaction signatures to return (between 1 and 1,000, default: 1,000). - * `before: ` - (optional) start searching backwards from this transaction signature. - If not provided the search starts from the top of the highest max confirmed block. - * `until: ` - (optional) search until this transaction signature, if found before limit reached. - * (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment); "processed" is not supported. If parameter not provided, the default is "finalized". + +- `` - account address as base-58 encoded string +- `` - (optional) Configuration object containing the following fields: + - `limit: ` - (optional) maximum transaction signatures to return (between 1 and 1,000, default: 1,000). + - `before: ` - (optional) start searching backwards from this transaction signature. + If not provided the search starts from the top of the highest max confirmed block. + - `until: ` - (optional) search until this transaction signature, if found before limit reached. + - (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment); "processed" is not supported. If parameter not provided, the default is "finalized". #### Results: + The result field will be an array of transaction signature information, ordered from newest to oldest transaction: -* `` - * `signature: ` - transaction signature as base-58 encoded string - * `slot: ` - The slot that contains the block with the transaction - * `err: ` - Error if transaction failed, null if transaction succeeded. [TransactionError definitions](https://github.com/solana-labs/solana/blob/c0c60386544ec9a9ec7119229f37386d9f070523/sdk/src/transaction/error.rs#L13) - * `memo: ` - Memo associated with the transaction, null if no memo is present - * `blockTime: ` - estimated production time, as Unix timestamp (seconds since the Unix epoch) of when transaction was processed. null if not available. + +- `` + - `signature: ` - transaction signature as base-58 encoded string + - `slot: ` - The slot that contains the block with the transaction + - `err: ` - Error if transaction failed, null if transaction succeeded. [TransactionError definitions](https://github.com/solana-labs/solana/blob/c0c60386544ec9a9ec7119229f37386d9f070523/sdk/src/transaction/error.rs#L13) + - `memo: ` - Memo associated with the transaction, null if no memo is present + - `blockTime: ` - estimated production time, as Unix timestamp (seconds since the Unix epoch) of when transaction was processed. null if not available. #### Example: + Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' { @@ -2015,6 +2099,7 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json { "jsonrpc": "2.0", @@ -2065,6 +2150,7 @@ An array of: #### Example: Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' { @@ -2082,6 +2168,7 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json { "jsonrpc": "2.0", @@ -2097,7 +2184,7 @@ Result: "status": { "Ok": null }, - "confirmationStatus": "confirmed", + "confirmationStatus": "confirmed" }, null ] @@ -2107,7 +2194,9 @@ Result: ``` #### Example: + Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' { @@ -2127,6 +2216,7 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json { "jsonrpc": "2.0", @@ -2142,7 +2232,7 @@ Result: "status": { "Ok": null }, - "confirmationStatus": "finalized", + "confirmationStatus": "finalized" }, null ] @@ -2166,6 +2256,7 @@ Returns the slot that has reached the [given or default commitment level](jsonrp #### Example: Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' {"jsonrpc":"2.0","id":1, "method":"getSlot"} @@ -2173,8 +2264,9 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json -{"jsonrpc":"2.0","result":1234,"id":1} +{ "jsonrpc": "2.0", "result": 1234, "id": 1 } ``` ### getSlotLeader @@ -2192,6 +2284,7 @@ Returns the current slot leader #### Example: Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' {"jsonrpc":"2.0","id":1, "method":"getSlotLeader"} @@ -2199,8 +2292,13 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json -{"jsonrpc":"2.0","result":"ENvAW7JScgYq6o4zKZwewtkzzJgDzuJAFxYasvmEQdpS","id":1} +{ + "jsonrpc": "2.0", + "result": "ENvAW7JScgYq6o4zKZwewtkzzJgDzuJAFxYasvmEQdpS", + "id": 1 +} ``` ### getSlotLeaders @@ -2221,6 +2319,7 @@ Returns the slot leaders for a given slot range If the current slot is #99, query the next 10 leaders with the following request: Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' {"jsonrpc":"2.0","id":1, "method":"getSlotLeaders", "params":[100, 10]} @@ -2256,21 +2355,23 @@ Returns epoch activation information for a stake account #### Parameters: -* `` - Pubkey of stake account to query, as base-58 encoded string -* `` - (optional) Configuration object containing the following optional fields: - * (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment) - * (optional) `epoch: ` - epoch for which to calculate activation details. If parameter not provided, defaults to current epoch. +- `` - Pubkey of stake account to query, as base-58 encoded string +- `` - (optional) Configuration object containing the following optional fields: + - (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment) + - (optional) `epoch: ` - epoch for which to calculate activation details. If parameter not provided, defaults to current epoch. #### Results: The result will be a JSON object with the following fields: -* `state: ` - stake active during the epoch -* `inactive: ` - stake inactive during the epoch +- `state: ` - stake active during the epoch +- `inactive: ` - stake inactive during the epoch #### Example: + Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' {"jsonrpc":"2.0","id":1, "method":"getStakeActivation", "params": ["CYRJWqiSjLitBAcRxPvWpgX3s5TvmN2SuRY3eEYypFvT"]} @@ -2278,12 +2379,19 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json -{"jsonrpc":"2.0","result":{"active":197717120,"inactive":0,"state":"active"},"id":1} +{ + "jsonrpc": "2.0", + "result": { "active": 197717120, "inactive": 0, "state": "active" }, + "id": 1 +} ``` #### Example: + Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' { @@ -2301,6 +2409,7 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json { "jsonrpc": "2.0", @@ -2335,6 +2444,7 @@ The result will be an RpcResponse JSON object with `value` equal to a JSON objec #### Example: Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' {"jsonrpc":"2.0", "id":1, "method":"getSupply"} @@ -2342,6 +2452,7 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json { "jsonrpc": "2.0", @@ -2389,6 +2500,7 @@ For more details on returned data: The #### Example: Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' {"jsonrpc":"2.0", "id":1, "method":"getTokenAccountBalance", "params": ["7fUAJdStEuGbc3sM84cKRL6yYaaSstyLSU4ve5oovLS7"]} @@ -2396,6 +2508,7 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json { "jsonrpc": "2.0", @@ -2407,7 +2520,7 @@ Result: "amount": "9864", "decimals": 2, "uiAmount": 98.64, - "uiAmountString": "98.64", + "uiAmountString": "98.64" }, "id": 1 } @@ -2422,11 +2535,11 @@ Returns all SPL Token accounts by approved Delegate. - `` - Pubkey of account delegate to query, as base-58 encoded string - `` - Either: - * `mint: ` - Pubkey of the specific token Mint to limit accounts to, as base-58 encoded string; or - * `programId: ` - Pubkey of the Token program ID that owns the accounts, as base-58 encoded string + - `mint: ` - Pubkey of the specific token Mint to limit accounts to, as base-58 encoded string; or + - `programId: ` - Pubkey of the Token program ID that owns the accounts, as base-58 encoded string - `` - (optional) Configuration object containing the following optional fields: - (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment) - - `encoding: ` - encoding for Account data, either "base58" (*slow*), "base64", "base64+zstd" or "jsonParsed". + - `encoding: ` - encoding for Account data, either "base58" (_slow_), "base64", "base64+zstd" or "jsonParsed". "jsonParsed" encoding attempts to use program-specific state parsers to return more human-readable and explicit account state data. If "jsonParsed" is requested but a valid mint cannot be found for a particular account, that account will be filtered out from results. - (optional) `dataSlice: ` - limit the returned account data using the provided `offset: ` and `length: ` fields; only available for "base58", "base64" or "base64+zstd" encodings. @@ -2436,11 +2549,11 @@ The result will be an RpcResponse JSON object with `value` equal to an array of - `pubkey: ` - the account Pubkey as base-58 encoded string - `account: ` - a JSON object, with the following sub fields: - - `lamports: `, number of lamports assigned to this account, as a u64 - - `owner: `, base-58 encoded Pubkey of the program this account has been assigned to - - `data: `, Token state data associated with the account, either as encoded binary data or in JSON format `{: }` - - `executable: `, boolean indicating if the account contains a program \(and is strictly read-only\) - - `rentEpoch: `, the epoch at which this account will next owe rent, as u64 + - `lamports: `, number of lamports assigned to this account, as a u64 + - `owner: `, base-58 encoded Pubkey of the program this account has been assigned to + - `data: `, Token state data associated with the account, either as encoded binary data or in JSON format `{: }` + - `executable: `, boolean indicating if the account contains a program \(and is strictly read-only\) + - `rentEpoch: `, the epoch at which this account will next owe rent, as u64 When the data is requested with the `jsonParsed` encoding a format similar to that of the [Token Balances Structure](jsonrpc-api.md#token-balances-structure) can be expected inside the structure, both for the `tokenAmount` and the `delegatedAmount`, with the latter being an optional object. @@ -2466,6 +2579,7 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json { "jsonrpc": "2.0", @@ -2509,7 +2623,6 @@ Result: }, "pubkey": "28YTZEwqtMHWrhWcvv34se7pjS7wctgqzCPB3gReCFKp" } - ] }, "id": 1 @@ -2524,11 +2637,11 @@ Returns all SPL Token accounts by token owner. - `` - Pubkey of account owner to query, as base-58 encoded string - `` - Either: - * `mint: ` - Pubkey of the specific token Mint to limit accounts to, as base-58 encoded string; or - * `programId: ` - Pubkey of the Token program ID that owns the accounts, as base-58 encoded string + - `mint: ` - Pubkey of the specific token Mint to limit accounts to, as base-58 encoded string; or + - `programId: ` - Pubkey of the Token program ID that owns the accounts, as base-58 encoded string - `` - (optional) Configuration object containing the following optional fields: - (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment) - - `encoding: ` - encoding for Account data, either "base58" (*slow*), "base64", "base64+zstd" or "jsonParsed". + - `encoding: ` - encoding for Account data, either "base58" (_slow_), "base64", "base64+zstd" or "jsonParsed". "jsonParsed" encoding attempts to use program-specific state parsers to return more human-readable and explicit account state data. If "jsonParsed" is requested but a valid mint cannot be found for a particular account, that account will be filtered out from results. - (optional) `dataSlice: ` - limit the returned account data using the provided `offset: ` and `length: ` fields; only available for "base58", "base64" or "base64+zstd" encodings. @@ -2538,11 +2651,11 @@ The result will be an RpcResponse JSON object with `value` equal to an array of - `pubkey: ` - the account Pubkey as base-58 encoded string - `account: ` - a JSON object, with the following sub fields: - - `lamports: `, number of lamports assigned to this account, as a u64 - - `owner: `, base-58 encoded Pubkey of the program this account has been assigned to - - `data: `, Token state data associated with the account, either as encoded binary data or in JSON format `{: }` - - `executable: `, boolean indicating if the account contains a program \(and is strictly read-only\) - - `rentEpoch: `, the epoch at which this account will next owe rent, as u64 + - `lamports: `, number of lamports assigned to this account, as a u64 + - `owner: `, base-58 encoded Pubkey of the program this account has been assigned to + - `data: `, Token state data associated with the account, either as encoded binary data or in JSON format `{: }` + - `executable: `, boolean indicating if the account contains a program \(and is strictly read-only\) + - `rentEpoch: `, the epoch at which this account will next owe rent, as u64 When the data is requested with the `jsonParsed` encoding a format similar to that of the [Token Balances Structure](jsonrpc-api.md#token-balances-structure) can be expected inside the structure, both for the `tokenAmount` and the `delegatedAmount`, with the latter being an optional object. @@ -2568,6 +2681,7 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json { "jsonrpc": "2.0", @@ -2579,36 +2693,36 @@ Result: { "account": { "data": { - "program": "spl-token", - "parsed": { - "accountType": "account", - "info": { - "tokenAmount": { - "amount": "1", - "decimals": 1, - "uiAmount": 0.1, - "uiAmountString": "0.1" - }, - "delegate": "4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T", - "delegatedAmount": { - "amount": "1", - "decimals": 1, - "uiAmount": 0.1, - "uiAmountString": "0.1" - }, - "state": "initialized", - "isNative": false, - "mint": "3wyAj7Rt1TWVPZVteFJPLa26JmLvdb1CAKEFZm3NY75E", - "owner": "4Qkev8aNZcqFNSRhQzwyLMFSsi94jHqE8WNVTJzTP99F" + "program": "spl-token", + "parsed": { + "accountType": "account", + "info": { + "tokenAmount": { + "amount": "1", + "decimals": 1, + "uiAmount": 0.1, + "uiAmountString": "0.1" }, - "type": "account" + "delegate": "4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T", + "delegatedAmount": { + "amount": "1", + "decimals": 1, + "uiAmount": 0.1, + "uiAmountString": "0.1" + }, + "state": "initialized", + "isNative": false, + "mint": "3wyAj7Rt1TWVPZVteFJPLa26JmLvdb1CAKEFZm3NY75E", + "owner": "4Qkev8aNZcqFNSRhQzwyLMFSsi94jHqE8WNVTJzTP99F" }, - "space": 165 + "type": "account" }, - "executable": false, - "lamports": 1726080, - "owner": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", - "rentEpoch": 4 + "space": 165 + }, + "executable": false, + "lamports": 1726080, + "owner": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", + "rentEpoch": 4 }, "pubkey": "C2gJg6tKpQs41PRS1nC8aw3ZKNZK3HQQZGVrDFDup5nx" } @@ -2646,6 +2760,7 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json { "jsonrpc": "2.0", @@ -2701,6 +2816,7 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json { "jsonrpc": "2.0", @@ -2712,7 +2828,7 @@ Result: "amount": "100000", "decimals": 2, "uiAmount": 1000, - "uiAmountString": "1000", + "uiAmountString": "1000" } }, "id": 1 @@ -2727,8 +2843,8 @@ Returns transaction details for a confirmed transaction - `` - transaction signature as base-58 encoded string - `` - (optional) Configuration object containing the following optional fields: - - (optional) `encoding: ` - encoding for each returned Transaction, either "json", "jsonParsed", "base58" (*slow*), "base64". If parameter not provided, the default encoding is "json". - "jsonParsed" encoding attempts to use program-specific instruction parsers to return more human-readable and explicit data in the `transaction.message.instructions` list. If "jsonParsed" is requested but a parser cannot be found, the instruction falls back to regular JSON encoding (`accounts`, `data`, and `programIdIndex` fields). + - (optional) `encoding: ` - encoding for each returned Transaction, either "json", "jsonParsed", "base58" (_slow_), "base64". If parameter not provided, the default encoding is "json". + "jsonParsed" encoding attempts to use program-specific instruction parsers to return more human-readable and explicit data in the `transaction.message.instructions` list. If "jsonParsed" is requested but a parser cannot be found, the instruction falls back to regular JSON encoding (`accounts`, `data`, and `programIdIndex` fields). - (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment); "processed" is not supported. If parameter not provided, the default is "finalized". #### Results: @@ -2744,7 +2860,7 @@ Returns transaction details for a confirmed transaction - `preBalances: ` - array of u64 account balances from before the transaction was processed - `postBalances: ` - array of u64 account balances after the transaction was processed - `innerInstructions: ` - List of [inner instructions](#inner-instructions-structure) or `null` if inner instruction recording was not enabled during this transaction - - `preTokenBalances: ` - List of [token balances](#token-balances-structure) from before the transaction was processed or omitted if token balance recording was not yet enabled during this transaction + - `preTokenBalances: ` - List of [token balances](#token-balances-structure) from before the transaction was processed or omitted if token balance recording was not yet enabled during this transaction - `postTokenBalances: ` - List of [token balances](#token-balances-structure) from after the transaction was processed or omitted if token balance recording was not yet enabled during this transaction - `logMessages: ` - array of string log messages or `null` if log message recording was not enabled during this transaction - DEPRECATED: `status: ` - Transaction status @@ -2757,9 +2873,10 @@ Returns transaction details for a confirmed transaction - `rewardType: ` - type of reward: currently only "rent", other types may be added in the future - `commission: ` - vote account commission when the reward was credited, only present for voting and staking rewards - #### Example: + Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' { @@ -2775,6 +2892,7 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json { "jsonrpc": "2.0", @@ -2783,21 +2901,9 @@ Result: "err": null, "fee": 5000, "innerInstructions": [], - "postBalances": [ - 499998932500, - 26858640, - 1, - 1, - 1 - ], + "postBalances": [499998932500, 26858640, 1, 1, 1], "postTokenBalances": [], - "preBalances": [ - 499998937500, - 26858640, - 1, - 1, - 1 - ], + "preBalances": [499998937500, 26858640, 1, 1, 1], "preTokenBalances": [], "status": { "Ok": null @@ -2820,12 +2926,7 @@ Result: }, "instructions": [ { - "accounts": [ - 1, - 2, - 3, - 0 - ], + "accounts": [1, 2, 3, 0], "data": "37u9WtQpcm6ULa3WRQHmj49EPs4if7o9f1jSRVZpm2dvihR9C8jY4NqEwXUbLwx15HBSNcP1", "programIdIndex": 4 } @@ -2843,7 +2944,9 @@ Result: ``` #### Example: + Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' { @@ -2859,6 +2962,7 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json { "jsonrpc": "2.0", @@ -2867,21 +2971,9 @@ Result: "err": null, "fee": 5000, "innerInstructions": [], - "postBalances": [ - 499998932500, - 26858640, - 1, - 1, - 1 - ], + "postBalances": [499998932500, 26858640, 1, 1, 1], "postTokenBalances": [], - "preBalances": [ - 499998937500, - 26858640, - 1, - 1, - 1 - ], + "preBalances": [499998937500, 26858640, 1, 1, 1], "preTokenBalances": [], "status": { "Ok": null @@ -2919,8 +3011,9 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json -{"jsonrpc":"2.0","result":268,"id":1} +{ "jsonrpc": "2.0", "result": 268, "id": 1 } ``` ### getVersion @@ -2941,6 +3034,7 @@ The result field will be a JSON object with the following fields: #### Example: Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' {"jsonrpc":"2.0","id":1, "method":"getVersion"} @@ -2948,8 +3042,9 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json -{"jsonrpc":"2.0","result":{"solana-core": "1.10.0"},"id":1} +{ "jsonrpc": "2.0", "result": { "solana-core": "1.10.0" }, "id": 1 } ``` ### getVoteAccounts @@ -2978,7 +3073,9 @@ each containing an array of JSON objects with the following sub fields: - `epochCredits: ` - History of how many credits earned by the end of each epoch, as an array of arrays containing: `[epoch, credits, previousCredits]` #### Example: + Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' {"jsonrpc":"2.0","id":1, "method":"getVoteAccounts"} @@ -2986,6 +3083,7 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json { "jsonrpc": "2.0", @@ -2995,8 +3093,8 @@ Result: "commission": 0, "epochVoteAccount": true, "epochCredits": [ - [ 1, 64, 0 ], - [ 2, 192, 64 ] + [1, 64, 0], + [2, 192, 64] ], "nodePubkey": "B97CCUW3AEZFGy6uUg6zUdnNYvnVq5VG8PUtb2HayTDD", "lastVote": 147, @@ -3023,6 +3121,7 @@ Result: #### Example: Restrict results to a single validator vote account Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' { @@ -3039,6 +3138,7 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json { "jsonrpc": "2.0", @@ -3048,8 +3148,8 @@ Result: "commission": 0, "epochVoteAccount": true, "epochCredits": [ - [ 1, 64, 0 ], - [ 2, 192, 64 ] + [1, 64, 0], + [2, 192, 64] ], "nodePubkey": "B97CCUW3AEZFGy6uUg6zUdnNYvnVq5VG8PUtb2HayTDD", "lastVote": 147, @@ -3082,6 +3182,7 @@ Returns whether a blockhash is still valid or not #### Example: Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' { @@ -3097,15 +3198,17 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json { - "jsonrpc":"2.0", - "result":{ - "context":{ - "slot":2483 + "jsonrpc": "2.0", + "result": { + "context": { + "slot": 2483 }, - "value":false - },"id":1 + "value": false + }, + "id": 1 } ``` @@ -3132,8 +3235,9 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json -{"jsonrpc":"2.0","result":1234,"id":1} +{ "jsonrpc": "2.0", "result": 1234, "id": 1 } ``` ### requestAirdrop @@ -3160,8 +3264,13 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json -{"jsonrpc":"2.0","result":"5VERv8NMvzbJMEkV8xnrLkEaWRtSz9CosKDYjCJjBRnbJLgp8uirBgmQpjKhoR4tjF3ZpRzrFmBV6UjKdiSZkQUW","id":1} +{ + "jsonrpc": "2.0", + "result": "5VERv8NMvzbJMEkV8xnrLkEaWRtSz9CosKDYjCJjBRnbJLgp8uirBgmQpjKhoR4tjF3ZpRzrFmBV6UjKdiSZkQUW", + "id": 1 +} ``` ### sendTransaction @@ -3201,9 +3310,9 @@ submission. - `` - (optional) Configuration object containing the following field: - `skipPreflight: ` - if true, skip the preflight transaction checks (default: false) - `preflightCommitment: ` - (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment) level to use for preflight (default: `"finalized"`). - - `encoding: ` - (optional) Encoding used for the transaction data. Either `"base58"` (*slow*, **DEPRECATED**), or `"base64"`. (default: `"base58"`). + - `encoding: ` - (optional) Encoding used for the transaction data. Either `"base58"` (_slow_, **DEPRECATED**), or `"base64"`. (default: `"base58"`). - `maxRetries: ` - (optional) Maximum number of times for the RPC node to retry sending the transaction to the leader. - If this parameter not provided, the RPC node will retry the transaction until it is finalized or until the blockhash expires. + If this parameter not provided, the RPC node will retry the transaction until it is finalized or until the blockhash expires. #### Results: @@ -3226,8 +3335,13 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json -{"jsonrpc":"2.0","result":"2id3YC2jK9G5Wo2phDx4gJVAew8DcY5NAojnVuao8rkxwPYPe8cSwE5GzhEgJA2y8fVjDEo6iR6ykBvDxrTQrtpb","id":1} +{ + "jsonrpc": "2.0", + "result": "2id3YC2jK9G5Wo2phDx4gJVAew8DcY5NAojnVuao8rkxwPYPe8cSwE5GzhEgJA2y8fVjDEo6iR6ykBvDxrTQrtpb", + "id": 1 +} ``` ### simulateTransaction @@ -3240,13 +3354,13 @@ Simulate sending a transaction - `` - (optional) Configuration object containing the following fields: - `sigVerify: ` - if true the transaction signatures will be verified (default: false, conflicts with `replaceRecentBlockhash`) - `commitment: ` - (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment) level to simulate the transaction at (default: `"finalized"`). - - `encoding: ` - (optional) Encoding used for the transaction data. Either `"base58"` (*slow*, **DEPRECATED**), or `"base64"`. (default: `"base58"`). + - `encoding: ` - (optional) Encoding used for the transaction data. Either `"base58"` (_slow_, **DEPRECATED**), or `"base64"`. (default: `"base58"`). - `replaceRecentBlockhash: ` - (optional) if true the transaction recent blockhash will be replaced with the most recent blockhash. - (default: false, conflicts with `sigVerify`) + (default: false, conflicts with `sigVerify`) - `accounts: ` - (optional) Accounts configuration object containing the following fields: - - `encoding: ` - (optional) encoding for returned Account data, either "base64" (default), "base64+zstd" or "jsonParsed". - "jsonParsed" encoding attempts to use program-specific state parsers to return more human-readable and explicit account state data. If "jsonParsed" is requested but a parser cannot be found, the field falls back to binary encoding, detectable when the `data` field is type ``. - - `addresses: ` - An array of accounts to return, as base-58 encoded strings + - `encoding: ` - (optional) encoding for returned Account data, either "base64" (default), "base64+zstd" or "jsonParsed". + "jsonParsed" encoding attempts to use program-specific state parsers to return more human-readable and explicit account state data. If "jsonParsed" is requested but a parser cannot be found, the field falls back to binary encoding, detectable when the `data` field is type ``. + - `addresses: ` - An array of accounts to return, as base-58 encoded strings #### Results: @@ -3281,6 +3395,7 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json { "jsonrpc": "2.0", @@ -3317,7 +3432,7 @@ Subscribe to an account to receive notifications when the lamports or data for a - `` - account Pubkey, as base-58 encoded string - `` - (optional) Configuration object containing the following optional fields: - `` - (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment) - - `encoding: ` - encoding for Account data, either "base58" (*slow*), "base64", "base64+zstd" or "jsonParsed". + - `encoding: ` - encoding for Account data, either "base58" (_slow_), "base64", "base64+zstd" or "jsonParsed". "jsonParsed" encoding attempts to use program-specific state parsers to return more human-readable and explicit account state data. If "jsonParsed" is requested but a parser cannot be found, the field falls back to binary encoding, detectable when the `data` field is type ``. #### Results: @@ -3327,6 +3442,7 @@ Subscribe to an account to receive notifications when the lamports or data for a #### Example: Request: + ```json { "jsonrpc": "2.0", @@ -3354,8 +3470,9 @@ Request: ``` Result: + ```json -{"jsonrpc": "2.0","result": 23784,"id": 1} +{ "jsonrpc": "2.0", "result": 23784, "id": 1 } ``` #### Notification Format: @@ -3363,6 +3480,7 @@ Result: The notification format is the same as seen in the [getAccountInfo](jsonrpc-api.md#getAccountInfo) RPC HTTP method. Base58 encoding: + ```json { "jsonrpc": "2.0", @@ -3373,7 +3491,10 @@ Base58 encoding: "slot": 5199307 }, "value": { - "data": ["11116bv5nS2h3y12kD1yUKeMZvGcKLSjQgX6BeV7u1FrjeJcKfsHPXHRDEHrBesJhZyqnnq9qJeUuF7WHxiuLuL5twc38w2TXNLxnDbjmuR", "base58"], + "data": [ + "11116bv5nS2h3y12kD1yUKeMZvGcKLSjQgX6BeV7u1FrjeJcKfsHPXHRDEHrBesJhZyqnnq9qJeUuF7WHxiuLuL5twc38w2TXNLxnDbjmuR", + "base58" + ], "executable": false, "lamports": 33594, "owner": "11111111111111111111111111111111", @@ -3386,6 +3507,7 @@ Base58 encoding: ``` Parsed-JSON encoding: + ```json { "jsonrpc": "2.0", @@ -3397,17 +3519,17 @@ Parsed-JSON encoding: }, "value": { "data": { - "program": "nonce", - "parsed": { - "type": "initialized", - "info": { - "authority": "Bbqg1M4YVVfbhEzwA9SpC9FhsaG83YMTYoR4a8oTDLX", - "blockhash": "LUaQTmM7WbMRiATdMMHaRGakPtCkc2GHtH57STKXs6k", - "feeCalculator": { - "lamportsPerSignature": 5000 - } + "program": "nonce", + "parsed": { + "type": "initialized", + "info": { + "authority": "Bbqg1M4YVVfbhEzwA9SpC9FhsaG83YMTYoR4a8oTDLX", + "blockhash": "LUaQTmM7WbMRiATdMMHaRGakPtCkc2GHtH57STKXs6k", + "feeCalculator": { + "lamportsPerSignature": 5000 } - } + } + } }, "executable": false, "lamports": 33594, @@ -3435,14 +3557,15 @@ Unsubscribe from account change notifications #### Example: Request: -```json -{"jsonrpc":"2.0", "id":1, "method":"accountUnsubscribe", "params":[0]} +```json +{ "jsonrpc": "2.0", "id": 1, "method": "accountUnsubscribe", "params": [0] } ``` Result: + ```json -{"jsonrpc": "2.0","result": true,"id": 1} +{ "jsonrpc": "2.0", "result": true, "id": 1 } ``` ### blockSubscribe - Unstable, disabled by default @@ -3460,7 +3583,7 @@ Subscribe to receive notification anytime a new block is Confirmed or Finalized. - `{ "mentionsAccountOrProgram": }` - return only transactions that mention the provided public key (as base-58 encoded string). If no mentions in a given block, then no notification will be sent. - `` - (optional) Configuration object containing the following optional fields: - (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment) - - (optional) `encoding: ` - encoding for Account data, either "base58" (*slow*), "base64", "base64+zstd" or "jsonParsed". + - (optional) `encoding: ` - encoding for Account data, either "base58" (_slow_), "base64", "base64+zstd" or "jsonParsed". "jsonParsed" encoding attempts to use program-specific state parsers to return more human-readable and explicit account state data. If "jsonParsed" is requested but a parser cannot be found, the field falls back to base64 encoding, detectable when the `data` field is type ``. Default is "base64". - (optional) `transactionDetails: ` - level of transaction detail to return, either "full", "signatures", or "none". If parameter not provided, the default detail level is "full". - (optional) `showRewards: bool` - whether to populate the `rewards` array. If parameter not provided, the default includes rewards. @@ -3472,16 +3595,20 @@ Subscribe to receive notification anytime a new block is Confirmed or Finalized. #### Example: Request: + ```json -{"jsonrpc": "2.0", "id": "1", "method": "blockSubscribe", "params": ["all"]} +{ "jsonrpc": "2.0", "id": "1", "method": "blockSubscribe", "params": ["all"] } ``` + ```json { "jsonrpc": "2.0", "id": "1", "method": "blockSubscribe", "params": [ - {"mentionsAccountOrProgram": "LieKvPRE8XeX3Y2xVNHjKlpAScD12lYySBVQ4HqoJ5op"}, + { + "mentionsAccountOrProgram": "LieKvPRE8XeX3Y2xVNHjKlpAScD12lYySBVQ4HqoJ5op" + }, { "commitment": "confirmed", "encoding": "base64", @@ -3493,8 +3620,9 @@ Request: ``` Result: + ```json -{"jsonrpc": "2.0","result": 0,"id": 1} +{ "jsonrpc": "2.0", "result": 0, "id": 1 } ``` #### Notification Format: @@ -3502,6 +3630,7 @@ Result: The notification will be an object with the following fields: -`slot: ` - The corresponding slot. + - `err: ` - Error if something went wrong publishing the notification otherwise null. - `block: ` - A block object as seen in the [getBlock](jsonrpc-api.md#getblock) RPC HTTP method. @@ -3533,30 +3662,12 @@ The notification will be an object with the following fields: }, "fee": 5000, "preBalances": [ - 1758510880, - 2067120, - 1566000, - 1461600, - 2039280, - 2039280, - 1900080, - 1865280, - 0, - 3680844220, - 2039280 + 1758510880, 2067120, 1566000, 1461600, 2039280, 2039280, + 1900080, 1865280, 0, 3680844220, 2039280 ], "postBalances": [ - 1758505880, - 2067120, - 1566000, - 1461600, - 2039280, - 2039280, - 1900080, - 1865280, - 0, - 3680844220, - 2039280 + 1758505880, 2067120, 1566000, 1461600, 2039280, 2039280, + 1900080, 1865280, 0, 3680844220, 2039280 ], "innerInstructions": [ { @@ -3564,44 +3675,22 @@ The notification will be an object with the following fields: "instructions": [ { "programIdIndex": 13, - "accounts": [ - 1, - 15, - 3, - 4, - 2, - 14 - ], + "accounts": [1, 15, 3, 4, 2, 14], "data": "21TeLgZXNbtHXVBzCaiRmH" }, { "programIdIndex": 14, - "accounts": [ - 3, - 4, - 1 - ], + "accounts": [3, 4, 1], "data": "6qfC8ic7Aq99" }, { "programIdIndex": 13, - "accounts": [ - 1, - 15, - 3, - 5, - 2, - 14 - ], + "accounts": [1, 15, 3, 5, 2, 14], "data": "21TeLgZXNbsn4QEpaSEr3q" }, { "programIdIndex": 14, - "accounts": [ - 3, - 5, - 1 - ], + "accounts": [3, 5, 1], "data": "6LC7BYyxhFRh" } ] @@ -3611,33 +3700,17 @@ The notification will be an object with the following fields: "instructions": [ { "programIdIndex": 14, - "accounts": [ - 4, - 3, - 0 - ], + "accounts": [4, 3, 0], "data": "7aUiLHFjSVdZ" }, { "programIdIndex": 19, - "accounts": [ - 17, - 18, - 16, - 9, - 11, - 12, - 14 - ], + "accounts": [17, 18, 16, 9, 11, 12, 14], "data": "8kvZyjATKQWYxaKR1qD53V" }, { "programIdIndex": 14, - "accounts": [ - 9, - 11, - 18 - ], + "accounts": [9, 11, 18], "data": "6qfC8ic7Aq99" } ] @@ -3769,13 +3842,15 @@ Unsubscribe from block notifications #### Example: Request: + ```json -{"jsonrpc":"2.0", "id":1, "method":"blockUnsubscribe", "params":[0]} +{ "jsonrpc": "2.0", "id": 1, "method": "blockUnsubscribe", "params": [0] } ``` Response: + ```json -{"jsonrpc": "2.0","result": true,"id": 1} +{ "jsonrpc": "2.0", "result": true, "id": 1 } ``` ### logsSubscribe @@ -3798,6 +3873,7 @@ Subscribe to transaction logging #### Example: Request: + ```json { "jsonrpc": "2.0", @@ -3821,8 +3897,9 @@ Request: ``` Result: + ```json -{"jsonrpc": "2.0","result": 24040,"id": 1} +{ "jsonrpc": "2.0", "result": 24040, "id": 1 } ``` #### Notification Format: @@ -3872,13 +3949,15 @@ Unsubscribe from transaction logging #### Example: Request: + ```json -{"jsonrpc":"2.0", "id":1, "method":"logsUnsubscribe", "params":[0]} +{ "jsonrpc": "2.0", "id": 1, "method": "logsUnsubscribe", "params": [0] } ``` Result: + ```json -{"jsonrpc": "2.0","result": true,"id": 1} +{ "jsonrpc": "2.0", "result": true, "id": 1 } ``` ### programSubscribe @@ -3890,7 +3969,7 @@ Subscribe to a program to receive notifications when the lamports or data for a - `` - program_id Pubkey, as base-58 encoded string - `` - (optional) Configuration object containing the following optional fields: - (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment) - - `encoding: ` - encoding for Account data, either "base58" (*slow*), "base64", "base64+zstd" or "jsonParsed". + - `encoding: ` - encoding for Account data, either "base58" (_slow_), "base64", "base64+zstd" or "jsonParsed". "jsonParsed" encoding attempts to use program-specific state parsers to return more human-readable and explicit account state data. If "jsonParsed" is requested but a parser cannot be found, the field falls back to base64 encoding, detectable when the `data` field is type ``. - (optional) `filters: ` - filter results using various [filter objects](jsonrpc-api.md#filters); account must meet all filter criteria to be included in results @@ -3901,6 +3980,7 @@ Subscribe to a program to receive notifications when the lamports or data for a #### Example: Request: + ```json { "jsonrpc": "2.0", @@ -3944,8 +4024,9 @@ Request: ``` Result: + ```json -{"jsonrpc": "2.0","result": 24040,"id": 1} +{ "jsonrpc": "2.0", "result": 24040, "id": 1 } ``` #### Notification Format: @@ -3953,6 +4034,7 @@ Result: The notification format is a single program account object as seen in the [getProgramAccounts](jsonrpc-api.md#getProgramAccounts) RPC HTTP method. Base58 encoding: + ```json { "jsonrpc": "2.0", @@ -3965,12 +4047,15 @@ Base58 encoding: "value": { "pubkey": "H4vnBqifaSACnKa7acsxstsY1iV1bvJNxsCY7enrd1hq", "account": { - "data": ["11116bv5nS2h3y12kD1yUKeMZvGcKLSjQgX6BeV7u1FrjeJcKfsHPXHRDEHrBesJhZyqnnq9qJeUuF7WHxiuLuL5twc38w2TXNLxnDbjmuR", "base58"], + "data": [ + "11116bv5nS2h3y12kD1yUKeMZvGcKLSjQgX6BeV7u1FrjeJcKfsHPXHRDEHrBesJhZyqnnq9qJeUuF7WHxiuLuL5twc38w2TXNLxnDbjmuR", + "base58" + ], "executable": false, "lamports": 33594, "owner": "11111111111111111111111111111111", "rentEpoch": 636 - }, + } } }, "subscription": 24040 @@ -3979,6 +4064,7 @@ Base58 encoding: ``` Parsed-JSON encoding: + ```json { "jsonrpc": "2.0", @@ -3992,23 +4078,23 @@ Parsed-JSON encoding: "pubkey": "H4vnBqifaSACnKa7acsxstsY1iV1bvJNxsCY7enrd1hq", "account": { "data": { - "program": "nonce", - "parsed": { - "type": "initialized", - "info": { - "authority": "Bbqg1M4YVVfbhEzwA9SpC9FhsaG83YMTYoR4a8oTDLX", - "blockhash": "LUaQTmM7WbMRiATdMMHaRGakPtCkc2GHtH57STKXs6k", - "feeCalculator": { - "lamportsPerSignature": 5000 - } + "program": "nonce", + "parsed": { + "type": "initialized", + "info": { + "authority": "Bbqg1M4YVVfbhEzwA9SpC9FhsaG83YMTYoR4a8oTDLX", + "blockhash": "LUaQTmM7WbMRiATdMMHaRGakPtCkc2GHtH57STKXs6k", + "feeCalculator": { + "lamportsPerSignature": 5000 } - } + } + } }, "executable": false, "lamports": 33594, "owner": "11111111111111111111111111111111", "rentEpoch": 636 - }, + } } }, "subscription": 24040 @@ -4031,14 +4117,15 @@ Unsubscribe from program-owned account change notifications #### Example: Request: -```json -{"jsonrpc":"2.0", "id":1, "method":"programUnsubscribe", "params":[0]} +```json +{ "jsonrpc": "2.0", "id": 1, "method": "programUnsubscribe", "params": [0] } ``` Result: + ```json -{"jsonrpc": "2.0","result": true,"id": 1} +{ "jsonrpc": "2.0", "result": true, "id": 1 } ``` ### signatureSubscribe @@ -4057,6 +4144,7 @@ Subscribe to a transaction signature to receive notification when the transactio #### Example: Request: + ```json { "jsonrpc": "2.0", @@ -4081,16 +4169,19 @@ Request: ``` Result: + ```json -{"jsonrpc": "2.0","result": 0,"id": 1} +{ "jsonrpc": "2.0", "result": 0, "id": 1 } ``` #### Notification Format: The notification will be an RpcResponse JSON object with value containing an object with: + - `err: ` - Error if transaction failed, null if transaction succeeded. [TransactionError definitions](https://github.com/solana-labs/solana/blob/c0c60386544ec9a9ec7119229f37386d9f070523/sdk/src/transaction/error.rs#L13) Example: + ```json { "jsonrpc": "2.0", @@ -4124,14 +4215,15 @@ Unsubscribe from signature confirmation notification #### Example: Request: -```json -{"jsonrpc":"2.0", "id":1, "method":"signatureUnsubscribe", "params":[0]} +```json +{ "jsonrpc": "2.0", "id": 1, "method": "signatureUnsubscribe", "params": [0] } ``` Result: + ```json -{"jsonrpc": "2.0","result": true,"id": 1} +{ "jsonrpc": "2.0", "result": true, "id": 1 } ``` ### slotSubscribe @@ -4149,14 +4241,15 @@ None #### Example: Request: -```json -{"jsonrpc":"2.0", "id":1, "method":"slotSubscribe"} +```json +{ "jsonrpc": "2.0", "id": 1, "method": "slotSubscribe" } ``` Result: + ```json -{"jsonrpc": "2.0","result": 0,"id": 1} +{ "jsonrpc": "2.0", "result": 0, "id": 1 } ``` #### Notification Format: @@ -4168,6 +4261,7 @@ The notification will be an object with the following fields: - `slot: ` - The newly set slot value Example: + ```json { "jsonrpc": "2.0", @@ -4198,14 +4292,15 @@ Unsubscribe from slot notifications #### Example: Request: -```json -{"jsonrpc":"2.0", "id":1, "method":"slotUnsubscribe", "params":[0]} +```json +{ "jsonrpc": "2.0", "id": 1, "method": "slotUnsubscribe", "params": [0] } ``` Result: + ```json -{"jsonrpc": "2.0","result": true,"id": 1} +{ "jsonrpc": "2.0", "result": true, "id": 1 } ``` ### slotsUpdatesSubscribe - Unstable @@ -4227,14 +4322,15 @@ None #### Example: Request: -```json -{"jsonrpc":"2.0", "id":1, "method":"slotsUpdatesSubscribe"} +```json +{ "jsonrpc": "2.0", "id": 1, "method": "slotsUpdatesSubscribe" } ``` Result: + ```json -{"jsonrpc": "2.0","result": 0,"id": 1} +{ "jsonrpc": "2.0", "result": 0, "id": 1 } ``` #### Notification Format: @@ -4284,14 +4380,20 @@ Unsubscribe from slot-update notifications #### Example: Request: -```json -{"jsonrpc":"2.0", "id":1, "method":"slotsUpdatesUnsubscribe", "params":[0]} +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "slotsUpdatesUnsubscribe", + "params": [0] +} ``` Result: + ```json -{"jsonrpc": "2.0","result": true,"id": 1} +{ "jsonrpc": "2.0", "result": true, "id": 1 } ``` ### rootSubscribe @@ -4309,14 +4411,15 @@ None #### Example: Request: -```json -{"jsonrpc":"2.0", "id":1, "method":"rootSubscribe"} +```json +{ "jsonrpc": "2.0", "id": 1, "method": "rootSubscribe" } ``` Result: + ```json -{"jsonrpc": "2.0","result": 0,"id": 1} +{ "jsonrpc": "2.0", "result": 0, "id": 1 } ``` #### Notification Format: @@ -4349,20 +4452,21 @@ Unsubscribe from root notifications #### Example: Request: -```json -{"jsonrpc":"2.0", "id":1, "method":"rootUnsubscribe", "params":[0]} +```json +{ "jsonrpc": "2.0", "id": 1, "method": "rootUnsubscribe", "params": [0] } ``` Result: + ```json -{"jsonrpc": "2.0","result": true,"id": 1} +{ "jsonrpc": "2.0", "result": true, "id": 1 } ``` ### voteSubscribe - Unstable, disabled by default **This subscription is unstable and only available if the validator was started -with the `--rpc-pubsub-enable-vote-subscription` flag. The format of this +with the `--rpc-pubsub-enable-vote-subscription` flag. The format of this subscription may change in the future** Subscribe to receive notification anytime a new vote is observed in gossip. @@ -4380,19 +4484,21 @@ None #### Example: Request: -```json -{"jsonrpc":"2.0", "id":1, "method":"voteSubscribe"} +```json +{ "jsonrpc": "2.0", "id": 1, "method": "voteSubscribe" } ``` Result: + ```json -{"jsonrpc": "2.0","result": 0,"id": 1} +{ "jsonrpc": "2.0", "result": 0, "id": 1 } ``` #### Notification Format: The notification will be an object with the following fields: + - `hash: ` - The vote hash - `slots: ` - The slots covered by the vote, as an array of u64 integers - `timestamp: ` - The timestamp of the vote @@ -4427,13 +4533,15 @@ Unsubscribe from vote notifications #### Example: Request: + ```json -{"jsonrpc":"2.0", "id":1, "method":"voteUnsubscribe", "params":[0]} +{ "jsonrpc": "2.0", "id": 1, "method": "voteUnsubscribe", "params": [0] } ``` Response: + ```json -{"jsonrpc": "2.0","result": true,"id": 1} +{ "jsonrpc": "2.0", "result": true, "id": 1 } ``` ## JSON RPC API Deprecated Methods @@ -4449,8 +4557,8 @@ Returns identity and transaction information about a confirmed block in the ledg - `` - slot, as u64 integer - `` - (optional) Configuration object containing the following optional fields: - - (optional) `encoding: ` - encoding for each returned Transaction, either "json", "jsonParsed", "base58" (*slow*), "base64". If parameter not provided, the default encoding is "json". - "jsonParsed" encoding attempts to use program-specific instruction parsers to return more human-readable and explicit data in the `transaction.message.instructions` list. If "jsonParsed" is requested but a parser cannot be found, the instruction falls back to regular JSON encoding (`accounts`, `data`, and `programIdIndex` fields). + - (optional) `encoding: ` - encoding for each returned Transaction, either "json", "jsonParsed", "base58" (_slow_), "base64". If parameter not provided, the default encoding is "json". + "jsonParsed" encoding attempts to use program-specific instruction parsers to return more human-readable and explicit data in the `transaction.message.instructions` list. If "jsonParsed" is requested but a parser cannot be found, the instruction falls back to regular JSON encoding (`accounts`, `data`, and `programIdIndex` fields). - (optional) `transactionDetails: ` - level of transaction detail to return, either "full", "signatures", or "none". If parameter not provided, the default detail level is "full". - (optional) `rewards: bool` - whether to populate the `rewards` array. If parameter not provided, the default includes rewards. - (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment); "processed" is not supported. If parameter not provided, the default is "finalized". @@ -4490,6 +4598,7 @@ The result field will be an object with the following fields: #### Example: Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' {"jsonrpc": "2.0","id":1,"method":"getConfirmedBlock","params":[430, {"encoding": "json","transactionDetails":"full","rewards":false}]} @@ -4497,6 +4606,7 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json { "jsonrpc": "2.0", @@ -4512,21 +4622,9 @@ Result: "fee": 5000, "innerInstructions": [], "logMessages": [], - "postBalances": [ - 499998932500, - 26858640, - 1, - 1, - 1 - ], + "postBalances": [499998932500, 26858640, 1, 1, 1], "postTokenBalances": [], - "preBalances": [ - 499998937500, - 26858640, - 1, - 1, - 1 - ], + "preBalances": [499998937500, 26858640, 1, 1, 1], "preTokenBalances": [], "status": { "Ok": null @@ -4548,12 +4646,7 @@ Result: }, "instructions": [ { - "accounts": [ - 1, - 2, - 3, - 0 - ], + "accounts": [1, 2, 3, 0], "data": "37u9WtQpcm6ULa3WRQHmj49EPs4if7o9f1jSRVZpm2dvihR9C8jY4NqEwXUbLwx15HBSNcP1", "programIdIndex": 4 } @@ -4572,7 +4665,9 @@ Result: ``` #### Example: + Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' {"jsonrpc": "2.0","id":1,"method":"getConfirmedBlock","params":[430, "base64"]} @@ -4580,6 +4675,7 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json { "jsonrpc": "2.0", @@ -4596,21 +4692,9 @@ Result: "fee": 5000, "innerInstructions": [], "logMessages": [], - "postBalances": [ - 499998932500, - 26858640, - 1, - 1, - 1 - ], + "postBalances": [499998932500, 26858640, 1, 1, 1], "postTokenBalances": [], - "preBalances": [ - 499998937500, - 26858640, - 1, - 1, - 1 - ], + "preBalances": [499998937500, 26858640, 1, 1, 1], "preTokenBalances": [], "status": { "Ok": null @@ -4649,12 +4733,12 @@ Returns a list of confirmed blocks between two slots 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. - +inclusive. Max range allowed is 500,000 slots. #### Example: Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' {"jsonrpc": "2.0","id":1,"method":"getConfirmedBlocks","params":[5, 10]} @@ -4662,8 +4746,9 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json -{"jsonrpc":"2.0","result":[5,6,7,8,9,10],"id":1} +{ "jsonrpc": "2.0", "result": [5, 6, 7, 8, 9, 10], "id": 1 } ``` ### getConfirmedBlocksWithLimit @@ -4687,6 +4772,7 @@ starting at `start_slot` for up to `limit` blocks, inclusive. #### Example: Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' {"jsonrpc": "2.0","id":1,"method":"getConfirmedBlocksWithLimit","params":[5, 3]} @@ -4694,8 +4780,9 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json -{"jsonrpc":"2.0","result":[5,6,7],"id":1} +{ "jsonrpc": "2.0", "result": [5, 6, 7], "id": 1 } ``` ### getConfirmedSignaturesForAddress2 @@ -4707,28 +4794,32 @@ 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: -* `` - account address as base-58 encoded string -* `` - (optional) Configuration object containing the following fields: - * `limit: ` - (optional) maximum transaction signatures to return (between 1 and 1,000, default: 1,000). - * `before: ` - (optional) start searching backwards from this transaction signature. - If not provided the search starts from the top of the highest max confirmed block. - * `until: ` - (optional) search until this transaction signature, if found before limit reached. - * (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment); "processed" is not supported. If parameter not provided, the default is "finalized". + +- `` - account address as base-58 encoded string +- `` - (optional) Configuration object containing the following fields: + - `limit: ` - (optional) maximum transaction signatures to return (between 1 and 1,000, default: 1,000). + - `before: ` - (optional) start searching backwards from this transaction signature. + If not provided the search starts from the top of the highest max confirmed block. + - `until: ` - (optional) search until this transaction signature, if found before limit reached. + - (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment); "processed" is not supported. If parameter not provided, the default is "finalized". #### Results: + The result field will be an array of transaction signature information, ordered from newest to oldest transaction: -* `` - * `signature: ` - transaction signature as base-58 encoded string - * `slot: ` - The slot that contains the block with the transaction - * `err: ` - Error if transaction failed, null if transaction succeeded. [TransactionError definitions](https://github.com/solana-labs/solana/blob/c0c60386544ec9a9ec7119229f37386d9f070523/sdk/src/transaction/error.rs#L13) - * `memo: ` - Memo associated with the transaction, null if no memo is present - * `blockTime: ` - estimated production time, as Unix timestamp (seconds since the Unix epoch) of when transaction was processed. null if not available. + +- `` + - `signature: ` - transaction signature as base-58 encoded string + - `slot: ` - The slot that contains the block with the transaction + - `err: ` - Error if transaction failed, null if transaction succeeded. [TransactionError definitions](https://github.com/solana-labs/solana/blob/c0c60386544ec9a9ec7119229f37386d9f070523/sdk/src/transaction/error.rs#L13) + - `memo: ` - Memo associated with the transaction, null if no memo is present + - `blockTime: ` - estimated production time, as Unix timestamp (seconds since the Unix epoch) of when transaction was processed. null if not available. #### Example: + Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' { @@ -4746,6 +4837,7 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json { "jsonrpc": "2.0", @@ -4773,8 +4865,8 @@ Returns transaction details for a confirmed transaction - `` - transaction signature as base-58 encoded string - `` - (optional) Configuration object containing the following optional fields: - - (optional) `encoding: ` - encoding for each returned Transaction, either "json", "jsonParsed", "base58" (*slow*), "base64". If parameter not provided, the default encoding is "json". - "jsonParsed" encoding attempts to use program-specific instruction parsers to return more human-readable and explicit data in the `transaction.message.instructions` list. If "jsonParsed" is requested but a parser cannot be found, the instruction falls back to regular JSON encoding (`accounts`, `data`, and `programIdIndex` fields). + - (optional) `encoding: ` - encoding for each returned Transaction, either "json", "jsonParsed", "base58" (_slow_), "base64". If parameter not provided, the default encoding is "json". + "jsonParsed" encoding attempts to use program-specific instruction parsers to return more human-readable and explicit data in the `transaction.message.instructions` list. If "jsonParsed" is requested but a parser cannot be found, the instruction falls back to regular JSON encoding (`accounts`, `data`, and `programIdIndex` fields). - (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment); "processed" is not supported. If parameter not provided, the default is "finalized". #### Results: @@ -4790,7 +4882,7 @@ Returns transaction details for a confirmed transaction - `preBalances: ` - array of u64 account balances from before the transaction was processed - `postBalances: ` - array of u64 account balances after the transaction was processed - `innerInstructions: ` - List of [inner instructions](#inner-instructions-structure) or `null` if inner instruction recording was not enabled during this transaction - - `preTokenBalances: ` - List of [token balances](#token-balances-structure) from before the transaction was processed or omitted if token balance recording was not yet enabled during this transaction + - `preTokenBalances: ` - List of [token balances](#token-balances-structure) from before the transaction was processed or omitted if token balance recording was not yet enabled during this transaction - `postTokenBalances: ` - List of [token balances](#token-balances-structure) from after the transaction was processed or omitted if token balance recording was not yet enabled during this transaction - `logMessages: ` - array of string log messages or `null` if log message recording was not enabled during this transaction - DEPRECATED: `status: ` - Transaction status @@ -4798,7 +4890,9 @@ Returns transaction details for a confirmed transaction - `"Err": ` - Transaction failed with TransactionError #### Example: + Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' { @@ -4814,6 +4908,7 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json { "jsonrpc": "2.0", @@ -4822,21 +4917,9 @@ Result: "err": null, "fee": 5000, "innerInstructions": [], - "postBalances": [ - 499998932500, - 26858640, - 1, - 1, - 1 - ], + "postBalances": [499998932500, 26858640, 1, 1, 1], "postTokenBalances": [], - "preBalances": [ - 499998937500, - 26858640, - 1, - 1, - 1 - ], + "preBalances": [499998937500, 26858640, 1, 1, 1], "preTokenBalances": [], "status": { "Ok": null @@ -4859,12 +4942,7 @@ Result: }, "instructions": [ { - "accounts": [ - 1, - 2, - 3, - 0 - ], + "accounts": [1, 2, 3, 0], "data": "37u9WtQpcm6ULa3WRQHmj49EPs4if7o9f1jSRVZpm2dvihR9C8jY4NqEwXUbLwx15HBSNcP1", "programIdIndex": 4 } @@ -4882,7 +4960,9 @@ Result: ``` #### Example: + Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' { @@ -4898,6 +4978,7 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json { "jsonrpc": "2.0", @@ -4906,21 +4987,9 @@ Result: "err": null, "fee": 5000, "innerInstructions": [], - "postBalances": [ - 499998932500, - 26858640, - 1, - 1, - 1 - ], + "postBalances": [499998932500, 26858640, 1, 1, 1], "postTokenBalances": [], - "preBalances": [ - 499998937500, - 26858640, - 1, - 1, - 1 - ], + "preBalances": [499998937500, 26858640, 1, 1, 1], "preTokenBalances": [], "status": { "Ok": null @@ -4959,6 +5028,7 @@ The result will be an RpcResponse JSON object with `value` equal to: #### Example: Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' { @@ -4973,6 +5043,7 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json { "jsonrpc": "2.0", @@ -5011,6 +5082,7 @@ The `result` field will be an `object` with the following fields: #### Example: Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' {"jsonrpc":"2.0","id":1, "method":"getFeeRateGovernor"} @@ -5018,6 +5090,7 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json { "jsonrpc": "2.0", @@ -5064,6 +5137,7 @@ The result will be an RpcResponse JSON object with `value` set to a JSON object #### Example: Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' {"jsonrpc":"2.0","id":1, "method":"getFees"} @@ -5071,6 +5145,7 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json { "jsonrpc": "2.0", @@ -5113,6 +5188,7 @@ An RpcResponse containing a JSON object consisting of a string blockhash and Fee #### Example: Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' {"jsonrpc":"2.0","id":1, "method":"getRecentBlockhash"} @@ -5120,6 +5196,7 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json { "jsonrpc": "2.0", @@ -5156,6 +5233,7 @@ None #### Example: Request: + ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' {"jsonrpc":"2.0","id":1, "method":"getSnapshotSlot"} @@ -5163,11 +5241,17 @@ curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' ``` Result: + ```json -{"jsonrpc":"2.0","result":100,"id":1} +{ "jsonrpc": "2.0", "result": 100, "id": 1 } ``` Result when the node has no snapshot: + ```json -{"jsonrpc":"2.0","error":{"code":-32008,"message":"No snapshot"},"id":1} +{ + "jsonrpc": "2.0", + "error": { "code": -32008, "message": "No snapshot" }, + "id": 1 +} ``` diff --git a/docs/src/developing/programming-model/accounts.md b/docs/src/developing/programming-model/accounts.md index 06151ddaf9..5eb9521eb2 100644 --- a/docs/src/developing/programming-model/accounts.md +++ b/docs/src/developing/programming-model/accounts.md @@ -24,9 +24,9 @@ uses an _address_ to look up an account. The address is a 256-bit public key. ## Signers Transactions may include digital [signatures](terminology.md#signature) -corresponding to the accounts' public keys referenced by the transaction. Such +corresponding to the account's public keys referenced by the transaction. Such signatures signify that the holder of the -account's private key signed and thus "authorized" the transaction. In this case, +account's private key signed, and thus, "authorized" the transaction. In this case, the account is referred to as a _signer_. Whether an account is a signer or not is communicated to the program as part of the account's metadata. Programs can then use that information to make authority decisions. @@ -71,7 +71,7 @@ previously created, the program will be passed an account with no data and zero that is owned by the system program. Such newly created accounts reflect -whether they sign the transaction and therefore can be used as an +whether they sign the transaction, and therefore, can be used as an authority. Authorities in this context convey to the program that the holder of the private key associated with the account's public key signed the transaction. The account's public key may be known to the program or recorded in another @@ -85,14 +85,14 @@ System program and is called a _system account_ aptly. An account includes "owner" metadata. The owner is a program id. The runtime grants the program write access to the account if its id matches the owner. For the case of the System program, the runtime allows clients to transfer lamports and importantly -_assign_ account ownership, meaning changing owner to different program id. If +_assign_ account ownership, meaning changing the owner to a different program id. If an account is not owned by a program, the program is only permitted to read its data and credit the account. ## Verifying validity of unmodified, reference-only accounts For security purposes, it is recommended that programs check the validity of any -account it reads but does not modify. +account it reads, but does not modify. This is because a malicious user could create accounts with arbitrary data and then pass these accounts to the @@ -101,17 +101,17 @@ a way that leads to unexpected or harmful program behavior. The security model enforces that an account's data can only be modified by the account's `Owner` program. This allows the program to trust that the data -passed to them via accounts they own. The +is passed to them via accounts they own. The runtime enforces this by rejecting any transaction containing a program that attempts to write to an account it does not own. If a program were to not check account validity, it might read an account -it thinks it owns but doesn't. Anyone can +it thinks it owns, but doesn't. Anyone can issue instructions to a program, and the runtime does not know that those accounts are expected to be owned by the program. To check an account's validity, the program should either check the account's -address against a known value or check that the account is indeed owned +address against a known value, or check that the account is indeed owned correctly (usually owned by the program itself). One example is when programs use a sysvar account. Unless the program checks the @@ -120,7 +120,7 @@ valid sysvar account merely by successful deserialization of the account's data. Accordingly, the Solana SDK [checks the sysvar account's validity during deserialization](https://github.com/solana-labs/solana/blob/a95675a7ce1651f7b59443eb146b356bc4b3f374/sdk/program/src/sysvar/mod.rs#L65). -A alternative and safer way to read a sysvar is via the sysvar's [`get()` +An alternative and safer way to read a sysvar is via the sysvar's [`get()` function](https://github.com/solana-labs/solana/blob/64bfc14a75671e4ec3fe969ded01a599645080eb/sdk/program/src/sysvar/mod.rs#L73) which doesn't require these checks. diff --git a/docs/src/developing/programming-model/calling-between-programs.md b/docs/src/developing/programming-model/calling-between-programs.md index 1157e05534..b554f02776 100644 --- a/docs/src/developing/programming-model/calling-between-programs.md +++ b/docs/src/developing/programming-model/calling-between-programs.md @@ -30,8 +30,8 @@ let message = Message::new(vec![ client.send_and_confirm_message(&[&alice_keypair, &bob_keypair], &message); ``` -Given two on-chain programs `token` and `acme`, each implementing instructions -`pay()` and `launch_missiles()` respectively, acme can be implemented with a +Given two on-chain programs, `token` and `acme`, each implementing instructions +`pay()` and `launch_missiles()` respectively, `acme` can be implemented with a call to a function defined in the `token` module by issuing a cross-program invocation: @@ -66,12 +66,12 @@ state of the accounts at the beginning of the `acme`'s instruction. After `pay()` completes, the runtime must again ensure that `token` didn't modify any accounts owned by `acme` by again applying the runtime's policy, but this time with the `token` program ID. Lastly, after `pay_and_launch_missiles()` -completes, the runtime must apply the runtime policy one more time, where it +completes, the runtime must apply the runtime policy one more time where it normally would, but using all updated `pre_*` variables. If executing `pay_and_launch_missiles()` up to `pay()` made no invalid account changes, `pay()` made no invalid changes, and executing from `pay()` until `pay_and_launch_missiles()` returns made no invalid changes, then the runtime -can transitively assume `pay_and_launch_missiles()` as whole made no invalid +can transitively assume `pay_and_launch_missiles()` as a whole made no invalid account changes, and therefore commit all these account modifications. ### Instructions that require privileges @@ -111,12 +111,12 @@ To sign an account with program derived addresses, a program may ### Call Depth -Cross-program invocations allow programs to invoke other programs directly but +Cross-program invocations allow programs to invoke other programs directly, but the depth is constrained currently to 4. ### Reentrancy -Reentrancy is currently limited to direct self recursion capped at a fixed +Reentrancy is currently limited to direct self recursion, capped at a fixed depth. This restriction prevents situations where a program might invoke another from an intermediary state without the knowledge that it might later be called back into. Direct recursion gives the program full control of its state at the @@ -159,22 +159,22 @@ Program derived address: present in instructions invoked via [Cross-Program Invocations](#cross-program-invocations). Given the two conditions, users can securely transfer or assign the authority of -on-chain assets to program addresses and the program can then assign that +on-chain assets to program addresses, and the program can then assign that authority elsewhere at its discretion. ### Private keys for program addresses -A Program address does not lie on the ed25519 curve and therefore has no valid +A program address does not lie on the ed25519 curve and therefore has no valid private key associated with it, and thus generating a signature for it is impossible. While it has no private key of its own, it can be used by a program -to issue an instruction that includes the Program address as a signer. +to issue an instruction that includes the program address as a signer. ### Hash-based generated program addresses Program addresses are deterministically derived from a collection of seeds and a program id using a 256-bit pre-image resistant hash function. Program address must not lie on the ed25519 curve to ensure there is no associated private key. -During generation an error will be returned if the address is found to lie on +During generation, an error will be returned if the address is found to lie on the curve. There is about a 50/50 chance of this happening for a given collection of seeds and program id. If this occurs a different set of seeds or a seed bump (additional 8 bit seed) can be used to find a valid program address @@ -184,7 +184,7 @@ Deterministic program addresses for programs follow a similar derivation path as Accounts created with `SystemInstruction::CreateAccountWithSeed` which is implemented with `Pubkey::create_with_seed`. -For reference that implementation is as follows: +For reference, that implementation is as follows: ```rust,ignore pub fn create_with_seed( diff --git a/docs/src/developing/programming-model/runtime.md b/docs/src/developing/programming-model/runtime.md index e73ee82a68..b94335fe00 100644 --- a/docs/src/developing/programming-model/runtime.md +++ b/docs/src/developing/programming-model/runtime.md @@ -12,18 +12,18 @@ signed the transaction using the keypair's _private key_, it knows the client authorized the token transfer. In other words, the entire set of accounts owned by a given program can be -regarded as a key-value store where a key is the account address and value is +regarded as a key-value store, where a key is the account address and value is program-specific arbitrary binary data. A program author can decide how to -manage the program's whole state as possibly many accounts. +manage the program's whole state, possibly as many accounts. After the runtime executes each of the transaction's instructions, it uses the account metadata to verify that the access policy was not violated. If a program violates the policy, the runtime discards all account changes made by all -instructions in the transaction and marks the transaction as failed. +instructions in the transaction, and marks the transaction as failed. ### Policy -After a program has processed an instruction the runtime verifies that the +After a program has processed an instruction, the runtime verifies that the program only performed operations it was permitted to, and that the results adhere to the runtime policy. @@ -31,7 +31,7 @@ The policy is as follows: - Only the owner of the account may change owner. - And only if the account is writable. - - And only if the account is not executable + - And only if the account is not executable. - And only if the data is zero-initialized or empty. - An account not assigned to the program cannot have its balance decrease. - The balance of read-only and executable accounts may not change. @@ -45,15 +45,11 @@ The policy is as follows: ## Compute Budget -To prevent a program from abusing computation resources each instruction in a +To prevent a program from abusing computation resources, each instruction in a transaction is given a compute budget. The budget consists of computation units that are consumed as the program performs various operations and bounds that the -program may not exceed. When the program consumes its entire budget or exceeds a -bound then the runtime halts the program and returns an error. - -Note: The compute budget currently applies per-instruction but is moving toward -a per-transaction model. For more information see [Transaction-wide Compute -Budget](#transaction-wide-compute-buget). +program may not exceed. When the program consumes its entire budget or exceeds +a bound, then the runtime halts the program and returns an error. The following operations incur a compute cost: @@ -65,8 +61,8 @@ The following operations incur a compute cost: - ... For cross-program invocations, the programs invoked inherit the budget of their -parent. If an invoked program consume the budget or exceeds a bound the entire -invocation chain is halted. +parent. If an invoked program consumes the budget or exceeds a bound, the entire +invocation chain and the parent are halted. The current [compute budget](https://github.com/solana-labs/solana/blob/0224a8b127ace4c6453dd6492a38c66cb999abd2/sdk/src/compute_budget.rs#L102) @@ -89,10 +85,10 @@ log_pubkey_units: 100, Then the program -- Could execute 200,000 BPF instructions if it does nothing else -- Could log 2,000 log messages -- Can not exceed 4k of stack usage -- Can not exceed a BPF call depth of 64 +- Could execute 200,000 BPF instructions, if it does nothing else. +- Could log 2,000 log messages. +- Can not exceed 4k of stack usage. +- Can not exceed a BPF call depth of 64. - Cannot exceed 4 levels of cross-program invocations. Since the compute budget is consumed incrementally as the program executes, the @@ -106,7 +102,7 @@ for more information. ## Transaction-wide Compute Budget Transactions are processed as a single entity and are the primary unit of block -scheduling. In order to facilitate better block scheduling and account for the +scheduling. In order to facilitate better block scheduling and account for the computational cost of each transaction, the compute budget is moving to a transaction-wide budget rather than per-instruction. @@ -114,16 +110,16 @@ For information on what the compute budget is and how it is applied see [Compute Budget](#compute-budget). With a transaction-wide compute budget the `max_units` cap is applied to the -entire transaction rather than to each instruction within the transaction. The +entire transaction rather than to each instruction within the transaction. The default number of maximum units remains at 200k which means the sum of the compute units used by each instruction in the transaction must not exceed that value. The number of maximum units allows is intentionally kept small to facilitate optimized programs and form the bases for a minimum fee level. There are a lot of uses cases that require more than 200k units -transaction-wide. To enable these uses cases transactions can include a +transaction-wide. To enable these uses cases transactions can include a [``ComputeBudgetInstruction`](https://github.com/solana-labs/solana/blob/0224a8b127ace4c6453dd6492a38c66cb999abd2/sdk/src/compute_budget.rs#L44) -requesting a higher compute unit cap. Higher compute caps will be charged +requesting a higher compute unit cap. Higher compute caps will be charged higher fees. Compute Budget instructions don't require any accounts and must lie in the first @@ -140,7 +136,7 @@ let instruction = ComputeBudgetInstruction::request_units(300_000); As Solana evolves, new features or patches may be introduced that changes the behavior of the cluster and how programs run. Changes in behavior must be -coordinated between the various nodes of the cluster, if nodes do not coordinate +coordinated between the various nodes of the cluster. If nodes do not coordinate, then these changes can result in a break-down of consensus. Solana supports a mechanism called runtime features to facilitate the smooth adoption of changes. @@ -157,6 +153,6 @@ tools](cli/install-solana-cli-tools.md): solana feature status ``` -If you encounter problems first ensure that the Solana tools version you are +If you encounter problems, first ensure that the Solana tools version you are using match the version returned by `solana cluster-version`. If they do not -match [install the correct tool suite](cli/install-solana-cli-tools.md). +match, [install the correct tool suite](cli/install-solana-cli-tools.md). diff --git a/docs/src/developing/programming-model/transactions.md b/docs/src/developing/programming-model/transactions.md index e1a5c32f5f..393f6f5ecf 100644 --- a/docs/src/developing/programming-model/transactions.md +++ b/docs/src/developing/programming-model/transactions.md @@ -43,7 +43,7 @@ not requiring signatures. #### Account Addresses Format The addresses that require signatures appear at the beginning of the account -address array, with addresses requesting write access first and read-only +address array, with addresses requesting read-write access first, and read-only accounts following. The addresses that do not require signatures follow the addresses that do, again with read-write accounts first and read-only accounts following. @@ -130,7 +130,7 @@ https://github.com/solana-labs/solana/blob/6606590b8132e56dab9e60b3f7d20ba7412a7 The instruction's [program id](terminology.md#program-id) specifies which program will process this instruction. The program's account's owner specifies -which loader should be used to load and execute the program and the data +which loader should be used to load and execute the program, and the data contains information about how the runtime should execute the program. In the case of [on-chain BPF programs](developing/on-chain-programs/overview.md), @@ -145,7 +145,7 @@ are handled differently in that they are built directly into the Solana runtime. ### Accounts The accounts referenced by an instruction represent on-chain state and serve as -both the inputs and outputs of a program. More information about Accounts can be +both the inputs and outputs of a program. More information about accounts can be found in the [Accounts](accounts.md) section. ### Instruction data @@ -157,8 +157,8 @@ perform, and any additional information those operations may need above and beyond what the accounts contain. Programs are free to specify how information is encoded into the instruction -data byte array. The choice of how data is encoded should take into account the -overhead of decoding since that step is performed by the program on-chain. It's +data byte array. The choice of how data is encoded should take into calculate the +overhead of decoding, since that step is performed by the program on-chain. It's been observed that some common encodings (Rust's bincode for example) are very inefficient.