From 55ac654e08c852f5831a5fb2f51e2318709a6804 Mon Sep 17 00:00:00 2001 From: Nick Frostbutter <75431177+nickfrosty@users.noreply.github.com> Date: Thu, 26 Jan 2023 18:14:47 -0500 Subject: [PATCH] [docs] new JSON RPC API docs format (#29772) * feat: added api page * fix: api redirects * feat: websocket page and partials * feat: deprectated partials * feat: http method partials * fix: more deprecated partials * feat: codeblock component and styles * feat: api http methods page * feat: sidebar * refactor: proposal api links * refactor: internal linking * refactor: more internal links * refactor: internal link and note cards * refactor: local links * refactor: local links and auto save prettier * feat: added numNonVoteTransaction data details * fix: updated getRecentPrioritizationFees * fix: corrected wording * fix: version typo * fix: commitment links * fix: parsed response links * fix: dangling links * refactor: filter criteria * docs: removed jsonrpc-api.md file * fix: dangling links * style: removed whitespaces for CI * style: removed whitespace * style: fixed whitespaces --- docs/components/CodeDocBlock.jsx | 161 + docs/publish-docs.sh | 3 +- docs/sidebars.js | 6 +- docs/sidebars/api.js | 492 ++ .../src/api/deprecated/_getConfirmedBlock.mdx | 169 + .../api/deprecated/_getConfirmedBlocks.mdx | 71 + .../_getConfirmedBlocksWithLimit.mdx | 78 + .../_getConfirmedSignaturesForAddress2.mdx | 114 + .../deprecated/_getConfirmedTransaction.mdx | 133 + .../_getFeeCalculatorForBlockhash.mdx | 97 + .../api/deprecated/_getFeeRateGovernor.mdx | 76 + docs/src/api/deprecated/_getFees.mdx | 92 + .../api/deprecated/_getRecentBlockhash.mdx | 87 + docs/src/api/deprecated/_getSnapshotSlot.mdx | 64 + docs/src/api/http.md | 419 ++ docs/src/api/methods/_getAccountInfo.mdx | 136 + docs/src/api/methods/_getBalance.mdx | 78 + docs/src/api/methods/_getBlock.mdx | 288 + docs/src/api/methods/_getBlockCommitment.mdx | 70 + docs/src/api/methods/_getBlockHeight.mdx | 73 + docs/src/api/methods/_getBlockProduction.mdx | 97 + docs/src/api/methods/_getBlockTime.mdx | 67 + docs/src/api/methods/_getBlocks.mdx | 86 + docs/src/api/methods/_getBlocksWithLimit.mdx | 84 + docs/src/api/methods/_getClusterNodes.mdx | 71 + docs/src/api/methods/_getEpochInfo.mdx | 85 + docs/src/api/methods/_getEpochSchedule.mdx | 67 + docs/src/api/methods/_getFeeForMessage.mdx | 86 + .../api/methods/_getFirstAvailableBlock.mdx | 50 + docs/src/api/methods/_getGenesisHash.mdx | 51 + docs/src/api/methods/_getHealth.mdx | 88 + .../api/methods/_getHighestSnapshotSlot.mdx | 78 + docs/src/api/methods/_getIdentity.mdx | 55 + .../src/api/methods/_getInflationGovernor.mdx | 75 + docs/src/api/methods/_getInflationRate.mdx | 62 + docs/src/api/methods/_getInflationReward.mdx | 101 + docs/src/api/methods/_getLargestAccounts.mdx | 150 + docs/src/api/methods/_getLatestBlockhash.mdx | 92 + docs/src/api/methods/_getLeaderSchedule.mdx | 96 + .../src/api/methods/_getMaxRetransmitSlot.mdx | 48 + .../api/methods/_getMaxShredInsertSlot.mdx | 48 + .../_getMinimumBalanceForRentExemption.mdx | 67 + docs/src/api/methods/_getMultipleAccounts.mdx | 143 + docs/src/api/methods/_getProgramAccounts.mdx | 160 + .../methods/_getRecentPerformanceSamples.mdx | 103 + .../methods/_getRecentPrioritizationFees.mdx | 95 + .../src/api/methods/_getSignatureStatuses.mdx | 114 + .../api/methods/_getSignaturesForAddress.mdx | 117 + docs/src/api/methods/_getSlot.mdx | 63 + docs/src/api/methods/_getSlotLeader.mdx | 67 + docs/src/api/methods/_getSlotLeaders.mdx | 77 + docs/src/api/methods/_getStakeActivation.mdx | 95 + .../methods/_getStakeMinimumDelegation.mdx | 73 + docs/src/api/methods/_getSupply.mdx | 87 + .../api/methods/_getTokenAccountBalance.mdx | 91 + .../methods/_getTokenAccountsByDelegate.mdx | 177 + .../api/methods/_getTokenAccountsByOwner.mdx | 176 + .../api/methods/_getTokenLargestAccounts.mdx | 99 + docs/src/api/methods/_getTokenSupply.mdx | 88 + docs/src/api/methods/_getTransaction.mdx | 172 + docs/src/api/methods/_getTransactionCount.mdx | 63 + docs/src/api/methods/_getVersion.mdx | 51 + docs/src/api/methods/_getVoteAccounts.mdx | 114 + docs/src/api/methods/_isBlockhashValid.mdx | 89 + docs/src/api/methods/_minimumLedgerSlot.mdx | 52 + docs/src/api/methods/_requestAirdrop.mdx | 78 + docs/src/api/methods/_sendTransaction.mdx | 124 + docs/src/api/methods/_simulateTransaction.mdx | 174 + docs/src/api/websocket.md | 91 + docs/src/api/websocket/_accountSubscribe.mdx | 160 + .../src/api/websocket/_accountUnsubscribe.mdx | 53 + docs/src/api/websocket/_blockSubscribe.mdx | 342 + docs/src/api/websocket/_blockUnsubscribe.mdx | 53 + docs/src/api/websocket/_logsSubscribe.mdx | 130 + docs/src/api/websocket/_logsUnsubscribe.mdx | 53 + docs/src/api/websocket/_programSubscribe.mdx | 205 + .../src/api/websocket/_programUnsubscribe.mdx | 53 + docs/src/api/websocket/_rootSubscribe.mdx | 62 + docs/src/api/websocket/_rootUnsubscribe.mdx | 53 + .../src/api/websocket/_signatureSubscribe.mdx | 98 + .../api/websocket/_signatureUnsubscribe.mdx | 53 + docs/src/api/websocket/_slotSubscribe.mdx | 72 + docs/src/api/websocket/_slotUnsubscribe.mdx | 53 + .../api/websocket/_slotsUpdatesSubscribe.mdx | 86 + .../websocket/_slotsUpdatesUnsubscribe.mdx | 53 + docs/src/api/websocket/_voteSubscribe.mdx | 79 + docs/src/api/websocket/_voteUnsubscribe.mdx | 53 + docs/src/cluster/rpc-endpoints.md | 12 +- docs/src/developing/clients/javascript-api.md | 2 +- .../clients/javascript-reference.md | 4 +- docs/src/developing/clients/jsonrpc-api.md | 5490 ----------------- docs/src/developing/clients/rust-api.md | 2 +- docs/src/developing/intro/rent.md | 2 +- docs/src/developing/intro/transaction_fees.md | 2 +- .../developing/programming-model/accounts.md | 6 +- docs/src/developing/test-validator.md | 6 +- .../developing/transaction_confirmation.md | 199 + docs/src/developing/versioned-transactions.md | 8 +- docs/src/getstarted/hello-world.md | 25 +- .../rpc-transaction-history.md | 14 +- .../implemented-proposals/transaction-fees.md | 4 +- docs/src/integrations/exchange.md | 19 +- .../src/integrations/retrying-transactions.md | 16 +- docs/src/pages/CodeDocBlock.module.css | 80 + docs/src/pages/api.js | 82 + docs/src/pages/developers.js | 2 +- docs/src/running-validator/validator-stake.md | 2 +- docs/src/running-validator/validator-start.md | 21 +- docs/src/transaction_fees.md | 2 +- 109 files changed, 9391 insertions(+), 5564 deletions(-) create mode 100644 docs/components/CodeDocBlock.jsx create mode 100644 docs/sidebars/api.js create mode 100644 docs/src/api/deprecated/_getConfirmedBlock.mdx create mode 100644 docs/src/api/deprecated/_getConfirmedBlocks.mdx create mode 100644 docs/src/api/deprecated/_getConfirmedBlocksWithLimit.mdx create mode 100644 docs/src/api/deprecated/_getConfirmedSignaturesForAddress2.mdx create mode 100644 docs/src/api/deprecated/_getConfirmedTransaction.mdx create mode 100644 docs/src/api/deprecated/_getFeeCalculatorForBlockhash.mdx create mode 100644 docs/src/api/deprecated/_getFeeRateGovernor.mdx create mode 100644 docs/src/api/deprecated/_getFees.mdx create mode 100644 docs/src/api/deprecated/_getRecentBlockhash.mdx create mode 100644 docs/src/api/deprecated/_getSnapshotSlot.mdx create mode 100644 docs/src/api/http.md create mode 100644 docs/src/api/methods/_getAccountInfo.mdx create mode 100644 docs/src/api/methods/_getBalance.mdx create mode 100644 docs/src/api/methods/_getBlock.mdx create mode 100644 docs/src/api/methods/_getBlockCommitment.mdx create mode 100644 docs/src/api/methods/_getBlockHeight.mdx create mode 100644 docs/src/api/methods/_getBlockProduction.mdx create mode 100644 docs/src/api/methods/_getBlockTime.mdx create mode 100644 docs/src/api/methods/_getBlocks.mdx create mode 100644 docs/src/api/methods/_getBlocksWithLimit.mdx create mode 100644 docs/src/api/methods/_getClusterNodes.mdx create mode 100644 docs/src/api/methods/_getEpochInfo.mdx create mode 100644 docs/src/api/methods/_getEpochSchedule.mdx create mode 100644 docs/src/api/methods/_getFeeForMessage.mdx create mode 100644 docs/src/api/methods/_getFirstAvailableBlock.mdx create mode 100644 docs/src/api/methods/_getGenesisHash.mdx create mode 100644 docs/src/api/methods/_getHealth.mdx create mode 100644 docs/src/api/methods/_getHighestSnapshotSlot.mdx create mode 100644 docs/src/api/methods/_getIdentity.mdx create mode 100644 docs/src/api/methods/_getInflationGovernor.mdx create mode 100644 docs/src/api/methods/_getInflationRate.mdx create mode 100644 docs/src/api/methods/_getInflationReward.mdx create mode 100644 docs/src/api/methods/_getLargestAccounts.mdx create mode 100644 docs/src/api/methods/_getLatestBlockhash.mdx create mode 100644 docs/src/api/methods/_getLeaderSchedule.mdx create mode 100644 docs/src/api/methods/_getMaxRetransmitSlot.mdx create mode 100644 docs/src/api/methods/_getMaxShredInsertSlot.mdx create mode 100644 docs/src/api/methods/_getMinimumBalanceForRentExemption.mdx create mode 100644 docs/src/api/methods/_getMultipleAccounts.mdx create mode 100644 docs/src/api/methods/_getProgramAccounts.mdx create mode 100644 docs/src/api/methods/_getRecentPerformanceSamples.mdx create mode 100644 docs/src/api/methods/_getRecentPrioritizationFees.mdx create mode 100644 docs/src/api/methods/_getSignatureStatuses.mdx create mode 100644 docs/src/api/methods/_getSignaturesForAddress.mdx create mode 100644 docs/src/api/methods/_getSlot.mdx create mode 100644 docs/src/api/methods/_getSlotLeader.mdx create mode 100644 docs/src/api/methods/_getSlotLeaders.mdx create mode 100644 docs/src/api/methods/_getStakeActivation.mdx create mode 100644 docs/src/api/methods/_getStakeMinimumDelegation.mdx create mode 100644 docs/src/api/methods/_getSupply.mdx create mode 100644 docs/src/api/methods/_getTokenAccountBalance.mdx create mode 100644 docs/src/api/methods/_getTokenAccountsByDelegate.mdx create mode 100644 docs/src/api/methods/_getTokenAccountsByOwner.mdx create mode 100644 docs/src/api/methods/_getTokenLargestAccounts.mdx create mode 100644 docs/src/api/methods/_getTokenSupply.mdx create mode 100644 docs/src/api/methods/_getTransaction.mdx create mode 100644 docs/src/api/methods/_getTransactionCount.mdx create mode 100644 docs/src/api/methods/_getVersion.mdx create mode 100644 docs/src/api/methods/_getVoteAccounts.mdx create mode 100644 docs/src/api/methods/_isBlockhashValid.mdx create mode 100644 docs/src/api/methods/_minimumLedgerSlot.mdx create mode 100644 docs/src/api/methods/_requestAirdrop.mdx create mode 100644 docs/src/api/methods/_sendTransaction.mdx create mode 100644 docs/src/api/methods/_simulateTransaction.mdx create mode 100644 docs/src/api/websocket.md create mode 100644 docs/src/api/websocket/_accountSubscribe.mdx create mode 100644 docs/src/api/websocket/_accountUnsubscribe.mdx create mode 100644 docs/src/api/websocket/_blockSubscribe.mdx create mode 100644 docs/src/api/websocket/_blockUnsubscribe.mdx create mode 100644 docs/src/api/websocket/_logsSubscribe.mdx create mode 100644 docs/src/api/websocket/_logsUnsubscribe.mdx create mode 100644 docs/src/api/websocket/_programSubscribe.mdx create mode 100644 docs/src/api/websocket/_programUnsubscribe.mdx create mode 100644 docs/src/api/websocket/_rootSubscribe.mdx create mode 100644 docs/src/api/websocket/_rootUnsubscribe.mdx create mode 100644 docs/src/api/websocket/_signatureSubscribe.mdx create mode 100644 docs/src/api/websocket/_signatureUnsubscribe.mdx create mode 100644 docs/src/api/websocket/_slotSubscribe.mdx create mode 100644 docs/src/api/websocket/_slotUnsubscribe.mdx create mode 100644 docs/src/api/websocket/_slotsUpdatesSubscribe.mdx create mode 100644 docs/src/api/websocket/_slotsUpdatesUnsubscribe.mdx create mode 100644 docs/src/api/websocket/_voteSubscribe.mdx create mode 100644 docs/src/api/websocket/_voteUnsubscribe.mdx delete mode 100644 docs/src/developing/clients/jsonrpc-api.md create mode 100644 docs/src/developing/transaction_confirmation.md create mode 100644 docs/src/pages/CodeDocBlock.module.css create mode 100644 docs/src/pages/api.js diff --git a/docs/components/CodeDocBlock.jsx b/docs/components/CodeDocBlock.jsx new file mode 100644 index 00000000000000..bd0099b99e7830 --- /dev/null +++ b/docs/components/CodeDocBlock.jsx @@ -0,0 +1,161 @@ +import React from "react"; +import Link from "@docusaurus/Link"; +// import clsx from "clsx"; +import styles from "../src/pages/CodeDocBlock.module.css"; + +export function DocBlock({ children }) { + return
{children}
; +} + +export function DocSideBySide({ children }) { + return
{children}
; +} + +export function CodeParams({ children }) { + return
{children}
; +} + +export function CodeSnippets({ children }) { + return ( +
+ {/*

Code Sample:

*/} + + {children} +
+ ); +} + +/* + Display a single Parameter +*/ +export function Parameter(props) { + const { + name = null, + type = null, + required = null, + optional = null, + children, + } = computeHeader(props); + + return ( +
+

+ {name && name} {type && type} {required && required}{" "} + {optional && optional} +

+ + {children} +
+ ); +} + +/* + Display a single Parameter's field data +*/ +export function Field(props) { + const { + name = null, + type = null, + values = null, + required = null, + defaultValue = null, + optional = null, + children, + } = computeHeader(props); + + return ( +
+

+ {name && name} {type && type} {required && required}{" "} + {optional && optional} + {defaultValue && defaultValue} +

+ +
+ {values && values} + + {children} +
+
+ ); +} + +/* + Parse an array of string values to display +*/ +export function Values({ values = null }) { + // format the Parameter's values + if (values && Array.isArray(values) && values?.length) { + values = values.map((value) => ( + + {value} + + )); + } + + return ( +

+ Values: {values} +

+ ); +} + +/* + Compute the formatted Parameter and Field component's header meta data +*/ +function computeHeader({ + name = null, + type = null, + href = null, + values = null, + required = null, + defaultValue = null, + optional = null, + children, +}) { + // format the Parameter's name + if (name) { + name = {name}; + + if (href) name = {name}; + } + + // format the Parameter's type + if (type) type = {type}; + + // format the Parameter's values + if (values && Array.isArray(values)) { + values = values.map((value) => ( + {value} + )); + } + + // format the `defaultValue` flag + if (defaultValue) { + defaultValue = ( + + Default: {defaultValue.toString()} + + ); + } + + // format the `required` flag + if (required) { + required = required; + } + // format the `optional` flag + else if (optional) { + optional = optional; + } + + return { + name, + type, + href, + values, + required, + defaultValue, + optional, + children, + }; +} diff --git a/docs/publish-docs.sh b/docs/publish-docs.sh index 2a6002871b8f31..811dea1eb491f7 100755 --- a/docs/publish-docs.sh +++ b/docs/publish-docs.sh @@ -38,7 +38,8 @@ cat > "$CONFIG_FILE" < + +## getConfirmedBlock + +:::warning DEPRECATED +This method is expected to be removed in solana-core v2.0. +**Please use [getBlock](#getblock) instead** +::: + +Returns identity and transaction information about a confirmed block in the ledger + + + + + +### Parameters: + + + slot number, as u64 integer + + + + +Configuration object containing the following fields: + + + + + level of transaction detail to return, either "full", "signatures", or "none" + + + + whether to populate the `rewards` array. + + + + +Encoding format for Account data + + + +
+ +- `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). + +
+ +
+ +
+ +### Result: + +The result field will be an object with the following fields: + +- `` - if specified block is not confirmed +- `` - if block is confirmed, an object with the following fields: + - `blockhash: ` - the blockhash of this block, as base-58 encoded string + - `previousBlockhash: ` - the blockhash of this block's parent, as base-58 encoded string; if the parent block is not available due to ledger cleanup, this field will return "11111111111111111111111111111111" + - `parentSlot: ` - the slot index of this block's parent + - `transactions: ` - present if "full" transaction details are requested; an array of JSON objects containing: + - `transaction: ` - [Transaction](#transaction-structure) object, either in JSON format or encoded binary data, depending on encoding parameter + - `meta: ` - transaction status metadata object, containing `null` or: + - `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) + - `fee: ` - fee this transaction was charged, as u64 integer + - `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 + - `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 + - `"Ok": ` - Transaction was successful + - `"Err": ` - Transaction failed with TransactionError + - `signatures: ` - present if "signatures" are requested for transaction details; an array of signatures strings, corresponding to the transaction order in the block + - `rewards: ` - present if rewards are requested; an array of JSON objects containing: + - `pubkey: ` - The public key, as base-58 encoded string, of the account that received the reward + - `lamports: `- number of reward lamports credited or debited by the account, as a i64 + - `postBalance: ` - account balance in lamports after the reward was applied + - `rewardType: ` - type of reward: "fee", "rent", "voting", "staking" + - `commission: ` - vote account commission when the reward was credited, only present for voting and staking rewards + - `blockTime: ` - estimated production time, as Unix timestamp (seconds since the Unix epoch). null if not available + +#### For more details on returned data: + +- [Transaction Structure](#transaction-structure) +- [Inner Instructions Structure](#inner-instructions-structure) +- [Token Balances Structure](#token-balances-structure) + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc": "2.0", "id": 1, + "method": "getConfirmedBlock", + "params": [430, "base64"] + } +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": { + "blockTime": null, + "blockhash": "3Eq21vXNB5s86c62bVuUfTeaMif1N2kUqRPBmGRJhyTA", + "parentSlot": 429, + "previousBlockhash": "mfcyqEXB3DnHXki6KjjmZck6YjmZLvpAByy2fj4nh6B", + "rewards": [], + "transactions": [ + { + "meta": { + "err": null, + "fee": 5000, + "innerInstructions": [], + "logMessages": [], + "postBalances": [499998932500, 26858640, 1, 1, 1], + "postTokenBalances": [], + "preBalances": [499998937500, 26858640, 1, 1, 1], + "preTokenBalances": [], + "status": { + "Ok": null + } + }, + "transaction": [ + "AVj7dxHlQ9IrvdYVIjuiRFs1jLaDMHixgrv+qtHBwz51L4/ImLZhszwiyEJDIp7xeBSpm/TX5B7mYzxa+fPOMw0BAAMFJMJVqLw+hJYheizSoYlLm53KzgT82cDVmazarqQKG2GQsLgiqktA+a+FDR4/7xnDX7rsusMwryYVUdixfz1B1Qan1RcZLwqvxvJl4/t3zHragsUp0L47E24tAFUgAAAABqfVFxjHdMkoVmOYaR1etoteuKObS21cc1VbIQAAAAAHYUgdNXR0u3xNdiTr072z2DVec9EQQ/wNo1OAAAAAAAtxOUhPBp2WSjUNJEgfvy70BbxI00fZyEPvFHNfxrtEAQQEAQIDADUCAAAAAQAAAAAAAACtAQAAAAAAAAdUE18R96XTJCe+YfRfUp6WP+YKCy/72ucOL8AoBFSpAA==", + "base64" + ] + } + ] + }, + "id": 1 +} +``` + + + + diff --git a/docs/src/api/deprecated/_getConfirmedBlocks.mdx b/docs/src/api/deprecated/_getConfirmedBlocks.mdx new file mode 100644 index 00000000000000..5a6b21c12aa8a8 --- /dev/null +++ b/docs/src/api/deprecated/_getConfirmedBlocks.mdx @@ -0,0 +1,71 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getConfirmedBlocks + +:::warning DEPRECATED +This method is expected to be removed in solana-core v2.0 +**Please use [getBlocks](#getblocks) instead** +::: + +Returns a list of confirmed blocks between two slots + + + + + +### Parameters: + + + start_slot, as u64 integer + + + + +Configuration object containing the following fields: + + + + + +### Result: + +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. + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + {"jsonrpc": "2.0","id":1,"method":"getConfirmedBlocks","params":[5, 10]} +' +``` + +### Response: + +```json +{ "jsonrpc": "2.0", "result": [5, 6, 7, 8, 9, 10], "id": 1 } +``` + + + + diff --git a/docs/src/api/deprecated/_getConfirmedBlocksWithLimit.mdx b/docs/src/api/deprecated/_getConfirmedBlocksWithLimit.mdx new file mode 100644 index 00000000000000..3daec0abc25a37 --- /dev/null +++ b/docs/src/api/deprecated/_getConfirmedBlocksWithLimit.mdx @@ -0,0 +1,78 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getConfirmedBlocksWithLimit + +:::warning DEPRECATED +This method is expected to be removed in solana-core v2.0 +**Please use [getBlocksWithLimit](#getblockswithlimit) instead** +::: + +Returns a list of confirmed blocks starting at the given slot + + + + + +### Parameters: + + + start_slot, as u64 integer + + + + limit, as u64 integer + + + + +Configuration object containing the following fields: + + + + + +### Result: + +The result field will be an array of u64 integers listing confirmed blocks +starting at `start_slot` for up to `limit` blocks, inclusive. + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc": "2.0", "id": 1, + "method": "getConfirmedBlocksWithLimit", + "params": [5, 3] + } +' +``` + +### Response: + +```json +{ "jsonrpc": "2.0", "result": [5, 6, 7], "id": 1 } +``` + + + + diff --git a/docs/src/api/deprecated/_getConfirmedSignaturesForAddress2.mdx b/docs/src/api/deprecated/_getConfirmedSignaturesForAddress2.mdx new file mode 100644 index 00000000000000..7d8c803d061544 --- /dev/null +++ b/docs/src/api/deprecated/_getConfirmedSignaturesForAddress2.mdx @@ -0,0 +1,114 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getConfirmedSignaturesForAddress2 + +:::warning DEPRECATED +This method is expected to be removed in solana-core v2.0 +**Please use [getSignaturesForAddress](#getsignaturesforaddress) instead** +::: + +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 + + + +Configuration object containing the following fields: + + + + + maximum transaction signatures to return (between 1 and 1,000, default: + 1,000). + + + + start searching backwards from this transaction signature. (If not provided + the search starts from the top of the highest max confirmed block.) + + + + search until this transaction signature, if found before limit reached. + + + + +### Result: + +The result field will be an array of ``, ordered +from newest to oldest transaction, containing transaction signature information with the following fields: + +- `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. + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc": "2.0", + "id": 1, + "method": "getConfirmedSignaturesForAddress2", + "params": [ + "Vote111111111111111111111111111111111111111", + { + "limit": 1 + } + ] + } +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": [ + { + "err": null, + "memo": null, + "signature": "5h6xBEauJ3PK6SWCZ1PGjBvj8vDdWG3KpwATGy1ARAXFSDwt8GFXM7W5Ncn16wmqokgpiKRLuS83KUxyZyv2sUYv", + "slot": 114, + "blockTime": null + } + ], + "id": 1 +} +``` + + + + diff --git a/docs/src/api/deprecated/_getConfirmedTransaction.mdx b/docs/src/api/deprecated/_getConfirmedTransaction.mdx new file mode 100644 index 00000000000000..9586975df62c6e --- /dev/null +++ b/docs/src/api/deprecated/_getConfirmedTransaction.mdx @@ -0,0 +1,133 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getConfirmedTransaction + +:::warning DEPRECATED +This method is expected to be removed in solana-core v2.0 +**Please use [getTransaction](#gettransaction) instead** +::: + +Returns transaction details for a confirmed transaction + + + + + +### Parameters: + + + transaction signature, as base-58 encoded string + + + + +Configuration object containing the following fields: + + + + + +Encoding format for Account data + + + +
+ +- `base58` is slow and limited to less than 129 bytes of Account data. +- `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). + +
+ +
+ +
+ +### Result: + +- `` - if transaction is not found or not confirmed +- `` - if transaction is confirmed, an object with the following fields: + - `slot: ` - the slot this transaction was processed in + - `transaction: ` - [Transaction](#transaction-structure) object, either in JSON format or encoded binary data, depending on encoding parameter + - `blockTime: ` - estimated production time, as Unix timestamp (seconds since the Unix epoch) of when the transaction was processed. null if not available + - `meta: ` - transaction status metadata object: + - `err: ` - Error if transaction failed, null if transaction succeeded. [TransactionError definitions](https://docs.rs/solana-sdk/VERSION_FOR_DOCS_RS/solana_sdk/transaction/enum.TransactionError.html) + - `fee: ` - fee this transaction was charged, as u64 integer + - `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 + - `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 + - `"Ok": ` - Transaction was successful + - `"Err": ` - Transaction failed with TransactionError + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc": "2.0", + "id": 1, + "method": "getConfirmedTransaction", + "params": [ + "2nBhEBYYvfaAe16UMNqRHre4YNSskvuYgx3M6E4JP1oDYvZEJHvoPzyUidNgNX5r9sTyN1J9UxtbCXy2rqYcuyuv", + "base64" + ] + } +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": { + "meta": { + "err": null, + "fee": 5000, + "innerInstructions": [], + "postBalances": [499998932500, 26858640, 1, 1, 1], + "postTokenBalances": [], + "preBalances": [499998937500, 26858640, 1, 1, 1], + "preTokenBalances": [], + "status": { + "Ok": null + } + }, + "slot": 430, + "transaction": [ + "AVj7dxHlQ9IrvdYVIjuiRFs1jLaDMHixgrv+qtHBwz51L4/ImLZhszwiyEJDIp7xeBSpm/TX5B7mYzxa+fPOMw0BAAMFJMJVqLw+hJYheizSoYlLm53KzgT82cDVmazarqQKG2GQsLgiqktA+a+FDR4/7xnDX7rsusMwryYVUdixfz1B1Qan1RcZLwqvxvJl4/t3zHragsUp0L47E24tAFUgAAAABqfVFxjHdMkoVmOYaR1etoteuKObS21cc1VbIQAAAAAHYUgdNXR0u3xNdiTr072z2DVec9EQQ/wNo1OAAAAAAAtxOUhPBp2WSjUNJEgfvy70BbxI00fZyEPvFHNfxrtEAQQEAQIDADUCAAAAAQAAAAAAAACtAQAAAAAAAAdUE18R96XTJCe+YfRfUp6WP+YKCy/72ucOL8AoBFSpAA==", + "base64" + ] + }, + "id": 1 +} +``` + + + + diff --git a/docs/src/api/deprecated/_getFeeCalculatorForBlockhash.mdx b/docs/src/api/deprecated/_getFeeCalculatorForBlockhash.mdx new file mode 100644 index 00000000000000..66b0d954ee5581 --- /dev/null +++ b/docs/src/api/deprecated/_getFeeCalculatorForBlockhash.mdx @@ -0,0 +1,97 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getFeeCalculatorForBlockhash + +:::warning DEPRECATED +This method is expected to be removed in solana-core v2.0 +**Please use [isBlockhashValid](#isblockhashvalid) or [getFeeForMessage](#getfeeformessage) instead** +::: + +Returns the fee calculator associated with the query blockhash, or `null` if the blockhash has expired + + + + + +### Parameters: + + + query blockhash, as a base-58 encoded string + + + + +Configuration object containing the following fields: + + + + + The minimum slot that the request can be evaluated at + + + + +### Result: + +The result will be an RpcResponse JSON object with `value` equal to: + +- `` - if the query blockhash has expired; or +- `` - otherwise, a JSON object containing: + - `feeCalculator: ` - `FeeCalculator` object describing the cluster fee rate at the queried blockhash + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc": "2.0", + "id": 1, + "method": "getFeeCalculatorForBlockhash", + "params": [ + "GJxqhuxcgfn5Tcj6y3f8X4FeCDd2RQ6SnEMo1AAxrPRZ" + ] + } +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": { + "context": { + "slot": 221 + }, + "value": { + "feeCalculator": { + "lamportsPerSignature": 5000 + } + } + }, + "id": 1 +} +``` + + + + diff --git a/docs/src/api/deprecated/_getFeeRateGovernor.mdx b/docs/src/api/deprecated/_getFeeRateGovernor.mdx new file mode 100644 index 00000000000000..e7b87cda19b981 --- /dev/null +++ b/docs/src/api/deprecated/_getFeeRateGovernor.mdx @@ -0,0 +1,76 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getFeeRateGovernor + +:::warning DEPRECATED +This method is expected to be removed in solana-core v2.0 +::: + +Returns the fee rate governor information from the root bank + + + + + +### Parameters: + +**None** + +### Result: + +The result will be an RpcResponse JSON object with `value` equal to an `object` with the following fields: + +- `burnPercent: ` - Percentage of fees collected to be destroyed +- `maxLamportsPerSignature: ` - Largest value `lamportsPerSignature` can attain for the next slot +- `minLamportsPerSignature: ` - Smallest value `lamportsPerSignature` can attain for the next slot +- `targetLamportsPerSignature: ` - Desired fee rate for the cluster +- `targetSignaturesPerSlot: ` - Desired signature rate for the cluster + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + {"jsonrpc":"2.0","id":1, "method":"getFeeRateGovernor"} +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": { + "context": { + "slot": 54 + }, + "value": { + "feeRateGovernor": { + "burnPercent": 50, + "maxLamportsPerSignature": 100000, + "minLamportsPerSignature": 5000, + "targetLamportsPerSignature": 10000, + "targetSignaturesPerSlot": 20000 + } + } + }, + "id": 1 +} +``` + + + + diff --git a/docs/src/api/deprecated/_getFees.mdx b/docs/src/api/deprecated/_getFees.mdx new file mode 100644 index 00000000000000..62cd33745483ef --- /dev/null +++ b/docs/src/api/deprecated/_getFees.mdx @@ -0,0 +1,92 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getFees + +:::warning DEPRECATED +This method is expected to be removed in solana-core v2.0 +**Please use [getFeeForMessage](#getfeeformessage) instead** +::: + +Returns a recent block hash from the ledger, a fee schedule that can be used to +compute the cost of submitting a transaction using it, and the last slot in +which the blockhash will be valid. + + + + + +### Parameters: + + + Pubkey of account to query, as base-58 encoded string + + + + +Configuration object containing the following fields: + + + + + +### Result: + +The result will be an RpcResponse JSON object with `value` set to a JSON object with the following fields: + +- `blockhash: ` - a Hash as base-58 encoded string +- `feeCalculator: ` - FeeCalculator object, the fee schedule for this block hash +- `lastValidSlot: ` - DEPRECATED - this value is inaccurate and should not be relied upon +- `lastValidBlockHeight: ` - last [block height](../../terminology.md#block-height) at which the blockhash will be valid + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { "jsonrpc":"2.0", "id": 1, "method":"getFees"} +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": { + "context": { + "slot": 1 + }, + "value": { + "blockhash": "CSymwgTNX1j3E4qhKfJAUE41nBWEwXufoYryPbkde5RR", + "feeCalculator": { + "lamportsPerSignature": 5000 + }, + "lastValidSlot": 297, + "lastValidBlockHeight": 296 + } + }, + "id": 1 +} +``` + + + + diff --git a/docs/src/api/deprecated/_getRecentBlockhash.mdx b/docs/src/api/deprecated/_getRecentBlockhash.mdx new file mode 100644 index 00000000000000..456685c3ddf603 --- /dev/null +++ b/docs/src/api/deprecated/_getRecentBlockhash.mdx @@ -0,0 +1,87 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getRecentBlockhash + +:::warning DEPRECATED +This method is expected to be removed in solana-core v2.0 +**Please use [getLatestBlockhash](#getlatestblockhash) instead** +::: + +Returns a recent block hash from the ledger, and a fee schedule that can be used to compute the cost of submitting a transaction using it. + + + + + +### Parameters: + + + Pubkey of account to query, as base-58 encoded string + + + + +Configuration object containing the following fields: + + + + + +### Result: + +An RpcResponse containing a JSON object consisting of a string blockhash and FeeCalculator JSON object. + +- `RpcResponse` - RpcResponse JSON object with `value` field set to a JSON object including: +- `blockhash: ` - a Hash as base-58 encoded string +- `feeCalculator: ` - FeeCalculator object, the fee schedule for this block hash + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + {"jsonrpc":"2.0","id":1, "method":"getRecentBlockhash"} +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": { + "context": { + "slot": 1 + }, + "value": { + "blockhash": "CSymwgTNX1j3E4qhKfJAUE41nBWEwXufoYryPbkde5RR", + "feeCalculator": { + "lamportsPerSignature": 5000 + } + } + }, + "id": 1 +} +``` + + + + diff --git a/docs/src/api/deprecated/_getSnapshotSlot.mdx b/docs/src/api/deprecated/_getSnapshotSlot.mdx new file mode 100644 index 00000000000000..42ee186d5c3325 --- /dev/null +++ b/docs/src/api/deprecated/_getSnapshotSlot.mdx @@ -0,0 +1,64 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getSnapshotSlot + +:::warning DEPRECATED +This method is expected to be removed in solana-core v2.0 +**Please use [getHighestSnapshotSlot](#gethighestsnapshotslot) instead** +::: + +Returns the highest slot that the node has a snapshot for + + + + + +### Parameters: + +**None** + +### Result: + +`` - Snapshot slot + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + {"jsonrpc":"2.0","id":1, "method":"getSnapshotSlot"} +' +``` + +### Response: + +```json +{ "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 +} +``` + + + + diff --git a/docs/src/api/http.md b/docs/src/api/http.md new file mode 100644 index 00000000000000..63163fbfa4ccdf --- /dev/null +++ b/docs/src/api/http.md @@ -0,0 +1,419 @@ +--- +title: JSON RPC HTTP Methods +displayed_sidebar: apiHttpMethodsSidebar +hide_table_of_contents: true +--- + +Solana nodes accept HTTP requests using the [JSON-RPC 2.0](https://www.jsonrpc.org/specification) specification. + +:::info +For JavaScript applications, use the [@solana/web3.js](https://github.com/solana-labs/solana-web3.js) library as a convenient interface for the RPC methods to interact with a Solana node. + +For an PubSub connection to a Solana node, use the [Websocket API](./websocket.md). +::: + +## RPC HTTP Endpoint + +**Default port:** 8899 e.g. [http://localhost:8899](http://localhost:8899), [http://192.168.1.88:8899](http://192.168.1.88:8899) + +## 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: + +- `jsonrpc: ` - set to `"2.0"` +- `id: ` - a unique client-generated identifying integer +- `method: ` - a string containing the method to be invoked +- `params: ` - a JSON array of ordered parameter values + +Example using curl: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc": "2.0", + "id": 1, + "method": "getBalance", + "params": [ + "83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri" + ] + } +' +``` + +The response output will be a JSON object with the following fields: + +- `jsonrpc: ` - matching the request specification +- `id: ` - matching the request identifier +- `result: ` - requested data or success confirmation + +Requests can be sent in batches by sending an array of JSON-RPC request objects as the data for a single POST. + +## Definitions + +- Hash: A SHA-256 hash of a chunk of data. +- Pubkey: The public key of a Ed25519 key-pair. +- Transaction: A list of Solana instructions signed by a client keypair to authorize those actions. +- Signature: An Ed25519 signature of transaction's payload data including instructions. This can be used to identify transactions. + +## Configuring State Commitment + +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 +querying the ledger state, it's recommended to use lower levels of commitment +to report progress and higher levels to ensure the state will not be rolled back. + +In descending order of commitment (most finalized to least finalized), clients +may specify: + +- `"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 +- `"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. + +For processing many dependent transactions in series, it's recommended to use +`"confirmed"` commitment, which balances speed with rollback safety. +For total safety, it's recommended to use`"finalized"` commitment. + +#### Example + +The commitment parameter should be included as the last element in the `params` array: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc": "2.0", + "id": 1, + "method": "getBalance", + "params": [ + "83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri", + { + "commitment": "finalized" + } + ] + } +' +``` + +#### Default: + +If commitment configuration is not provided, the node will default to `"finalized"` commitment + +Only methods that query bank state accept the commitment parameter. They are indicated in the API Reference below. + +#### RpcResponse Structure + +Many methods that take a commitment parameter return an RpcResponse JSON object comprised of two parts: + +- `context` : An RpcResponseContext JSON structure including a `slot` field at which the operation was evaluated. +- `value` : The value returned by the operation itself. + +#### Parsed Responses + +Some methods support an `encoding` parameter, and can return account or +instruction data in parsed JSON format if `"encoding":"jsonParsed"` is requested +and the node has a parser for the owning program. Solana nodes currently support +JSON parsing for the following native and SPL programs: + +| Program | Account State | Instructions | +| ---------------------------- | ------------- | ------------ | +| Address Lookup | v1.15.0 | v1.15.0 | +| BPF Loader | n/a | stable | +| BPF Upgradeable Loader | stable | stable | +| Config | stable | | +| SPL Associated Token Account | n/a | stable | +| SPL Memo | n/a | stable | +| SPL Token | stable | stable | +| SPL Token 2022 | stable | stable | +| Stake | stable | stable | +| Vote | stable | stable | + +The list of account parsers can be found [here](https://github.com/solana-labs/solana/blob/master/account-decoder/src/parse_account_data.rs), and instruction parsers [here](https://github.com/solana-labs/solana/blob/master/transaction-status/src/parse_instruction.rs). + +## Filter criteria + +Some methods support providing a `filters` object to enable pre-filtering the data returned within the RpcResponse JSON object. The following filters exist: + +- `memcmp: object` - compares a provided series of bytes with program account data at a particular offset. Fields: + + - `offset: usize` - offset into program account data to start comparison + - `bytes: string` - data to match, as encoded string + - `encoding: string` - encoding for filter `bytes` data, either "base58" or "base64". Data is limited in size to 128 or fewer decoded bytes.
+ **NEW: This field, and base64 support generally, is only available in solana-core v1.14.0 or newer. Please omit when querying nodes on earlier versions** + +- `dataSize: u64` - compares the program account data length with the provided data size + +## Health Check + +Although not a JSON RPC API, a `GET /health` at the RPC HTTP Endpoint provides a +health-check mechanism for use by load balancers or other network +infrastructure. This request will always return a HTTP 200 OK response with a body of +"ok", "behind" or "unknown" based on the following conditions: + +1. 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 "behind". "unknown" is returned when no slot + information from known validators is not yet available. +2. "ok" is always returned if no known validators are provided. + +## JSON RPC API Reference + +import GetAccountInfo from "./methods/\_getAccountInfo.mdx" + + + +import GetBalance from "./methods/\_getBalance.mdx" + + + +import GetBlock from "./methods/\_getBlock.mdx" + + + +import GetBlockHeight from "./methods/\_getBlockHeight.mdx" + + + +import GetBlockProduction from "./methods/\_getBlockProduction.mdx" + + + +import GetBlockCommitment from "./methods/\_getBlockCommitment.mdx" + + + +import GetBlocks from "./methods/\_getBlocks.mdx" + + + +import GetBlocksWithLimit from "./methods/\_getBlocksWithLimit.mdx" + + + +import GetBlockTime from "./methods/\_getBlockTime.mdx" + + + +import GetClusterNodes from "./methods/\_getClusterNodes.mdx" + + + +import GetEpochInfo from "./methods/\_getEpochInfo.mdx" + + + +import GetEpochSchedule from "./methods/\_getEpochSchedule.mdx" + + + +import GetFeeForMessage from "./methods/\_getFeeForMessage.mdx" + + + +import GetFirstAvailableBlock from "./methods/\_getFirstAvailableBlock.mdx" + + + +import GetGenesisHash from "./methods/\_getGenesisHash.mdx" + + + +import GetHealth from "./methods/\_getHealth.mdx" + + + +import GetHighestSnapshotSlot from "./methods/\_getHighestSnapshotSlot.mdx" + + + +import GetIdentity from "./methods/\_getIdentity.mdx" + + + +import GetInflationGovernor from "./methods/\_getInflationGovernor.mdx" + + + +import GetInflationRate from "./methods/\_getInflationRate.mdx" + + + +import GetInflationReward from "./methods/\_getInflationReward.mdx" + + + +import GetLargestAccounts from "./methods/\_getLargestAccounts.mdx" + + + +import GetLatestBlockhash from "./methods/\_getLatestBlockhash.mdx" + + + +import GetLeaderSchedule from "./methods/\_getLeaderSchedule.mdx" + + + +import GetMaxRetransmitSlot from "./methods/\_getMaxRetransmitSlot.mdx" + + + +import GetMaxShredInsertSlot from "./methods/\_getMaxShredInsertSlot.mdx" + + + +import GetMinimumBalanceForRentExemption from "./methods/\_getMinimumBalanceForRentExemption.mdx" + + + +import GetMultipleAccounts from "./methods/\_getMultipleAccounts.mdx" + + + +import GetProgramAccounts from "./methods/\_getProgramAccounts.mdx" + + + +import GetRecentPerformanceSamples from "./methods/\_getRecentPerformanceSamples.mdx" + + + +import GetRecentPrioritizationFees from "./methods/\_getRecentPrioritizationFees.mdx" + + + +import GetSignaturesForAddress from "./methods/\_getSignaturesForAddress.mdx" + + + +import GetSignatureStatuses from "./methods/\_getSignatureStatuses.mdx" + + + +import GetSlot from "./methods/\_getSlot.mdx" + + + +import GetSlotLeader from "./methods/\_getSlotLeader.mdx" + + + +import GetSlotLeaders from "./methods/\_getSlotLeaders.mdx" + + + +import GetStakeActivation from "./methods/\_getStakeActivation.mdx" + + + +import GetStakeMinimumDelegation from "./methods/\_getStakeMinimumDelegation.mdx" + + + +import GetSupply from "./methods/\_getSupply.mdx" + + + +import GetTokenAccountBalance from "./methods/\_getTokenAccountBalance.mdx" + + + +import GetTokenAccountsByDelegate from "./methods/\_getTokenAccountsByDelegate.mdx" + + + +import GetTokenAccountsByOwner from "./methods/\_getTokenAccountsByOwner.mdx" + + + +import GetTokenLargestAccounts from "./methods/\_getTokenLargestAccounts.mdx" + + + +import GetTokenSupply from "./methods/\_getTokenSupply.mdx" + + + +import GetTransaction from "./methods/\_getTransaction.mdx" + + + +import GetTransactionCount from "./methods/\_getTransactionCount.mdx" + + + +import GetVersion from "./methods/\_getVersion.mdx" + + + +import GetVoteAccounts from "./methods/\_getVoteAccounts.mdx" + + + +import IsBlockhashValid from "./methods/\_isBlockhashValid.mdx" + + + +import MinimumLedgerSlot from "./methods/\_minimumLedgerSlot.mdx" + + + +import RequestAirdrop from "./methods/\_requestAirdrop.mdx" + + + +import SendTransaction from "./methods/\_sendTransaction.mdx" + + + +import SimulateTransaction from "./methods/\_simulateTransaction.mdx" + + + +## JSON RPC API Deprecated Methods + +import GetConfirmedBlock from "./deprecated/\_getConfirmedBlock.mdx" + + + +import GetConfirmedBlocks from "./deprecated/\_getConfirmedBlocks.mdx" + + + +import GetConfirmedBlocksWithLimit from "./deprecated/\_getConfirmedBlocksWithLimit.mdx" + + + +import GetConfirmedSignaturesForAddress2 from "./deprecated/\_getConfirmedSignaturesForAddress2.mdx" + + + +import GetConfirmedTransaction from "./deprecated/\_getConfirmedTransaction.mdx" + + + +import GetFeeCalculatorForBlockhash from "./deprecated/\_getFeeCalculatorForBlockhash.mdx" + + + +import GetFeeRateGovernor from "./deprecated/\_getFeeRateGovernor.mdx" + + + +import GetFees from "./deprecated/\_getFees.mdx" + + + +import GetRecentBlockhash from "./deprecated/\_getRecentBlockhash.mdx" + + + +import GetSnapshotSlot from "./deprecated/\_getSnapshotSlot.mdx" + + diff --git a/docs/src/api/methods/_getAccountInfo.mdx b/docs/src/api/methods/_getAccountInfo.mdx new file mode 100644 index 00000000000000..18a5080758de4a --- /dev/null +++ b/docs/src/api/methods/_getAccountInfo.mdx @@ -0,0 +1,136 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getAccountInfo + +Returns all information associated with the account of provided Pubkey + + + + + +### Parameters: + + + Pubkey of account to query, as base-58 encoded string + + + + +Configuration object containing the following fields: + + + + + +Encoding format for Account data + + + +
+ +- `base58` is slow and limited to less than 129 bytes of Account data. +- `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 `string`. + +
+ +
+ + + limit the returned account data using the provided "offset: <usize>" and + "length: <usize>" fields +
  • + only available for base58, base64 or{" "} + base64+zstd encodings. +
  • +
    + + + The minimum slot that the request can be evaluated at + + +
    + +### Result: + +The result will be an RpcResponse JSON object with `value` equal to: + +- `` - if the requested account doesn't exist +- `` - otherwise, a JSON object containing: + - `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 + - `size: ` - the data size of the account + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc": "2.0", + "id": 1, + "method": "getAccountInfo", + "params": [ + "vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg", + { + "encoding": "base58" + } + ] + } +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": { + "context": { + "slot": 1 + }, + "value": { + "data": [ + "11116bv5nS2h3y12kD1yUKeMZvGcKLSjQgX6BeV7u1FrjeJcKfsHRTPuR3oZ1EioKtYGiYxpxMG5vpbZLsbcBYBEmZZcMKaSoGx9JZeAuWf", + "base58" + ], + "executable": false, + "lamports": 1000000000, + "owner": "11111111111111111111111111111111", + "rentEpoch": 2, + "space": 80 + } + }, + "id": 1 +} +``` + + + + diff --git a/docs/src/api/methods/_getBalance.mdx b/docs/src/api/methods/_getBalance.mdx new file mode 100644 index 00000000000000..0cd0f0c6d0ef23 --- /dev/null +++ b/docs/src/api/methods/_getBalance.mdx @@ -0,0 +1,78 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getBalance + +Returns the balance of the account of provided Pubkey + + + + + +### Parameters: + + + Pubkey of account to query, as base-58 encoded string + + + + +Configuration object containing the following fields: + + + + + The minimum slot that the request can be evaluated at + + + + +### Result: + +`RpcResponse` - RpcResponse JSON object with `value` field set to the balance + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc": "2.0", "id": 1, + "method": "getBalance", + "params": [ + "83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri" + ] + } +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": { "context": { "slot": 1 }, "value": 0 }, + "id": 1 +} +``` + + + + diff --git a/docs/src/api/methods/_getBlock.mdx b/docs/src/api/methods/_getBlock.mdx new file mode 100644 index 00000000000000..dd70eaf5b95347 --- /dev/null +++ b/docs/src/api/methods/_getBlock.mdx @@ -0,0 +1,288 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getBlock + +Returns identity and transaction information about a confirmed block in the ledger + + + + + +### Parameters: + + + slot number, as u64 integer + + + + +Configuration object containing the following fields: + + +
  • + the default is finalized +
  • +
  • + processed is not supported. +
  • +
    + + + +encoding format for each returned Transaction + + + +
    + +- `jsonParsed` 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). + +
    + +
    + + + +level of transaction detail to return + + + +
    + +- If `accounts` are requested, transaction details only include signatures and + an annotated list of accounts in each transaction. +- Transaction metadata is limited to only: fee, err, pre_balances, + post_balances, pre_token_balances, and post_token_balances. + +
    + +
    + + + +the max transaction version to return in responses. + +
    + +- If the requested block contains a transaction with a higher version, an + error will be returned. +- If this parameter is omitted, only legacy transactions will be returned, and + a block containing any versioned transaction will prompt the error. + +
    + +
    + + + whether to populate the `rewards` array. If parameter not provided, the + default includes rewards. + + +
    + +### Result: + +The result field will be an object with the following fields: + +- `` - if specified block is not confirmed +- `` - if block is confirmed, an object with the following fields: + - `blockhash: ` - the blockhash of this block, as base-58 encoded string + - `previousBlockhash: ` - the blockhash of this block's parent, as base-58 encoded string; if the parent block is not available due to ledger cleanup, this field will return "11111111111111111111111111111111" + - `parentSlot: ` - the slot index of this block's parent + - `transactions: ` - present if "full" transaction details are requested; an array of JSON objects containing: + - `transaction: ` - [Transaction](#transaction-structure) object, either in JSON format or encoded binary data, depending on encoding parameter + - `meta: ` - transaction status metadata object, containing `null` or: + - `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) + - `fee: ` - fee this transaction was charged, as u64 integer + - `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 + - `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 + - `rewards: ` - transaction-level rewards, populated if rewards are requested; an array of JSON objects containing: + - `pubkey: ` - The public key, as base-58 encoded string, of the account that received the reward + - `lamports: `- number of reward lamports credited or debited by the account, as a i64 + - `postBalance: ` - account balance in lamports after the reward was applied + - `rewardType: ` - type of reward: "fee", "rent", "voting", "staking" + - `commission: ` - vote account commission when the reward was credited, only present for voting and staking rewards + - DEPRECATED: `status: ` - Transaction status + - `"Ok": ` - Transaction was successful + - `"Err": ` - Transaction failed with TransactionError + - `loadedAddresses: ` - Transaction addresses loaded from address lookup tables. Undefined if `maxSupportedTransactionVersion` is not set in request params. + - `writable: ` - Ordered list of base-58 encoded addresses for writable loaded accounts + - `readonly: ` - Ordered list of base-58 encoded addresses for readonly loaded accounts + - `returnData: ` - the most-recent return data generated by an instruction in the transaction, with the following fields: + - `programId: ` - the program that generated the return data, as base-58 encoded Pubkey + - `data: <[string, encoding]>` - the return data itself, as base-64 encoded binary data + - `computeUnitsConsumed: ` - number of [compute units](developing/programming-model/runtime.md#compute-budget) consumed by the transaction + - `version: <"legacy"|number|undefined>` - Transaction version. Undefined if `maxSupportedTransactionVersion` is not set in request params. + - `signatures: ` - present if "signatures" are requested for transaction details; an array of signatures strings, corresponding to the transaction order in the block + - `rewards: ` - block-level rewards, present if rewards are requested; an array of JSON objects containing: + - `pubkey: ` - The public key, as base-58 encoded string, of the account that received the reward + - `lamports: `- number of reward lamports credited or debited by the account, as a i64 + - `postBalance: ` - account balance in lamports after the reward was applied + - `rewardType: ` - type of reward: "fee", "rent", "voting", "staking" + - `commission: ` - vote account commission when the reward was credited, only present for voting and staking rewards + - `blockTime: ` - estimated production time, as Unix timestamp (seconds since the Unix epoch). null if not available + - `blockHeight: ` - the number of blocks beneath this block + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc": "2.0","id":1, + "method":"getBlock", + "params": [ + 430, + { + "encoding": "json", + "maxSupportedTransactionVersion":0, + "transactionDetails":"full", + "rewards":false + } + ] + } +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": { + "blockHeight": 428, + "blockTime": null, + "blockhash": "3Eq21vXNB5s86c62bVuUfTeaMif1N2kUqRPBmGRJhyTA", + "parentSlot": 429, + "previousBlockhash": "mfcyqEXB3DnHXki6KjjmZck6YjmZLvpAByy2fj4nh6B", + "transactions": [ + { + "meta": { + "err": null, + "fee": 5000, + "innerInstructions": [], + "logMessages": [], + "postBalances": [499998932500, 26858640, 1, 1, 1], + "postTokenBalances": [], + "preBalances": [499998937500, 26858640, 1, 1, 1], + "preTokenBalances": [], + "rewards": null, + "status": { + "Ok": null + } + }, + "transaction": { + "message": { + "accountKeys": [ + "3UVYmECPPMZSCqWKfENfuoTv51fTDTWicX9xmBD2euKe", + "AjozzgE83A3x1sHNUR64hfH7zaEBWeMaFuAN9kQgujrc", + "SysvarS1otHashes111111111111111111111111111", + "SysvarC1ock11111111111111111111111111111111", + "Vote111111111111111111111111111111111111111" + ], + "header": { + "numReadonlySignedAccounts": 0, + "numReadonlyUnsignedAccounts": 3, + "numRequiredSignatures": 1 + }, + "instructions": [ + { + "accounts": [1, 2, 3, 0], + "data": "37u9WtQpcm6ULa3WRQHmj49EPs4if7o9f1jSRVZpm2dvihR9C8jY4NqEwXUbLwx15HBSNcP1", + "programIdIndex": 4 + } + ], + "recentBlockhash": "mfcyqEXB3DnHXki6KjjmZck6YjmZLvpAByy2fj4nh6B" + }, + "signatures": [ + "2nBhEBYYvfaAe16UMNqRHre4YNSskvuYgx3M6E4JP1oDYvZEJHvoPzyUidNgNX5r9sTyN1J9UxtbCXy2rqYcuyuv" + ] + } + } + ] + }, + "id": 1 +} +``` + + + + +--- + +#### Transaction Structure + +Transactions are quite different from those on other blockchains. Be sure to review [Anatomy of a Transaction](developing/programming-model/transactions.md) to learn about transactions on Solana. + +The JSON structure of a transaction is defined as follows: + +- `signatures: ` - A list of base-58 encoded signatures applied to the transaction. The list is always of length `message.header.numRequiredSignatures` and not empty. The signature at index `i` corresponds to the public key at index `i` in `message.accountKeys`. The first one is used as the [transaction id](../../terminology.md#transaction-id). +- `message: ` - Defines the content of the transaction. + - `accountKeys: ` - List of base-58 encoded public keys used by the transaction, including by the instructions and for signatures. The first `message.header.numRequiredSignatures` public keys must sign the transaction. + - `header: ` - Details the account types and signatures required by the transaction. + - `numRequiredSignatures: ` - The total number of signatures required to make the transaction valid. The signatures must match the first `numRequiredSignatures` of `message.accountKeys`. + - `numReadonlySignedAccounts: ` - The last `numReadonlySignedAccounts` of the signed keys are read-only accounts. Programs may process multiple transactions that load read-only accounts within a single PoH entry, but are not permitted to credit or debit lamports or modify account data. Transactions targeting the same read-write account are evaluated sequentially. + - `numReadonlyUnsignedAccounts: ` - The last `numReadonlyUnsignedAccounts` of the unsigned keys are read-only accounts. + - `recentBlockhash: ` - A base-58 encoded hash of a recent block in the ledger used to prevent transaction duplication and to give transactions lifetimes. + - `instructions: ` - List of program instructions that will be executed in sequence and committed in one atomic transaction if all succeed. + - `programIdIndex: ` - Index into the `message.accountKeys` array indicating the program account that executes this instruction. + - `accounts: ` - List of ordered indices into the `message.accountKeys` array indicating which accounts to pass to the program. + - `data: ` - The program input data encoded in a base-58 string. + - `addressTableLookups: ` - List of address table lookups used by a transaction to dynamically load addresses from on-chain address lookup tables. Undefined if `maxSupportedTransactionVersion` is not set. + - `accountKey: ` - base-58 encoded public key for an address lookup table account. + - `writableIndexes: ` - List of indices used to load addresses of writable accounts from a lookup table. + - `readonlyIndexes: ` - List of indices used to load addresses of readonly accounts from a lookup table. + +#### Inner Instructions Structure + +The Solana runtime records the cross-program instructions that are invoked during transaction processing and makes these available for greater transparency of what was executed on-chain per transaction instruction. Invoked instructions are grouped by the originating transaction instruction and are listed in order of processing. + +The JSON structure of inner instructions is defined as a list of objects in the following structure: + +- `index: number` - Index of the transaction instruction from which the inner instruction(s) originated +- `instructions: ` - Ordered list of inner program instructions that were invoked during a single transaction instruction. + - `programIdIndex: ` - Index into the `message.accountKeys` array indicating the program account that executes this instruction. + - `accounts: ` - List of ordered indices into the `message.accountKeys` array indicating which accounts to pass to the program. + - `data: ` - The program input data encoded in a base-58 string. + +#### Token Balances Structure + +The JSON structure of token balances is defined as a list of objects in the following structure: + +- `accountIndex: ` - Index of the account in which the token balance is provided for. +- `mint: ` - Pubkey of the token's mint. +- `owner: ` - Pubkey of token balance's owner. +- `programId: ` - Pubkey of the Token program that owns the account. +- `uiTokenAmount: ` - + - `amount: ` - Raw amount of tokens as a string, ignoring decimals. + - `decimals: ` - Number of decimals configured for token's mint. + - `uiAmount: ` - Token amount as a float, accounting for decimals. **DEPRECATED** + - `uiAmountString: ` - Token amount as a string, accounting for decimals. + + diff --git a/docs/src/api/methods/_getBlockCommitment.mdx b/docs/src/api/methods/_getBlockCommitment.mdx new file mode 100644 index 00000000000000..c12fc186cfca4b --- /dev/null +++ b/docs/src/api/methods/_getBlockCommitment.mdx @@ -0,0 +1,70 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getBlockCommitment + +Returns commitment for particular block + + + + + +### Parameters: + + + block number, identified by Slot + + +### Result: + +The result field will be a JSON object containing: + +- `commitment` - commitment, comprising either: + - `` - Unknown block + - `` - commitment, array of u64 integers logging the amount of cluster stake in lamports that has voted on the block at each depth from 0 to `MAX_LOCKOUT_HISTORY` + 1 +- `totalStake` - total active stake, in lamports, of the current epoch + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc": "2.0", "id": 1, + "method": "getBlockCommitment", + "params":[5] + } +' +``` + +### Response: + +```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 + ], + "totalStake": 42 + }, + "id": 1 +} +``` + + + + diff --git a/docs/src/api/methods/_getBlockHeight.mdx b/docs/src/api/methods/_getBlockHeight.mdx new file mode 100644 index 00000000000000..9b8a07d0fd6a2b --- /dev/null +++ b/docs/src/api/methods/_getBlockHeight.mdx @@ -0,0 +1,73 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getBlockHeight + +Returns the current block height of the node + + + + + +### Parameters: + + + +Configuration object containing the following fields: + + + + + The minimum slot that the request can be evaluated at + + + + +### Result: + +- `` - Current block height + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc":"2.0","id":1, + "method":"getBlockHeight" + } +' +``` + +Result: + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": 1233, + "id": 1 +} +``` + + + + diff --git a/docs/src/api/methods/_getBlockProduction.mdx b/docs/src/api/methods/_getBlockProduction.mdx new file mode 100644 index 00000000000000..eed1b5e6fbd3b2 --- /dev/null +++ b/docs/src/api/methods/_getBlockProduction.mdx @@ -0,0 +1,97 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getBlockProduction + +Returns recent block production information from the current or previous epoch. + + + + + +### Parameters: + + + +Configuration object containing the following fields: + + + + + Only return results for this validator identity (base-58 encoded) + + + +Slot range to return block production for. If parameter not provided, defaults to current epoch. + +- `firstSlot: ` - first slot to return block production information for (inclusive) +- (optional) `lastSlot: ` - last slot to return block production information for (inclusive). If parameter not provided, defaults to the highest slot + + + + + +### Result: + +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 + number of leader slots and the number of blocks produced. + - `range: ` - Block production slot range + - `firstSlot: ` - first slot of the block production information (inclusive) + - `lastSlot: ` - last slot of block production information (inclusive) + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + {"jsonrpc":"2.0","id":1, "method":"getBlockProduction"} +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": { + "context": { + "slot": 9887 + }, + "value": { + "byIdentity": { + "85iYT5RuzRTDgjyRa3cP8SYhM2j21fj7NhfJ3peu1DPr": [9888, 9886] + }, + "range": { + "firstSlot": 0, + "lastSlot": 9887 + } + } + }, + "id": 1 +} +``` + + + + diff --git a/docs/src/api/methods/_getBlockTime.mdx b/docs/src/api/methods/_getBlockTime.mdx new file mode 100644 index 00000000000000..50ef1de6fb4699 --- /dev/null +++ b/docs/src/api/methods/_getBlockTime.mdx @@ -0,0 +1,67 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getBlockTime + +Returns the estimated production time of a block. + +:::info +Each validator reports their UTC time to the ledger on a regular interval by +intermittently adding a timestamp to a Vote for a particular block. A requested +block's time is calculated from the stake-weighted mean of the Vote timestamps +in a set of recent blocks recorded on the ledger. +::: + + + + + +### Parameters: + + + block number, identified by Slot + + +### Result: + +- `` - estimated production time, as Unix timestamp (seconds since the Unix epoch) +- `` - timestamp is not available for this block + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc":"2.0", "id":1, + "method": "getBlockTime", + "params":[5] + } +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": 1574721591, + "id": 1 +} +``` + + + + diff --git a/docs/src/api/methods/_getBlocks.mdx b/docs/src/api/methods/_getBlocks.mdx new file mode 100644 index 00000000000000..59e816d6e1af26 --- /dev/null +++ b/docs/src/api/methods/_getBlocks.mdx @@ -0,0 +1,86 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getBlocks + +Returns a list of confirmed blocks between two slots + + + + + +### Parameters: + + + end_slot, as u64 integer + + + + start_slot, as u64 integer (must be no more than 500,000 blocks + higher than the `start_slot`) + + + + +Configuration object containing the following fields: + + + +- "processed" is not supported + + + + + +### Result: + +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. + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc": "2.0", "id": 1, + "method": "getBlocks", + "params": [ + 5, 10 + ] + } +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": [5, 6, 7, 8, 9, 10], + "id": 1 +} +``` + + + + diff --git a/docs/src/api/methods/_getBlocksWithLimit.mdx b/docs/src/api/methods/_getBlocksWithLimit.mdx new file mode 100644 index 00000000000000..6080a027c5926a --- /dev/null +++ b/docs/src/api/methods/_getBlocksWithLimit.mdx @@ -0,0 +1,84 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getBlocksWithLimit + +Returns a list of confirmed blocks starting at the given slot + + + + + +### Parameters: + + + start_slot, as u64 integer + + + + limit, as u64 integer (must be no more than 500,000 blocks higher + than the start_slot) + + + + +Configuration object containing the following field: + + + +- "processed" is not supported + + + + + +### Result: + +The result field will be an array of u64 integers listing confirmed blocks +starting at `start_slot` for up to `limit` blocks, inclusive. + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc": "2.0", + "id":1, + "method":"getBlocksWithLimit", + "params":[5, 3] + } +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": [5, 6, 7], + "id": 1 +} +``` + + + + diff --git a/docs/src/api/methods/_getClusterNodes.mdx b/docs/src/api/methods/_getClusterNodes.mdx new file mode 100644 index 00000000000000..735e3aff27fc8e --- /dev/null +++ b/docs/src/api/methods/_getClusterNodes.mdx @@ -0,0 +1,71 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getClusterNodes + +Returns information about all the nodes participating in the cluster + + + + +### Parameters: + +**None** + +### Result: + +The result field will be an array of JSON objects, each with the following sub fields: + +- `pubkey: ` - Node public key, as base-58 encoded string +- `gossip: ` - Gossip network address for the node +- `tpu: ` - TPU network address for the node +- `rpc: ` - JSON RPC network address for the node, or `null` if the JSON RPC service is not enabled +- `version: ` - The software version of the node, or `null` if the version information is not available +- `featureSet: ` - The unique identifier of the node's feature set +- `shredVersion: ` - The shred version the node has been configured to use + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc": "2.0", "id": 1, + "method": "getClusterNodes" + } +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": [ + { + "gossip": "10.239.6.48:8001", + "pubkey": "9QzsJf7LPLj8GkXbYT3LFDKqsj2hHG7TA3xinJHu8epQ", + "rpc": "10.239.6.48:8899", + "tpu": "10.239.6.48:8856", + "version": "1.0.0 c375ce1f" + } + ], + "id": 1 +} +``` + + + + diff --git a/docs/src/api/methods/_getEpochInfo.mdx b/docs/src/api/methods/_getEpochInfo.mdx new file mode 100644 index 00000000000000..1f2cb4939a947e --- /dev/null +++ b/docs/src/api/methods/_getEpochInfo.mdx @@ -0,0 +1,85 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getEpochInfo + +Returns information about the current epoch + + + + + +### Parameters: + + + Pubkey of account to query, as base-58 encoded string + + + + +Configuration object containing the following fields: + + + + + The minimum slot that the request can be evaluated at + + + + +### Result: + +The result field will be an object with the following fields: + +- `absoluteSlot: ` - the current slot +- `blockHeight: ` - the current block height +- `epoch: ` - the current epoch +- `slotIndex: ` - the current slot relative to the start of the current epoch +- `slotsInEpoch: ` - the number of slots in this epoch +- `transactionCount: ` - total number of transactions processed without error since genesis + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + {"jsonrpc":"2.0","id":1, "method":"getEpochInfo"} +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": { + "absoluteSlot": 166598, + "blockHeight": 166500, + "epoch": 27, + "slotIndex": 2790, + "slotsInEpoch": 8192, + "transactionCount": 22661093 + }, + "id": 1 +} +``` + + + + diff --git a/docs/src/api/methods/_getEpochSchedule.mdx b/docs/src/api/methods/_getEpochSchedule.mdx new file mode 100644 index 00000000000000..2e11e8a4be0d93 --- /dev/null +++ b/docs/src/api/methods/_getEpochSchedule.mdx @@ -0,0 +1,67 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getEpochSchedule + +Returns the epoch schedule information from this cluster's genesis config + + + + +### Parameters: + +**None** + +### Result: + +The result field will be an object with the following fields: + +- `slotsPerEpoch: ` - the maximum number of slots in each epoch +- `leaderScheduleSlotOffset: ` - the number of slots before beginning of an epoch to calculate a leader schedule for that epoch +- `warmup: ` - whether epochs start short and grow +- `firstNormalEpoch: ` - first normal-length epoch, log2(slotsPerEpoch) - log2(MINIMUM_SLOTS_PER_EPOCH) +- `firstNormalSlot: ` - MINIMUM_SLOTS_PER_EPOCH \* (2.pow(firstNormalEpoch) - 1) + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc":"2.0","id":1, + "method":"getEpochSchedule" + } +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": { + "firstNormalEpoch": 8, + "firstNormalSlot": 8160, + "leaderScheduleSlotOffset": 8192, + "slotsPerEpoch": 8192, + "warmup": true + }, + "id": 1 +} +``` + + + + diff --git a/docs/src/api/methods/_getFeeForMessage.mdx b/docs/src/api/methods/_getFeeForMessage.mdx new file mode 100644 index 00000000000000..85a81f589b0fc9 --- /dev/null +++ b/docs/src/api/methods/_getFeeForMessage.mdx @@ -0,0 +1,86 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getFeeForMessage + +Get the fee the network will charge for a particular Message + +:::caution +**NEW: This method is only available in solana-core v1.9 or newer. Please use +[getFees](#getFees) for solana-core v1.8** +::: + + + + +### Parameters: + + + Base-64 encoded Message + + + + +Configuration object containing the following fields: + + + + + The minimum slot that the request can be evaluated at + + + + +### Result: + +- `` - Fee corresponding to the message at the specified blockhash + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' +{ + "id":1, + "jsonrpc":"2.0", + "method":"getFeeForMessage", + "params":[ + "AQABAgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQAA", + { + "commitment":"processed" + } + ] +} +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": { "context": { "slot": 5068 }, "value": 5000 }, + "id": 1 +} +``` + + + + diff --git a/docs/src/api/methods/_getFirstAvailableBlock.mdx b/docs/src/api/methods/_getFirstAvailableBlock.mdx new file mode 100644 index 00000000000000..97139e17b5bf60 --- /dev/null +++ b/docs/src/api/methods/_getFirstAvailableBlock.mdx @@ -0,0 +1,50 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getFirstAvailableBlock + +Returns the slot of the lowest confirmed block that has not been purged from the ledger + + + + +### Parameters: + +**None** + +### Result: + +- `` - Slot + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc":"2.0","id":1, + "method":"getFirstAvailableBlock" + } +' +``` + +### Response: + +```json +{ "jsonrpc": "2.0", "result": 250000, "id": 1 } +``` + + + + diff --git a/docs/src/api/methods/_getGenesisHash.mdx b/docs/src/api/methods/_getGenesisHash.mdx new file mode 100644 index 00000000000000..4a7802d8b1b266 --- /dev/null +++ b/docs/src/api/methods/_getGenesisHash.mdx @@ -0,0 +1,51 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getGenesisHash + +Returns the genesis hash + + + + +### Parameters: + +**None** + +### Result: + +- `` - a Hash as base-58 encoded string + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + {"jsonrpc":"2.0","id":1, "method":"getGenesisHash"} +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": "GH7ome3EiwEr7tu9JuTh2dpYWBJK3z69Xm1ZE3MEE6JC", + "id": 1 +} +``` + + + + diff --git a/docs/src/api/methods/_getHealth.mdx b/docs/src/api/methods/_getHealth.mdx new file mode 100644 index 00000000000000..482a2ff62a076e --- /dev/null +++ b/docs/src/api/methods/_getHealth.mdx @@ -0,0 +1,88 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getHealth + +Returns the current health of the node. + +:::caution +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 provided. +::: + + + + +### Parameters: + +**None** + +### Result: + +If the node is healthy: "ok" + +If the node is unhealthy, a JSON RPC error response is returned. The specifics of the error response are **UNSTABLE** and may change in the future + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + {"jsonrpc":"2.0","id":1, "method":"getHealth"} +' +``` + +### Response: + +Healthy Result: + +```json +{ "jsonrpc": "2.0", "result": "ok", "id": 1 } +``` + +Unhealthy Result (generic): + +```json +{ + "jsonrpc": "2.0", + "error": { + "code": -32005, + "message": "Node is unhealthy", + "data": {} + }, + "id": 1 +} +``` + +Unhealthy Result (if additional information is available) + +```json +{ + "jsonrpc": "2.0", + "error": { + "code": -32005, + "message": "Node is behind by 42 slots", + "data": { + "numSlotsBehind": 42 + } + }, + "id": 1 +} +``` + + + + diff --git a/docs/src/api/methods/_getHighestSnapshotSlot.mdx b/docs/src/api/methods/_getHighestSnapshotSlot.mdx new file mode 100644 index 00000000000000..5028f77e6feeca --- /dev/null +++ b/docs/src/api/methods/_getHighestSnapshotSlot.mdx @@ -0,0 +1,78 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getHighestSnapshotSlot + +Returns the highest slot information that the node has snapshots for. + +This will find the highest full snapshot slot, and the highest incremental +snapshot slot _based on_ the full snapshot slot, if there is one. + +:::caution +NEW: This method is only available in solana-core v1.9 or newer. Please use +[getSnapshotSlot](/api/http#getsnapshotslot) for solana-core v1.8 +::: + + + + +### Parameters: + +**None** + +### Result: + +When the node has a snapshot, this returns a JSON object with the following fields: + +- `full: ` - Highest full snapshot slot +- `incremental: ` - Highest incremental snapshot slot _based on_ `full` + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + {"jsonrpc":"2.0","id":1,"method":"getHighestSnapshotSlot"} +' +``` + +### Response: + +Result when the node has a snapshot: + +```json +{ + "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 +} +``` + + + + diff --git a/docs/src/api/methods/_getIdentity.mdx b/docs/src/api/methods/_getIdentity.mdx new file mode 100644 index 00000000000000..263ebb28d7f824 --- /dev/null +++ b/docs/src/api/methods/_getIdentity.mdx @@ -0,0 +1,55 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getIdentity + +Returns the identity pubkey for the current node + + + + +### Parameters: + +**None** + +### Result: + +The result field will be a JSON object with the following fields: + +- `identity` - the identity pubkey of the current node \(as a base-58 encoded string\) + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + {"jsonrpc":"2.0","id":1, "method":"getIdentity"} +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": { + "identity": "2r1F4iWqVcb8M1DbAjQuFpebkQHY9hcVU4WuW2DJBppN" + }, + "id": 1 +} +``` + + + + diff --git a/docs/src/api/methods/_getInflationGovernor.mdx b/docs/src/api/methods/_getInflationGovernor.mdx new file mode 100644 index 00000000000000..206fa9a60c498a --- /dev/null +++ b/docs/src/api/methods/_getInflationGovernor.mdx @@ -0,0 +1,75 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getInflationGovernor + +Returns the current inflation governor + + + + +### Parameters: + + + +Configuration object containing the following fields: + + + + + +### Result: + +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) +- `foundation: ` - percentage of total inflation allocated to the foundation +- `foundationTerm: ` - duration of foundation pool inflation in years + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + {"jsonrpc":"2.0","id":1, "method":"getInflationGovernor"} +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": { + "foundation": 0.05, + "foundationTerm": 7, + "initial": 0.15, + "taper": 0.15, + "terminal": 0.015 + }, + "id": 1 +} +``` + + + + diff --git a/docs/src/api/methods/_getInflationRate.mdx b/docs/src/api/methods/_getInflationRate.mdx new file mode 100644 index 00000000000000..1cc987aab13c1c --- /dev/null +++ b/docs/src/api/methods/_getInflationRate.mdx @@ -0,0 +1,62 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getInflationRate + +Returns the specific inflation values for the current epoch + + + + +### Parameters: + +**None** + +### Result: + +The result field will be a JSON object with the following fields: + +- `total: ` - total inflation +- `validator: ` -inflation allocated to validators +- `foundation: ` - inflation allocated to the foundation +- `epoch: ` - epoch for which these values are valid + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + {"jsonrpc":"2.0","id":1, "method":"getInflationRate"} +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": { + "epoch": 100, + "foundation": 0.001, + "total": 0.149, + "validator": 0.148 + }, + "id": 1 +} +``` + + + + diff --git a/docs/src/api/methods/_getInflationReward.mdx b/docs/src/api/methods/_getInflationReward.mdx new file mode 100644 index 00000000000000..840a6f520fa34c --- /dev/null +++ b/docs/src/api/methods/_getInflationReward.mdx @@ -0,0 +1,101 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getInflationReward + +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 + + + + +Configuration object containing the following fields: + + + + + An epoch for which the reward occurs. If omitted, the previous epoch will be + used + + + + The minimum slot that the request can be evaluated at + + + + +### Result: + +The result field will be a JSON array with the following fields: + +- `epoch: ` - epoch for which reward occured +- `effectiveSlot: ` - the slot in which the rewards are effective +- `amount: ` - reward amount in lamports +- `postBalance: ` - post balance of the account in lamports +- `commission: ` - vote account commission when the reward was credited + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc": "2.0", + "id": 1, + "method": "getInflationReward", + "params": [ + [ + "6dmNQ5jwLeLk5REvio1JcMshcbvkYMwy26sJ8pbkvStu", + "BGsqMegLpV6n6Ve146sSX2dTjUMj3M92HnU8BbNRMhF2" + ], + {"epoch": 2} + ] + } +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": [ + { + "amount": 2500, + "effectiveSlot": 224, + "epoch": 2, + "postBalance": 499999442500 + }, + null + ], + "id": 1 +} +``` + + + + diff --git a/docs/src/api/methods/_getLargestAccounts.mdx b/docs/src/api/methods/_getLargestAccounts.mdx new file mode 100644 index 00000000000000..aef3e9f8202c57 --- /dev/null +++ b/docs/src/api/methods/_getLargestAccounts.mdx @@ -0,0 +1,150 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getLargestAccounts + +Returns the 20 largest accounts, by lamport balance (results may be cached up to two hours) + + + + +### Parameters: + + + +Configuration object containing the following fields: + + + + + filter results by account type + + + + + + +### Result: + +The result will be an RpcResponse JSON object with `value` equal to an array of `` containing: + +- `address: ` - base-58 encoded address of the account +- `lamports: ` - number of lamports in the account, as a u64 + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + {"jsonrpc":"2.0","id":1, "method":"getLargestAccounts"} +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": { + "context": { + "slot": 54 + }, + "value": [ + { + "lamports": 999974, + "address": "99P8ZgtJYe1buSK8JXkvpLh8xPsCFuLYhz9hQFNw93WJ" + }, + { + "lamports": 42, + "address": "uPwWLo16MVehpyWqsLkK3Ka8nLowWvAHbBChqv2FZeL" + }, + { + "lamports": 42, + "address": "aYJCgU7REfu3XF8b3QhkqgqQvLizx8zxuLBHA25PzDS" + }, + { + "lamports": 42, + "address": "CTvHVtQ4gd4gUcw3bdVgZJJqApXE9nCbbbP4VTS5wE1D" + }, + { + "lamports": 20, + "address": "4fq3xJ6kfrh9RkJQsmVd5gNMvJbuSHfErywvEjNQDPxu" + }, + { + "lamports": 4, + "address": "AXJADheGVp9cruP8WYu46oNkRbeASngN5fPCMVGQqNHa" + }, + { + "lamports": 2, + "address": "8NT8yS6LiwNprgW4yM1jPPow7CwRUotddBVkrkWgYp24" + }, + { + "lamports": 1, + "address": "SysvarEpochSchedu1e111111111111111111111111" + }, + { + "lamports": 1, + "address": "11111111111111111111111111111111" + }, + { + "lamports": 1, + "address": "Stake11111111111111111111111111111111111111" + }, + { + "lamports": 1, + "address": "SysvarC1ock11111111111111111111111111111111" + }, + { + "lamports": 1, + "address": "StakeConfig11111111111111111111111111111111" + }, + { + "lamports": 1, + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "lamports": 1, + "address": "Config1111111111111111111111111111111111111" + }, + { + "lamports": 1, + "address": "SysvarStakeHistory1111111111111111111111111" + }, + { + "lamports": 1, + "address": "SysvarRecentB1ockHashes11111111111111111111" + }, + { + "lamports": 1, + "address": "SysvarFees111111111111111111111111111111111" + }, + { + "lamports": 1, + "address": "Vote111111111111111111111111111111111111111" + } + ] + }, + "id": 1 +} +``` + + + + diff --git a/docs/src/api/methods/_getLatestBlockhash.mdx b/docs/src/api/methods/_getLatestBlockhash.mdx new file mode 100644 index 00000000000000..85724a785c71ec --- /dev/null +++ b/docs/src/api/methods/_getLatestBlockhash.mdx @@ -0,0 +1,92 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getLatestBlockhash + +Returns the latest blockhash + +:::caution +NEW: This method is only available in solana-core v1.9 or newer. Please use +[getRecentBlockhash](#getrecentblockhash) for solana-core v1.8 +::: + + + + +### Parameters: + + + +Configuration object containing the following fields: + + + + + The minimum slot that the request can be evaluated at + + + + +### Result: + +`RpcResponse` - RpcResponse JSON object with `value` field set to a JSON object including: + +- `blockhash: ` - a Hash as base-58 encoded string +- `lastValidBlockHeight: ` - last [block height](../../terminology.md#block-height) at which the blockhash will be valid + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "id":1, + "jsonrpc":"2.0", + "method":"getLatestBlockhash", + "params":[ + { + "commitment":"processed" + } + ] + } +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": { + "context": { + "slot": 2792 + }, + "value": { + "blockhash": "EkSnNWid2cvwEVnVx9aBqawnmiCNiDgp3gUdkDPTKN1N", + "lastValidBlockHeight": 3090 + } + }, + "id": 1 +} +``` + + + + diff --git a/docs/src/api/methods/_getLeaderSchedule.mdx b/docs/src/api/methods/_getLeaderSchedule.mdx new file mode 100644 index 00000000000000..ee6803cb0ed49f --- /dev/null +++ b/docs/src/api/methods/_getLeaderSchedule.mdx @@ -0,0 +1,96 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getLeaderSchedule + +Returns the leader schedule for an epoch + + + + +### Parameters: + + +Fetch the leader schedule for the epoch that corresponds to the provided slot. + +
  • If unspecified, the leader schedule for the current epoch is fetched
  • + +
    + + + +Configuration object containing the following fields: + + + + + Only return results for this validator identity (base-58 encoded) + + + + +### Result: + +Returns a result with one of the two following values: + +- `` - if requested epoch is not found, or +- `` - the result field will be a dictionary of validator identities, + as base-58 encoded strings, and their corresponding leader slot indices as values + (indices are relative to the first slot in the requested epoch) + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc": "2.0", + "id": 1, + "method": "getLeaderSchedule", + "params": [ + null, + { + "identity": "4Qkev8aNZcqFNSRhQzwyLMFSsi94jHqE8WNVTJzTP99F" + } + ] + } +' +``` + +### Response: + +```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 + ] + }, + "id": 1 +} +``` + + + + diff --git a/docs/src/api/methods/_getMaxRetransmitSlot.mdx b/docs/src/api/methods/_getMaxRetransmitSlot.mdx new file mode 100644 index 00000000000000..17a104750e5cd6 --- /dev/null +++ b/docs/src/api/methods/_getMaxRetransmitSlot.mdx @@ -0,0 +1,48 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getMaxRetransmitSlot + +Get the max slot seen from retransmit stage. + + + + +### Parameters: + +**None** + +### Result: + +`` - Slot number + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + {"jsonrpc":"2.0","id":1, "method":"getMaxRetransmitSlot"} +' +``` + +### Response: + +```json +{ "jsonrpc": "2.0", "result": 1234, "id": 1 } +``` + + + + diff --git a/docs/src/api/methods/_getMaxShredInsertSlot.mdx b/docs/src/api/methods/_getMaxShredInsertSlot.mdx new file mode 100644 index 00000000000000..d776870ed9cc2c --- /dev/null +++ b/docs/src/api/methods/_getMaxShredInsertSlot.mdx @@ -0,0 +1,48 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getMaxShredInsertSlot + +Get the max slot seen from after shred insert. + + + + +### Parameters: + +**None** + +### Result: + +`` - Slot number + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + {"jsonrpc":"2.0","id":1, "method":"getMaxShredInsertSlot"} +' +``` + +### Response: + +```json +{ "jsonrpc": "2.0", "result": 1234, "id": 1 } +``` + + + + diff --git a/docs/src/api/methods/_getMinimumBalanceForRentExemption.mdx b/docs/src/api/methods/_getMinimumBalanceForRentExemption.mdx new file mode 100644 index 00000000000000..3f528284413647 --- /dev/null +++ b/docs/src/api/methods/_getMinimumBalanceForRentExemption.mdx @@ -0,0 +1,67 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getMinimumBalanceForRentExemption + +Returns minimum balance required to make account rent exempt. + + + + +### Parameters: + + + the Account's data length + + + + +Configuration object containing the following fields: + + + + + +### Result: + +`` - minimum lamports required in the Account to remain rent free + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc": "2.0", "id": 1, + "method": "getMinimumBalanceForRentExemption", + "params": [50] + } +' +``` + +### Response: + +```json +{ "jsonrpc": "2.0", "result": 500, "id": 1 } +``` + + + + diff --git a/docs/src/api/methods/_getMultipleAccounts.mdx b/docs/src/api/methods/_getMultipleAccounts.mdx new file mode 100644 index 00000000000000..207828fb4e5c39 --- /dev/null +++ b/docs/src/api/methods/_getMultipleAccounts.mdx @@ -0,0 +1,143 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getMultipleAccounts + +Returns the account information for a list of Pubkeys. + + + + +### Parameters: + + + An array of Pubkeys to query, as base-58 encoded strings (up to a maximum of + 100) + + + + +Configuration object containing the following fields: + + + + + The minimum slot that the request can be evaluated at + + + + +limit the returned account data using the provided `offset: ` and `length: ` fields; only available for "base58", "base64" or "base64+zstd" encodings. + + + + + +encoding format for the returned Account data + + + +
    + +- `base58` is slow and limited to less than 129 bytes of Account data. +- `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](/api/http#parsed-responses) 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 ``. + +
    + +
    + +
    + +### Result: + +The result will be a JSON object with `value` equal to an array of: + +- `` - if the account at that Pubkey doesn't exist, or +- `` - a JSON object containing: + - `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 + - `size: ` - the data size of the account + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc": "2.0", + "id": 1, + "method": "getMultipleAccounts", + "params": [ + [ + "vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg", + "4fYNw3dojWmQ4dXtSGE9epjRGy9pFSx62YypT7avPYvA" + ], + { + "encoding": "base58" + } + ] + } +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": { + "context": { + "slot": 1 + }, + "value": [ + { + "data": ["", "base64"], + "executable": false, + "lamports": 1000000000, + "owner": "11111111111111111111111111111111", + "rentEpoch": 2, + "space": 16 + }, + { + "data": ["", "base64"], + "executable": false, + "lamports": 5000000000, + "owner": "11111111111111111111111111111111", + "rentEpoch": 2, + "space": 0 + } + ] + }, + "id": 1 +} +``` + + + + diff --git a/docs/src/api/methods/_getProgramAccounts.mdx b/docs/src/api/methods/_getProgramAccounts.mdx new file mode 100644 index 00000000000000..7b623849dd7a09 --- /dev/null +++ b/docs/src/api/methods/_getProgramAccounts.mdx @@ -0,0 +1,160 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getProgramAccounts + +Returns all accounts owned by the provided program Pubkey + + + + +### Parameters: + + + Pubkey of program, as base-58 encoded string + + + + +Configuration object containing the following fields: + + + + + The minimum slot that the request can be evaluated at + + + + wrap the result in an RpcResponse JSON object + + + + +encoding format for the returned Account data + + + +
    + +- `base58` is slow and limited to less than 129 bytes of Account data. +- `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](/api/http#parsed-responses) 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 ``. + +
    + +
    + + +limit the returned account data using the provided `offset: usize` and `length: usize` fields; + +- only available for "base58", "base64" or "base64+zstd" encodings. + + + + + +filter results using up to 4 filter objects + +:::info +The resultant account(s) must meet **ALL** filter criteria to be included in the returned results +::: + + + +
    + +### Result: + +By default, the result field will be an array of JSON objects. + +:::info +If `withContext` flag is set the array will be wrapped in an RpcResponse JSON object. +::: + +The resultant response 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 + - `size: ` - the data size of the account + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc": "2.0", + "id": 1, + "method": "getProgramAccounts", + "params": [ + "4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T", + { + "filters": [ + { + "dataSize": 17 + }, + { + "memcmp": { + "offset": 4, + "bytes": "3Mc6vR" + } + } + ] + } + ] + } +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": [ + { + "account": { + "data": "2R9jLfiAQ9bgdcw6h8s44439", + "executable": false, + "lamports": 15298080, + "owner": "4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T", + "rentEpoch": 28, + "space": 42 + }, + "pubkey": "CxELquR1gPP8wHe33gZ4QxqGB3sZ9RSwsJ2KshVewkFY" + } + ], + "id": 1 +} +``` + + + + diff --git a/docs/src/api/methods/_getRecentPerformanceSamples.mdx b/docs/src/api/methods/_getRecentPerformanceSamples.mdx new file mode 100644 index 00000000000000..131cc80ba794d9 --- /dev/null +++ b/docs/src/api/methods/_getRecentPerformanceSamples.mdx @@ -0,0 +1,103 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getRecentPerformanceSamples + +Returns a list of recent performance samples, in reverse slot order. Performance samples are taken every 60 seconds and +include the number of transactions and slots that occur in a given time window. + + + + +### Parameters: + + + +number of samples to return (maximum 720) + + + +### Result: + +An array of `RpcPerfSample` with the following fields: + +- `slot: ` - Slot in which sample was taken at +- `numTransactions: ` - Number of transactions in sample +- `numSlots: ` - Number of slots in sample +- `samplePeriodSecs: ` - Number of seconds in a sample window +- `numNonVoteTransaction: ` - Number of non-vote transactions in + sample. + +:::info +`numNonVoteTransaction` is present starting with v1.15. + +To get a number of voting transactions compute:
    +`numTransactions - numNonVoteTransaction` +::: + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc":"2.0", "id":1, + "method": "getRecentPerformanceSamples", + "params": [4]} +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": [ + { + "numSlots": 126, + "numTransactions": 126, + "numNonVoteTransaction": 1, + "samplePeriodSecs": 60, + "slot": 348125 + }, + { + "numSlots": 126, + "numTransactions": 126, + "numNonVoteTransaction": 1, + "samplePeriodSecs": 60, + "slot": 347999 + }, + { + "numSlots": 125, + "numTransactions": 125, + "numNonVoteTransaction": 0, + "samplePeriodSecs": 60, + "slot": 347873 + }, + { + "numSlots": 125, + "numTransactions": 125, + "numNonVoteTransaction": 0, + "samplePeriodSecs": 60, + "slot": 347748 + } + ], + "id": 1 +} +``` + + + + diff --git a/docs/src/api/methods/_getRecentPrioritizationFees.mdx b/docs/src/api/methods/_getRecentPrioritizationFees.mdx new file mode 100644 index 00000000000000..7d7fcc791de6ea --- /dev/null +++ b/docs/src/api/methods/_getRecentPrioritizationFees.mdx @@ -0,0 +1,95 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getRecentPrioritizationFees + +Returns a list of prioritization fees from recent blocks. + +:::info +Currently, a node's prioritization-fee cache stores data from up to 150 blocks. +::: + + + + +### Parameters: + + + +An array of Account addresses (up to a maximum of 128 addresses), as base-58 encoded strings + +:::note +If this parameter is provided, the response will reflect a fee to land a transaction locking all of the provided accounts as writable. +::: + + + +### Result: + +An array of `RpcPrioritizationFee` with the following fields: + +- `slot: ` - slot in which the fee was observed +- `prioritizationFee: ` - the per-compute-unit fee paid by at least + one successfully landed transaction, specified in increments of 0.000001 lamports + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc":"2.0", "id":1, + "method": "getRecentPrioritizationFees", + "params": [ + ["CxELquR1gPP8wHe33gZ4QxqGB3sZ9RSwsJ2KshVewkFY"] + ] + } +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": [ + { + "slot": 348125, + "prioritizationFee": 0 + }, + { + "slot": 348126, + "prioritizationFee": 1000 + }, + { + "slot": 348127, + "prioritizationFee": 500 + }, + { + "slot": 348128, + "prioritizationFee": 0 + }, + { + "slot": 348129, + "prioritizationFee": 1234 + } + ], + "id": 1 +} +``` + + + + diff --git a/docs/src/api/methods/_getSignatureStatuses.mdx b/docs/src/api/methods/_getSignatureStatuses.mdx new file mode 100644 index 00000000000000..25bcbc326bca18 --- /dev/null +++ b/docs/src/api/methods/_getSignatureStatuses.mdx @@ -0,0 +1,114 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getSignatureStatuses + +Returns the statuses of a list of signatures. + +:::info +Unless the `searchTransactionHistory` configuration parameter is included, +this method only searches the recent status cache of signatures, which +retains statuses for all active slots plus `MAX_RECENT_BLOCKHASHES` rooted slots. +::: + + + + +### Parameters: + + + An array of transaction signatures to confirm, as base-58 encoded strings (up + to a maximum of 256) + + + + +Configuration object containing the following fields: + + + +if `true` - a Solana node will search its ledger cache for any signatures not +found in the recent status cache + + + + + +### Result: + +An array of `RpcResponse` consisting of either: + +- `` - Unknown transaction, or +- `` + - `slot: ` - The slot the transaction was processed + - `confirmations: ` - Number of blocks since signature confirmation, null if rooted, as well as finalized by a supermajority of the cluster + - `err: ` - Error if transaction failed, null if transaction succeeded. + See [TransactionError definitions](https://github.com/solana-labs/solana/blob/c0c60386544ec9a9ec7119229f37386d9f070523/sdk/src/transaction/error.rs#L13) + - `confirmationStatus: ` - The transaction's cluster confirmation status; + Either `processed`, `confirmed`, or `finalized`. See [Commitment](/api/http#configuring-state-commitment) for more on optimistic confirmation. + - DEPRECATED: `status: ` - Transaction status + - `"Ok": ` - Transaction was successful + - `"Err": ` - Transaction failed with TransactionError + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc": "2.0", + "id": 1, + "method": "getSignatureStatuses", + "params": [ + [ + "5VERv8NMvzbJMEkV8xnrLkEaWRtSz9CosKDYjCJjBRnbJLgp8uirBgmQpjKhoR4tjF3ZpRzrFmBV6UjKdiSZkQUW" + ], + { + "searchTransactionHistory": true + } + ] + } +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": { + "context": { + "slot": 82 + }, + "value": [ + { + "slot": 48, + "confirmations": null, + "err": null, + "status": { + "Ok": null + }, + "confirmationStatus": "finalized" + }, + null + ] + }, + "id": 1 +} +``` + + + + diff --git a/docs/src/api/methods/_getSignaturesForAddress.mdx b/docs/src/api/methods/_getSignaturesForAddress.mdx new file mode 100644 index 00000000000000..dc0517058d34c7 --- /dev/null +++ b/docs/src/api/methods/_getSignaturesForAddress.mdx @@ -0,0 +1,117 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## 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 + + + + +Configuration object containing the following fields: + + + + + The minimum slot that the request can be evaluated at + + + + maximum transaction signatures to return (between 1 and 1,000). + + + + start searching backwards from this transaction signature. If not provided the + search starts from the top of the highest max confirmed block. + + + + search until this transaction signature, if found before limit reached + + + + +### Result: + +An array of ``, ordered from **newest** to **oldest** transaction, containing transaction +signature information with the following fields: + +- `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. + See [TransactionError definitions](https://github.com/solana-labs/solana/blob/c0c60386544ec9a9ec7119229f37386d9f070523/sdk/src/transaction/error.rs#L13) + for more info. +- `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. +- `confirmationStatus: ` - The transaction's cluster confirmation status; + Either `processed`, `confirmed`, or `finalized`. See [Commitment](/api/http#configuring-state-commitment) + for more on optimistic confirmation. + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc": "2.0", + "id": 1, + "method": "getSignaturesForAddress", + "params": [ + "Vote111111111111111111111111111111111111111", + { + "limit": 1 + } + ] + } +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": [ + { + "err": null, + "memo": null, + "signature": "5h6xBEauJ3PK6SWCZ1PGjBvj8vDdWG3KpwATGy1ARAXFSDwt8GFXM7W5Ncn16wmqokgpiKRLuS83KUxyZyv2sUYv", + "slot": 114, + "blockTime": null + } + ], + "id": 1 +} +``` + + + + diff --git a/docs/src/api/methods/_getSlot.mdx b/docs/src/api/methods/_getSlot.mdx new file mode 100644 index 00000000000000..8693f8f3bb038e --- /dev/null +++ b/docs/src/api/methods/_getSlot.mdx @@ -0,0 +1,63 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getSlot + +Returns the slot that has reached the [given or default commitment level](/api/http#configuring-state-commitment) + + + + +### Parameters: + + + +Configuration object containing the following fields: + + + + + The minimum slot that the request can be evaluated at + + + + +### Result: + +`` - Current slot + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + {"jsonrpc":"2.0","id":1, "method":"getSlot"} +' +``` + +### Response: + +```json +{ "jsonrpc": "2.0", "result": 1234, "id": 1 } +``` + + + + diff --git a/docs/src/api/methods/_getSlotLeader.mdx b/docs/src/api/methods/_getSlotLeader.mdx new file mode 100644 index 00000000000000..7f8550ee1b8bab --- /dev/null +++ b/docs/src/api/methods/_getSlotLeader.mdx @@ -0,0 +1,67 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getSlotLeader + +Returns the current slot leader + + + + +### Parameters: + + + +Configuration object containing the following fields: + + + + + The minimum slot that the request can be evaluated at + + + + +### Result: + +`` - Node identity Pubkey as base-58 encoded string + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + {"jsonrpc":"2.0","id":1, "method":"getSlotLeader"} +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": "ENvAW7JScgYq6o4zKZwewtkzzJgDzuJAFxYasvmEQdpS", + "id": 1 +} +``` + + + + diff --git a/docs/src/api/methods/_getSlotLeaders.mdx b/docs/src/api/methods/_getSlotLeaders.mdx new file mode 100644 index 00000000000000..386a74fb44de94 --- /dev/null +++ b/docs/src/api/methods/_getSlotLeaders.mdx @@ -0,0 +1,77 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getSlotLeaders + +Returns the slot leaders for a given slot range + + + + +### Parameters: + + + Start slot, as u64 integer + + + + Limit, as u64 integer (between 1 and 5,000) + + +### Result: + +`` - array of Node identity public keys as base-58 encoded strings + + + + + +### Code sample: + +If the current slot is `#99` - query the next `10` leaders with the following request: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc":"2.0", "id": 1, + "method": "getSlotLeaders", + "params": [100, 10] + } +' +``` + +### Response: + +The first leader returned is the leader for slot `#100`: + +```json +{ + "jsonrpc": "2.0", + "result": [ + "ChorusmmK7i1AxXeiTtQgQZhQNiXYU84ULeaYF1EH15n", + "ChorusmmK7i1AxXeiTtQgQZhQNiXYU84ULeaYF1EH15n", + "ChorusmmK7i1AxXeiTtQgQZhQNiXYU84ULeaYF1EH15n", + "ChorusmmK7i1AxXeiTtQgQZhQNiXYU84ULeaYF1EH15n", + "Awes4Tr6TX8JDzEhCZY2QVNimT6iD1zWHzf1vNyGvpLM", + "Awes4Tr6TX8JDzEhCZY2QVNimT6iD1zWHzf1vNyGvpLM", + "Awes4Tr6TX8JDzEhCZY2QVNimT6iD1zWHzf1vNyGvpLM", + "Awes4Tr6TX8JDzEhCZY2QVNimT6iD1zWHzf1vNyGvpLM", + "DWvDTSh3qfn88UoQTEKRV2JnLt5jtJAVoiCo3ivtMwXP", + "DWvDTSh3qfn88UoQTEKRV2JnLt5jtJAVoiCo3ivtMwXP" + ], + "id": 1 +} +``` + + + + diff --git a/docs/src/api/methods/_getStakeActivation.mdx b/docs/src/api/methods/_getStakeActivation.mdx new file mode 100644 index 00000000000000..abd1d0bafb5966 --- /dev/null +++ b/docs/src/api/methods/_getStakeActivation.mdx @@ -0,0 +1,95 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getStakeActivation + +Returns epoch activation information for a stake account + + + + +### Parameters: + + + Pubkey of stake Account to query, as base-58 encoded string + + + + +Configuration object containing the following fields: + + + + + The minimum slot that the request can be evaluated at + + + + epoch for which to calculate activation details. If parameter not provided, + defaults to current epoch. + + + + +### Result: + +The result will be a JSON object with the following fields: + +- `state: ` - the stake account's activation state, + either: `active`, `inactive`, `activating`, or `deactivating` +- `active: ` - stake active during the epoch +- `inactive: ` - stake inactive during the epoch + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc": "2.0", + "id": 1, + "method": "getStakeActivation", + "params": [ + "CYRJWqiSjLitBAcRxPvWpgX3s5TvmN2SuRY3eEYypFvT", + { + "epoch": 4 + } + ] + } +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": { + "active": 124429280, + "inactive": 73287840, + "state": "activating" + }, + "id": 1 +} +``` + + + + diff --git a/docs/src/api/methods/_getStakeMinimumDelegation.mdx b/docs/src/api/methods/_getStakeMinimumDelegation.mdx new file mode 100644 index 00000000000000..94e01ac87052e9 --- /dev/null +++ b/docs/src/api/methods/_getStakeMinimumDelegation.mdx @@ -0,0 +1,73 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getStakeMinimumDelegation + +Returns the stake minimum delegation, in lamports. + + + + +### Parameters: + + + +Configuration object containing the following fields: + + + + + +### Result: + +The result will be an RpcResponse JSON object with `value` equal to: + +- `` - The stake minimum delegation, in lamports + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc":"2.0", "id":1, + "method": "getStakeMinimumDelegation" + } +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": { + "context": { + "slot": 501 + }, + "value": 1000000000 + }, + "id": 1 +} +``` + + + + diff --git a/docs/src/api/methods/_getSupply.mdx b/docs/src/api/methods/_getSupply.mdx new file mode 100644 index 00000000000000..a1d8915a1b87d1 --- /dev/null +++ b/docs/src/api/methods/_getSupply.mdx @@ -0,0 +1,87 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getSupply + +Returns information about the current supply. + + + + +### Parameters: + + + +Configuration object containing the following fields: + + + + + exclude non circulating accounts list from response + + + + +### Result: + +The result will be an RpcResponse JSON object with `value` equal to a JSON object containing: + +- `total: ` - Total supply in lamports +- `circulating: ` - Circulating supply in lamports +- `nonCirculating: ` - Non-circulating supply in lamports +- `nonCirculatingAccounts: ` - an array of account addresses of non-circulating accounts, as strings. If `excludeNonCirculatingAccountsList` is enabled, the returned array will be empty. + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + {"jsonrpc":"2.0", "id":1, "method":"getSupply"} +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": { + "context": { + "slot": 1114 + }, + "value": { + "circulating": 16000, + "nonCirculating": 1000000, + "nonCirculatingAccounts": [ + "FEy8pTbP5fEoqMV1GdTz83byuA8EKByqYat1PKDgVAq5", + "9huDUZfxoJ7wGMTffUE7vh1xePqef7gyrLJu9NApncqA", + "3mi1GmwEE3zo2jmfDuzvjSX9ovRXsDUKHvsntpkhuLJ9", + "BYxEJTDerkaRWBem3XgnVcdhppktBXa2HbkHPKj2Ui4Z" + ], + "total": 1016000 + } + }, + "id": 1 +} +``` + + + + diff --git a/docs/src/api/methods/_getTokenAccountBalance.mdx b/docs/src/api/methods/_getTokenAccountBalance.mdx new file mode 100644 index 00000000000000..e0cb785f7d6038 --- /dev/null +++ b/docs/src/api/methods/_getTokenAccountBalance.mdx @@ -0,0 +1,91 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getTokenAccountBalance + +Returns the token balance of an SPL Token account. + + + + +### Parameters: + + + Pubkey of Token account to query, as base-58 encoded string + + + + +Configuration object containing the following fields: + + + + + +### Result: + +The result will be an RpcResponse JSON object with `value` equal to a JSON object containing: + +- `amount: ` - the raw balance without decimals, a string representation of u64 +- `decimals: ` - number of base 10 digits to the right of the decimal place +- `uiAmount: ` - the balance, using mint-prescribed decimals **DEPRECATED** +- `uiAmountString: ` - the balance as a string, using mint-prescribed decimals + +For more details on returned data, the [Token Balances Structure](#token-balances-structure) +response from [getBlock](#getblock) follows a similar structure. + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc": "2.0", "id": 1, + "method": "getTokenAccountBalance", + "params": [ + "7fUAJdStEuGbc3sM84cKRL6yYaaSstyLSU4ve5oovLS7" + ] + } +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": { + "context": { + "slot": 1114 + }, + "value": { + "amount": "9864", + "decimals": 2, + "uiAmount": 98.64, + "uiAmountString": "98.64" + }, + "id": 1 + } +} +``` + + + + diff --git a/docs/src/api/methods/_getTokenAccountsByDelegate.mdx b/docs/src/api/methods/_getTokenAccountsByDelegate.mdx new file mode 100644 index 00000000000000..be47c1305eeaa4 --- /dev/null +++ b/docs/src/api/methods/_getTokenAccountsByDelegate.mdx @@ -0,0 +1,177 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getTokenAccountsByDelegate + +Returns all SPL Token accounts by approved Delegate. + + + + +### Parameters: + + + Pubkey of account delegate to query, as base-58 encoded string + + + + +A JSON object with one of the following fields: + +- `mint: ` - Pubkey of the specific token Mint to limit accounts to, as base-58 encoded string; or +- `programId: ` - Pubkey of the Token program that owns the accounts, as base-58 encoded string + + + + + +Configuration object containing the following fields: + + + + + The minimum slot that the request can be evaluated at + + + + +limit the returned account data using the provided `offset: ` +and `length: ` fields; only available for `base58`, +`base64` or `base64+zstd` encodings. + + + + + +Encoding format for Account data + + + +
    + +- `base58` is slow and limited to less than 129 bytes of Account data. +- `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 `string`. + +
    + +
    + +
    + +### Result: + +The result will be an RpcResponse JSON object with `value` equal to an array of JSON objects, which 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: ` - 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 + - `size: ` - the data size of the account + +When the data is requested with the `jsonParsed` encoding a format similar to that of the +[Token Balances Structure](#token-balances-structure) can be expected inside the structure, +both for the `tokenAmount` and the `delegatedAmount` - with the latter being an optional object. + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc": "2.0", + "id": 1, + "method": "getTokenAccountsByDelegate", + "params": [ + "4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T", + { + "programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "encoding": "jsonParsed" + } + ] + } +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": { + "context": { + "slot": 1114 + }, + "value": [ + { + "account": { + "data": { + "program": "spl-token", + "parsed": { + "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": "CnPoSPKXu7wJqxe59Fs72tkBeALovhsCxYeFwPCQH9TD" + }, + "type": "account" + }, + "space": 165 + }, + "executable": false, + "lamports": 1726080, + "owner": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", + "rentEpoch": 4, + "space": 165 + }, + "pubkey": "28YTZEwqtMHWrhWcvv34se7pjS7wctgqzCPB3gReCFKp" + } + ] + }, + "id": 1 +} +``` + + + + diff --git a/docs/src/api/methods/_getTokenAccountsByOwner.mdx b/docs/src/api/methods/_getTokenAccountsByOwner.mdx new file mode 100644 index 00000000000000..06a7e5fe4bbd80 --- /dev/null +++ b/docs/src/api/methods/_getTokenAccountsByOwner.mdx @@ -0,0 +1,176 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getTokenAccountsByOwner + +Returns all SPL Token accounts by token owner. + + + + +### Parameters: + + + Pubkey of account delegate to query, as base-58 encoded string + + + + +A JSON object with one of the following fields: + +- `mint: ` - Pubkey of the specific token Mint to limit accounts to, as base-58 encoded string; or +- `programId: ` - Pubkey of the Token program that owns the accounts, as base-58 encoded string + + + + + +Configuration object containing the following fields: + + + + + The minimum slot that the request can be evaluated at + + + + +limit the returned account data using the provided `offset: ` +and `length: ` fields; only available for +`base58`, `base64`, or `base64+zstd` encodings. + + + + + +Encoding format for Account data + + + +
    + +- `base58` is slow and limited to less than 129 bytes of Account data. +- `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 `string`. + +
    + +
    + +
    + +### Result: + +The result will be an RpcResponse JSON object with `value` equal to an array of JSON objects, which 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: ` - 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 + - `size: ` - the data size of the account + +When the data is requested with the `jsonParsed` encoding a format similar to that of the [Token Balances Structure](/api/http#token-balances-structure) can be expected inside the structure, both for the `tokenAmount` and the `delegatedAmount` - with the latter being an optional object. + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc": "2.0", + "id": 1, + "method": "getTokenAccountsByOwner", + "params": [ + "4Qkev8aNZcqFNSRhQzwyLMFSsi94jHqE8WNVTJzTP99F", + { + "mint": "3wyAj7Rt1TWVPZVteFJPLa26JmLvdb1CAKEFZm3NY75E" + }, + { + "encoding": "jsonParsed" + } + ] + } +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": { + "context": { + "slot": 1114 + }, + "value": [ + { + "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" + }, + "type": "account" + }, + "space": 165 + }, + "executable": false, + "lamports": 1726080, + "owner": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", + "rentEpoch": 4, + "space": 165 + }, + "pubkey": "C2gJg6tKpQs41PRS1nC8aw3ZKNZK3HQQZGVrDFDup5nx" + } + ] + }, + "id": 1 +} +``` + + + + diff --git a/docs/src/api/methods/_getTokenLargestAccounts.mdx b/docs/src/api/methods/_getTokenLargestAccounts.mdx new file mode 100644 index 00000000000000..387f00ad2e1bd4 --- /dev/null +++ b/docs/src/api/methods/_getTokenLargestAccounts.mdx @@ -0,0 +1,99 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getTokenLargestAccounts + +Returns the 20 largest accounts of a particular SPL Token type. + + + + +### Parameters: + + + Pubkey of the token Mint to query, as base-58 encoded string + + + + +Configuration object containing the following fields: + + + + + +### Result: + +The result will be an RpcResponse JSON object with `value` equal to an array of JSON objects containing: + +- `address: ` - the address of the token account +- `amount: ` - the raw token account balance without decimals, a string representation of u64 +- `decimals: ` - number of base 10 digits to the right of the decimal place +- `uiAmount: ` - the token account balance, using mint-prescribed decimals **DEPRECATED** +- `uiAmountString: ` - the token account balance as a string, using mint-prescribed decimals + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc": "2.0", "id": 1, + "method": "getTokenLargestAccounts", + "params": [ + "3wyAj7Rt1TWVPZVteFJPLa26JmLvdb1CAKEFZm3NY75E" + ] + } +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": { + "context": { + "slot": 1114 + }, + "value": [ + { + "address": "FYjHNoFtSQ5uijKrZFyYAxvEr87hsKXkXcxkcmkBAf4r", + "amount": "771", + "decimals": 2, + "uiAmount": 7.71, + "uiAmountString": "7.71" + }, + { + "address": "BnsywxTcaYeNUtzrPxQUvzAWxfzZe3ZLUJ4wMMuLESnu", + "amount": "229", + "decimals": 2, + "uiAmount": 2.29, + "uiAmountString": "2.29" + } + ] + }, + "id": 1 +} +``` + + + + diff --git a/docs/src/api/methods/_getTokenSupply.mdx b/docs/src/api/methods/_getTokenSupply.mdx new file mode 100644 index 00000000000000..af42feee0683ac --- /dev/null +++ b/docs/src/api/methods/_getTokenSupply.mdx @@ -0,0 +1,88 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getTokenSupply + +Returns the total supply of an SPL Token type. + + + + +### Parameters: + + + Pubkey of the token Mint to query, as base-58 encoded string + + + + +Configuration object containing the following fields: + + + + + +### Result: + +The result will be an RpcResponse JSON object with `value` equal to a JSON object containing: + +- `amount: ` - the raw total token supply without decimals, a string representation of u64 +- `decimals: ` - number of base 10 digits to the right of the decimal place +- `uiAmount: ` - the total token supply, using mint-prescribed decimals **DEPRECATED** +- `uiAmountString: ` - the total token supply as a string, using mint-prescribed decimals + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc": "2.0", "id": 1, + "method": "getTokenSupply", + "params": [ + "3wyAj7Rt1TWVPZVteFJPLa26JmLvdb1CAKEFZm3NY75E" + ] + } +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": { + "context": { + "slot": 1114 + }, + "value": { + "amount": "100000", + "decimals": 2, + "uiAmount": 1000, + "uiAmountString": "1000" + } + }, + "id": 1 +} +``` + + + + diff --git a/docs/src/api/methods/_getTransaction.mdx b/docs/src/api/methods/_getTransaction.mdx new file mode 100644 index 00000000000000..c4e17e53c7fd2a --- /dev/null +++ b/docs/src/api/methods/_getTransaction.mdx @@ -0,0 +1,172 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getTransaction + +Returns transaction details for a confirmed transaction + + + + +### Parameters: + + + Transaction signature, as base-58 encoded string + + + + +Configuration object containing the following fields: + + + + + Set the max transaction version to return in responses. If the requested + transaction is a higher version, an error will be returned. If this parameter + is omitted, only legacy transactions will be returned, and any versioned + transaction will prompt the error. + + + + +Encoding for the returned Transaction + + + +
    + +- `jsonParsed` encoding attempts to use program-specific state 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). + +
    + +
    + +
    + +### Result: + +- `` - if transaction is not found or not confirmed +- `` - if transaction is confirmed, an object with the following fields: + - `slot: ` - the slot this transaction was processed in + - `transaction: ` - [Transaction](#transaction-structure) object, either in JSON format or encoded binary data, depending on encoding parameter + - `blockTime: ` - estimated production time, as Unix timestamp (seconds since the Unix epoch) of when the transaction was processed. null if not available + - `meta: ` - transaction status metadata object: + - `err: ` - Error if transaction failed, null if transaction succeeded. [TransactionError definitions](https://docs.rs/solana-sdk/VERSION_FOR_DOCS_RS/solana_sdk/transaction/enum.TransactionError.html) + - `fee: ` - fee this transaction was charged, as u64 integer + - `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 + - `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 + - `"Ok": ` - Transaction was successful + - `"Err": ` - Transaction failed with TransactionError + - `rewards: ` - transaction-level rewards, populated if rewards are requested; an array of JSON objects containing: + - `pubkey: ` - The public key, as base-58 encoded string, of the account that received the reward + - `lamports: `- number of reward lamports credited or debited by the account, as a i64 + - `postBalance: ` - account balance in lamports after the reward was applied + - `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 + - `loadedAddresses: ` - Transaction addresses loaded from address lookup tables. Undefined if `maxSupportedTransactionVersion` is not set in request params. + - `writable: ` - Ordered list of base-58 encoded addresses for writable loaded accounts + - `readonly: ` - Ordered list of base-58 encoded addresses for readonly loaded accounts + - `returnData: ` - the most-recent return data generated by an instruction in the transaction, with the following fields: + - `programId: ` - the program that generated the return data, as base-58 encoded Pubkey + - `data: <[string, encoding]>` - the return data itself, as base-64 encoded binary data + - `computeUnitsConsumed: ` - number of [compute units](developing/programming-model/runtime.md#compute-budget) consumed by the transaction + - `version: <"legacy"|number|undefined>` - Transaction version. Undefined if `maxSupportedTransactionVersion` is not set in request params. + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc": "2.0", + "id": 1, + "method": "getTransaction", + "params": [ + "2nBhEBYYvfaAe16UMNqRHre4YNSskvuYgx3M6E4JP1oDYvZEJHvoPzyUidNgNX5r9sTyN1J9UxtbCXy2rqYcuyuv", + "json" + ] + } +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": { + "meta": { + "err": null, + "fee": 5000, + "innerInstructions": [], + "postBalances": [499998932500, 26858640, 1, 1, 1], + "postTokenBalances": [], + "preBalances": [499998937500, 26858640, 1, 1, 1], + "preTokenBalances": [], + "rewards": [], + "status": { + "Ok": null + } + }, + "slot": 430, + "transaction": { + "message": { + "accountKeys": [ + "3UVYmECPPMZSCqWKfENfuoTv51fTDTWicX9xmBD2euKe", + "AjozzgE83A3x1sHNUR64hfH7zaEBWeMaFuAN9kQgujrc", + "SysvarS1otHashes111111111111111111111111111", + "SysvarC1ock11111111111111111111111111111111", + "Vote111111111111111111111111111111111111111" + ], + "header": { + "numReadonlySignedAccounts": 0, + "numReadonlyUnsignedAccounts": 3, + "numRequiredSignatures": 1 + }, + "instructions": [ + { + "accounts": [1, 2, 3, 0], + "data": "37u9WtQpcm6ULa3WRQHmj49EPs4if7o9f1jSRVZpm2dvihR9C8jY4NqEwXUbLwx15HBSNcP1", + "programIdIndex": 4 + } + ], + "recentBlockhash": "mfcyqEXB3DnHXki6KjjmZck6YjmZLvpAByy2fj4nh6B" + }, + "signatures": [ + "2nBhEBYYvfaAe16UMNqRHre4YNSskvuYgx3M6E4JP1oDYvZEJHvoPzyUidNgNX5r9sTyN1J9UxtbCXy2rqYcuyuv" + ] + } + }, + "blockTime": null, + "id": 1 +} +``` + + + + diff --git a/docs/src/api/methods/_getTransactionCount.mdx b/docs/src/api/methods/_getTransactionCount.mdx new file mode 100644 index 00000000000000..3a966a1f66dbf2 --- /dev/null +++ b/docs/src/api/methods/_getTransactionCount.mdx @@ -0,0 +1,63 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getTransactionCount + +Returns the current Transaction count from the ledger + + + + +### Parameters: + + + +Configuration object containing the following fields: + + + + + The minimum slot that the request can be evaluated at + + + + +### Result: + +`` - the current Transaction count from the ledger + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + {"jsonrpc":"2.0","id":1, "method":"getTransactionCount"} +' +``` + +### Response: + +```json +{ "jsonrpc": "2.0", "result": 268, "id": 1 } +``` + + + + diff --git a/docs/src/api/methods/_getVersion.mdx b/docs/src/api/methods/_getVersion.mdx new file mode 100644 index 00000000000000..0ed4d94020fd2a --- /dev/null +++ b/docs/src/api/methods/_getVersion.mdx @@ -0,0 +1,51 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getVersion + +Returns the current Solana version running on the node + + + + +### Parameters: + +**None** + +### Result: + +The result field will be a JSON object with the following fields: + +- `solana-core` - software version of solana-core +- `feature-set` - unique identifier of the current software's feature set + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + {"jsonrpc":"2.0","id":1, "method":"getVersion"} +' +``` + +### Response: + +```json +{ "jsonrpc": "2.0", "result": { "solana-core": "1.15.0" }, "id": 1 } +``` + + + + diff --git a/docs/src/api/methods/_getVoteAccounts.mdx b/docs/src/api/methods/_getVoteAccounts.mdx new file mode 100644 index 00000000000000..04a57a3aa42207 --- /dev/null +++ b/docs/src/api/methods/_getVoteAccounts.mdx @@ -0,0 +1,114 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## getVoteAccounts + +Returns the account info and associated stake for all the voting accounts in the current bank. + + + + +### Parameters: + + + +Configuration object containing the following fields: + + + + + Only return results for this validator vote address (base-58 encoded) + + + + Do not filter out delinquent validators with no stake + + + + Specify the number of slots behind the tip that a validator must fall to be + considered delinquent. **NOTE:** For the sake of consistency between ecosystem + products, _it is **not** recommended that this argument be specified._ + + + + +### Result: + +The result field will be a JSON object of `current` and `delinquent` accounts, +each containing an array of JSON objects with the following sub fields: + +- `votePubkey: ` - Vote account address, as base-58 encoded string +- `nodePubkey: ` - Validator identity, as base-58 encoded string +- `activatedStake: ` - the stake, in lamports, delegated to this vote account and active in this epoch +- `epochVoteAccount: ` - bool, whether the vote account is staked for this epoch +- `commission: ` - percentage (0-100) of rewards payout owed to the vote account +- `lastVote: ` - Most recent slot voted on by this vote account +- `epochCredits: ` - Latest history of earned credits for up to five epochs, as an array of arrays containing: `[epoch, credits, previousCredits]`. +- `rootSlot: ` - Current root slot for this vote account + + + + + +### Code sample: + +Restrict results to a single validator vote account: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc": "2.0", + "id": 1, + "method": "getVoteAccounts", + "params": [ + { + "votePubkey": "3ZT31jkAGhUaw8jsy4bTknwBMP8i4Eueh52By4zXcsVw" + } + ] + } +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": { + "current": [ + { + "commission": 0, + "epochVoteAccount": true, + "epochCredits": [ + [1, 64, 0], + [2, 192, 64] + ], + "nodePubkey": "B97CCUW3AEZFGy6uUg6zUdnNYvnVq5VG8PUtb2HayTDD", + "lastVote": 147, + "activatedStake": 42, + "votePubkey": "3ZT31jkAGhUaw8jsy4bTknwBMP8i4Eueh52By4zXcsVw" + } + ], + "delinquent": [] + }, + "id": 1 +} +``` + + + + diff --git a/docs/src/api/methods/_isBlockhashValid.mdx b/docs/src/api/methods/_isBlockhashValid.mdx new file mode 100644 index 00000000000000..d8903dc0ee44eb --- /dev/null +++ b/docs/src/api/methods/_isBlockhashValid.mdx @@ -0,0 +1,89 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## isBlockhashValid + +Returns whether a blockhash is still valid or not + +:::caution +NEW: This method is only available in solana-core v1.9 or newer. Please use +[getFeeCalculatorForBlockhash](#getfeecalculatorforblockhash) for solana-core v1.8 +::: + + + + +### Parameters: + + + the blockhash of the block to evauluate, as base-58 encoded string + + + + +Configuration object containing the following fields: + + + + + The minimum slot that the request can be evaluated at + + + + +### Result: + +`` - `true` if the blockhash is still valid + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "id":45, + "jsonrpc":"2.0", + "method":"isBlockhashValid", + "params":[ + "J7rBdM6AecPDEZp8aPq5iPSNKVkU5Q76F3oAV4eW5wsW", + {"commitment":"processed"} + ] + } +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": { + "context": { + "slot": 2483 + }, + "value": false + }, + "id": 1 +} +``` + + + + diff --git a/docs/src/api/methods/_minimumLedgerSlot.mdx b/docs/src/api/methods/_minimumLedgerSlot.mdx new file mode 100644 index 00000000000000..1ac63315d972ed --- /dev/null +++ b/docs/src/api/methods/_minimumLedgerSlot.mdx @@ -0,0 +1,52 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## minimumLedgerSlot + +Returns the lowest slot that the node has information about in its ledger. + +:::info +This value may increase over time if the node is configured to purge older ledger data +::: + + + + +### Parameters: + +**None** + +### Result: + +`u64` - Minimum ledger slot number + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + {"jsonrpc":"2.0","id":1, "method":"minimumLedgerSlot"} +' +``` + +### Response: + +```json +{ "jsonrpc": "2.0", "result": 1234, "id": 1 } +``` + + + + diff --git a/docs/src/api/methods/_requestAirdrop.mdx b/docs/src/api/methods/_requestAirdrop.mdx new file mode 100644 index 00000000000000..7a9cf3527f919d --- /dev/null +++ b/docs/src/api/methods/_requestAirdrop.mdx @@ -0,0 +1,78 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## requestAirdrop + +Requests an airdrop of lamports to a Pubkey + + + + +### Parameters: + + + Pubkey of account to receive lamports, as a base-58 encoded string + + + + lamports to airdrop, as a "u64" + + + + +Configuration object containing the following fields: + + + + + +### Result: + +`` - Transaction Signature of the airdrop, as a base-58 encoded string + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc": "2.0", "id": 1, + "method": "requestAirdrop", + "params": [ + "83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri", + 1000000000 + ] + } +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": "5VERv8NMvzbJMEkV8xnrLkEaWRtSz9CosKDYjCJjBRnbJLgp8uirBgmQpjKhoR4tjF3ZpRzrFmBV6UjKdiSZkQUW", + "id": 1 +} +``` + + + + diff --git a/docs/src/api/methods/_sendTransaction.mdx b/docs/src/api/methods/_sendTransaction.mdx new file mode 100644 index 00000000000000..fc9978aaeea0c6 --- /dev/null +++ b/docs/src/api/methods/_sendTransaction.mdx @@ -0,0 +1,124 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## sendTransaction + +Submits a signed transaction to the cluster for processing. + +This method does not alter the transaction in any way; it relays the +transaction created by clients to the node as-is. + +If the node's rpc service receives the transaction, this method immediately +succeeds, without waiting for any confirmations. A successful response from +this method does not guarantee the transaction is processed or confirmed by the +cluster. + +While the rpc service will reasonably retry to submit it, the transaction +could be rejected if transaction's `recent_blockhash` expires before it lands. + +Use [`getSignatureStatuses`](#getsignaturestatuses) to ensure a transaction is processed and confirmed. + +Before submitting, the following preflight checks are performed: + +1. The transaction signatures are verified +2. The transaction is simulated against the bank slot specified by the preflight + commitment. On failure an error will be returned. Preflight checks may be + disabled if desired. It is recommended to specify the same commitment and + preflight commitment to avoid confusing behavior. + +The returned signature is the first signature in the transaction, which +is used to identify the transaction ([transaction id](../../terminology.md#transaction-id)). +This identifier can be easily extracted from the transaction data before +submission. + + + + +### Parameters: + + + Fully-signed Transaction, as encoded string. + + + + +Configuration object containing the following optional fields: + + + +Encoding used for the transaction data. + +Values: `base58` (_slow_, **DEPRECATED**), or `base64`. + + + + + if "true", skip the preflight transaction checks + + + + Commitment level to use for preflight. + + + + 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. + + + + set the minimum slot at which to perform preflight transaction checks + + + + +### Result: + +`` - First Transaction Signature embedded in the transaction, as base-58 encoded string ([transaction id](../../terminology.md#transaction-id)) + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc": "2.0", + "id": 1, + "method": "sendTransaction", + "params": [ + "4hXTCkRzt9WyecNzV1XPgCDfGAZzQKNxLXgynz5QDuWWPSAZBZSHptvWRL3BjCvzUXRdKvHL2b7yGrRQcWyaqsaBCncVG7BFggS8w9snUts67BSh3EqKpXLUm5UMHfD7ZBe9GhARjbNQMLJ1QD3Spr6oMTBU6EhdB4RD8CP2xUxr2u3d6fos36PD98XS6oX8TQjLpsMwncs5DAMiD4nNnR8NBfyghGCWvCVifVwvA8B8TJxE1aiyiv2L429BCWfyzAme5sZW8rDb14NeCQHhZbtNqfXhcp2tAnaAT" + ] + } +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": "2id3YC2jK9G5Wo2phDx4gJVAew8DcY5NAojnVuao8rkxwPYPe8cSwE5GzhEgJA2y8fVjDEo6iR6ykBvDxrTQrtpb", + "id": 1 +} +``` + + + + diff --git a/docs/src/api/methods/_simulateTransaction.mdx b/docs/src/api/methods/_simulateTransaction.mdx new file mode 100644 index 00000000000000..fbae901244a97b --- /dev/null +++ b/docs/src/api/methods/_simulateTransaction.mdx @@ -0,0 +1,174 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## simulateTransaction + +Simulate sending a transaction + + + + +### Parameters: + + + +Transaction, as an encoded string. + +:::note +The transaction must have a valid blockhash, but is not required to be signed. +::: + + + + + +Configuration object containing the following fields: + + + Commitment level to simulate the transaction at + + + + if `true` the transaction signatures will be verified (conflicts with + `replaceRecentBlockhash`) + + + + if `true` the transaction recent blockhash will be replaced with the most + recent blockhash. (conflicts with `sigVerify`) + + + + the minimum slot that the request can be evaluated at + + + + +Encoding used for the transaction data. + +Values: `base58` (_slow_, **DEPRECATED**), or `base64`. + + + + + +Accounts configuration object containing the following fields: + + + An `array` of accounts to return, as base-58 encoded strings + + + + +encoding for returned Account data + + + +
    + +- `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 `string`. + +
    + +
    + +
    + +
    + +### Result: + +The result will be an RpcResponse JSON object with `value` set to a JSON object with the following fields: + +- `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) +- `logs: ` - Array of log messages the transaction instructions output during execution, null if simulation failed before the transaction was able to execute (for example due to an invalid blockhash or signature verification failure) +- `accounts: ` - array of accounts with the same length as the `accounts.addresses` array in the request + - `` - if the account doesn't exist or if `err` is not null + - `` - otherwise, a JSON object containing: + - `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 +- `unitsConsumed: ` - The number of compute budget units consumed during the processing of this transaction +- `returnData: ` - the most-recent return data generated by an instruction in the transaction, with the following fields: + - `programId: ` - the program that generated the return data, as base-58 encoded Pubkey + - `data: <[string, encoding]>` - the return data itself, as base-64 encoded binary data + + + + + +### Code sample: + +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc": "2.0", + "id": 1, + "method": "simulateTransaction", + "params": [ + "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEDArczbMia1tLmq7zz4DinMNN0pJ1JtLdqIJPUw3YrGCzYAMHBsgN27lcgB6H2WQvFgyZuJYHa46puOQo9yQ8CVQbd9uHXZaGT2cvhRs7reawctIXtX1s3kTqM9YV+/wCp20C7Wj2aiuk5TReAXo+VTVg8QTHjs0UjNMMKCvpzZ+ABAgEBARU=", + { + "encoding":"base64", + } + ] + } +' +``` + +### Response: + +```json +{ + "jsonrpc": "2.0", + "result": { + "context": { + "slot": 218 + }, + "value": { + "err": null, + "accounts": null, + "logs": [ + "Program 83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri invoke [1]", + "Program 83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri consumed 2366 of 1400000 compute units", + "Program return: 83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri KgAAAAAAAAA=", + "Program 83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri success" + ], + "returnData": { + "data": ["Kg==", "base64"], + "programId": "83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri" + }, + "unitsConsumed": 2366 + } + }, + "id": 1 +} +``` + + + + diff --git a/docs/src/api/websocket.md b/docs/src/api/websocket.md new file mode 100644 index 00000000000000..d409072f462901 --- /dev/null +++ b/docs/src/api/websocket.md @@ -0,0 +1,91 @@ +--- +title: RPC Websocket API +displayed_sidebar: apiWebsocketMethodsSidebar +hide_table_of_contents: true +--- + +After connecting to the RPC PubSub websocket at `ws://
    /`: + +- Submit subscription requests to the websocket using the methods below +- Multiple subscriptions may be active at once +- Many subscriptions take the optional [`commitment` parameter](/api/http#configuring-state-commitment), defining how finalized a change should be to trigger a notification. For subscriptions, if commitment is unspecified, the default value is `finalized`. + +## RPC PubSub WebSocket Endpoint + +**Default port:** 8900 e.g. ws://localhost:8900, [http://192.168.1.88:8900](http://192.168.1.88:8900) + +## Methods + +The following methods are supported in the RPC Websocket API: + +import AccountSubscribe from "./websocket/\_accountSubscribe.mdx" + + + +import AccountUnsubscribe from "./websocket/\_accountUnsubscribe.mdx" + + + +import BlockSubscribe from "./websocket/\_blockSubscribe.mdx" + + + +import BlockUnsubscribe from "./websocket/\_blockUnsubscribe.mdx" + + + +import LogsSubscribe from "./websocket/\_logsSubscribe.mdx" + + + +import LogsUnsubscribe from "./websocket/\_logsUnsubscribe.mdx" + + + +import ProgramSubscribe from "./websocket/\_programSubscribe.mdx" + + + +import ProgramUnsubscribe from "./websocket/\_programUnsubscribe.mdx" + + + +import SignatureSubscribe from "./websocket/\_signatureSubscribe.mdx" + + + +import SignatureUnsubscribe from "./websocket/\_signatureUnsubscribe.mdx" + + + +import SlotSubscribe from "./websocket/\_slotSubscribe.mdx" + + + +import SlotUnsubscribe from "./websocket/\_slotUnsubscribe.mdx" + + + +import SlotsUpdatesSubscribe from "./websocket/\_slotsUpdatesSubscribe.mdx" + + + +import SlotsUpdatesUnsubscribe from "./websocket/\_slotsUpdatesUnsubscribe.mdx" + + + +import RootSubscribe from "./websocket/\_rootSubscribe.mdx" + + + +import RootUnsubscribe from "./websocket/\_rootUnsubscribe.mdx" + + + +import VoteSubscribe from "./websocket/\_voteSubscribe.mdx" + + + +import VoteUnsubscribe from "./websocket/\_voteUnsubscribe.mdx" + + diff --git a/docs/src/api/websocket/_accountSubscribe.mdx b/docs/src/api/websocket/_accountSubscribe.mdx new file mode 100644 index 00000000000000..f86e214a64aa92 --- /dev/null +++ b/docs/src/api/websocket/_accountSubscribe.mdx @@ -0,0 +1,160 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## accountSubscribe + +Subscribe to an account to receive notifications when the lamports or data for a given account public key changes + + + + +### Parameters: + + + Account Pubkey, as base-58 encoded string + + + + +Configuration object containing the following fields: + + + + + +Encoding format for Account data + + + +
    + +- `base58` is slow. +- `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`string`. + +
    + +
    + +
    + +### Result: + +`` - Subscription id \(needed to unsubscribe\) + +
    + + + +### Code sample: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "accountSubscribe", + "params": [ + "CM78CPUeXjn8o3yroDHxUtKsZZgoy4GPkPPXfouKNH12", + { + "encoding": "jsonParsed", + "commitment": "finalized" + } + ] +} +``` + +### Response: + +```json +{ "jsonrpc": "2.0", "result": 23784, "id": 1 } +``` + + +
    + +#### Notification Format: + +The notification format is the same as seen in the [getAccountInfo](#getAccountInfo) RPC HTTP method. + +Base58 encoding: + +```json +{ + "jsonrpc": "2.0", + "method": "accountNotification", + "params": { + "result": { + "context": { + "slot": 5199307 + }, + "value": { + "data": [ + "11116bv5nS2h3y12kD1yUKeMZvGcKLSjQgX6BeV7u1FrjeJcKfsHPXHRDEHrBesJhZyqnnq9qJeUuF7WHxiuLuL5twc38w2TXNLxnDbjmuR", + "base58" + ], + "executable": false, + "lamports": 33594, + "owner": "11111111111111111111111111111111", + "rentEpoch": 635, + "space": 80 + } + }, + "subscription": 23784 + } +} +``` + +Parsed-JSON encoding: + +```json +{ + "jsonrpc": "2.0", + "method": "accountNotification", + "params": { + "result": { + "context": { + "slot": 5199307 + }, + "value": { + "data": { + "program": "nonce", + "parsed": { + "type": "initialized", + "info": { + "authority": "Bbqg1M4YVVfbhEzwA9SpC9FhsaG83YMTYoR4a8oTDLX", + "blockhash": "LUaQTmM7WbMRiATdMMHaRGakPtCkc2GHtH57STKXs6k", + "feeCalculator": { + "lamportsPerSignature": 5000 + } + } + } + }, + "executable": false, + "lamports": 33594, + "owner": "11111111111111111111111111111111", + "rentEpoch": 635, + "space": 80 + } + }, + "subscription": 23784 + } +} +``` + +
    diff --git a/docs/src/api/websocket/_accountUnsubscribe.mdx b/docs/src/api/websocket/_accountUnsubscribe.mdx new file mode 100644 index 00000000000000..d3a90de9ab9132 --- /dev/null +++ b/docs/src/api/websocket/_accountUnsubscribe.mdx @@ -0,0 +1,53 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## accountUnsubscribe + +Unsubscribe from account change notifications + + + + +### Parameters: + + + id of the account Subscription to cancel + + +### Result: + +`` - unsubscribe success message + + + + + +### Code sample: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "accountUnsubscribe", + "params": [0] +} +``` + +### Response: + +```json +{ "jsonrpc": "2.0", "result": true, "id": 1 } +``` + + + + diff --git a/docs/src/api/websocket/_blockSubscribe.mdx b/docs/src/api/websocket/_blockSubscribe.mdx new file mode 100644 index 00000000000000..078f7585846e7f --- /dev/null +++ b/docs/src/api/websocket/_blockSubscribe.mdx @@ -0,0 +1,342 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## blockSubscribe + +Subscribe to receive notification anytime a new block is Confirmed or Finalized. + +:::caution +This subscription is **unstable** and only available if the validator was started +with the `--rpc-pubsub-enable-block-subscription` flag. + +**NOTE: The format of this subscription may change in the future** +::: + + + + +### Parameters: + + + +filter criteria for the logs to receive results by account type; currently supported: + + + all - include all transactions in block + + + + +A JSON object with the following field: + +- `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. + + + + + + + +Configuration object containing the following fields: + + + + + level of transaction detail to return, either "full", "signatures", or "none". + + + + whether to populate the `rewards` array. + + + + +Encoding format for Account data + + + +
    + +- `base58` is slow +- `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 `string`. + +
    + +
    + +
    + +### Result: + +`integer` - subscription id \(needed to unsubscribe\) + +
    + + + +### Code sample: + +```json +{ + "jsonrpc": "2.0", + "id": "1", + "method": "blockSubscribe", + "params": ["all"] +} +``` + +```json +{ + "jsonrpc": "2.0", + "id": "1", + "method": "blockSubscribe", + "params": [ + { + "mentionsAccountOrProgram": "LieKvPRE8XeX3Y2xVNHjKlpAScD12lYySBVQ4HqoJ5op" + }, + { + "commitment": "confirmed", + "encoding": "base64", + "showRewards": true, + "transactionDetails": "full" + } + ] +} +``` + +### Response: + +```json +{ "jsonrpc": "2.0", "result": 0, "id": 1 } +``` + + +
    + +#### Notification Format: + +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](/api/http#getblock) RPC HTTP method. + +```json +{ + "jsonrpc": "2.0", + "method": "blockNotification", + "params": { + "result": { + "context": { + "slot": 112301554 + }, + "value": { + "slot": 112301554, + "block": { + "previousBlockhash": "GJp125YAN4ufCSUvZJVdCyWQJ7RPWMmwxoyUQySydZA", + "blockhash": "6ojMHjctdqfB55JDpEpqfHnP96fiaHEcvzEQ2NNcxzHP", + "parentSlot": 112301553, + "transactions": [ + { + "transaction": [ + "OpltwoUvWxYi1P2U8vbIdE/aPntjYo5Aa0VQ2JJyeJE2g9Vvxk8dDGgFMruYfDu8/IfUWb0REppTe7IpAuuLRgIBAAkWnj4KHRpEWWW7gvO1c0BHy06wZi2g7/DLqpEtkRsThAXIdBbhXCLvltw50ZnjDx2hzw74NVn49kmpYj2VZHQJoeJoYJqaKcvuxCi/2i4yywedcVNDWkM84Iuw+cEn9/ROCrXY4qBFI9dveEERQ1c4kdU46xjxj9Vi+QXkb2Kx45QFVkG4Y7HHsoS6WNUiw2m4ffnMNnOVdF9tJht7oeuEfDMuUEaO7l9JeUxppCvrGk3CP45saO51gkwVYEgKzhpKjCx3rgsYxNR81fY4hnUQXSbbc2Y55FkwgRBpVvQK7/+clR4Gjhd3L4y+OtPl7QF93Akg1LaU9wRMs5nvfDFlggqI9PqJl+IvVWrNRdBbPS8LIIhcwbRTkSbqlJQWxYg3Bo2CTVbw7rt1ZubuHWWp0mD/UJpLXGm2JprWTePNULzHu67sfqaWF99LwmwjTyYEkqkRt1T0Je5VzHgJs0N5jY4iIU9K3lMqvrKOIn/2zEMZ+ol2gdgjshx+sphIyhw65F3J/Dbzk04LLkK+CULmN571Y+hFlXF2ke0BIuUG6AUF+4214Cu7FXnqo3rkxEHDZAk0lRrAJ8X/Z+iwuwI5cgbd9uHXZaGT2cvhRs7reawctIXtX1s3kTqM9YV+/wCpDLAp8axcEkaQkLDKRoWxqp8XLNZSKial7Rk+ELAVVKWoWLRXRZ+OIggu0OzMExvVLE5VHqy71FNHq4gGitkiKYNFWSLIE4qGfdFLZXy/6hwS+wq9ewjikCpd//C9BcCL7Wl0iQdUslxNVCBZHnCoPYih9JXvGefOb9WWnjGy14sG9j70+RSVx6BlkFELWwFvIlWR/tHn3EhHAuL0inS2pwX7ZQTAU6gDVaoqbR2EiJ47cKoPycBNvHLoKxoY9AZaBjPl6q8SKQJSFyFd9n44opAgI6zMTjYF/8Ok4VpXEESp3QaoUyTI9sOJ6oFP6f4dwnvQelgXS+AEfAsHsKXxGAIUDQENAgMEBQAGBwgIDg8IBJCER3QXl1AVDBADCQoOAAQLERITDAjb7ugh3gOuTy==", + "base64" + ], + "meta": { + "err": null, + "status": { + "Ok": null + }, + "fee": 5000, + "preBalances": [ + 1758510880, 2067120, 1566000, 1461600, 2039280, 2039280, + 1900080, 1865280, 0, 3680844220, 2039280 + ], + "postBalances": [ + 1758505880, 2067120, 1566000, 1461600, 2039280, 2039280, + 1900080, 1865280, 0, 3680844220, 2039280 + ], + "innerInstructions": [ + { + "index": 0, + "instructions": [ + { + "programIdIndex": 13, + "accounts": [1, 15, 3, 4, 2, 14], + "data": "21TeLgZXNbtHXVBzCaiRmH" + }, + { + "programIdIndex": 14, + "accounts": [3, 4, 1], + "data": "6qfC8ic7Aq99" + }, + { + "programIdIndex": 13, + "accounts": [1, 15, 3, 5, 2, 14], + "data": "21TeLgZXNbsn4QEpaSEr3q" + }, + { + "programIdIndex": 14, + "accounts": [3, 5, 1], + "data": "6LC7BYyxhFRh" + } + ] + }, + { + "index": 1, + "instructions": [ + { + "programIdIndex": 14, + "accounts": [4, 3, 0], + "data": "7aUiLHFjSVdZ" + }, + { + "programIdIndex": 19, + "accounts": [17, 18, 16, 9, 11, 12, 14], + "data": "8kvZyjATKQWYxaKR1qD53V" + }, + { + "programIdIndex": 14, + "accounts": [9, 11, 18], + "data": "6qfC8ic7Aq99" + } + ] + } + ], + "logMessages": [ + "Program QMNeHCGYnLVDn1icRAfQZpjPLBNkfGbSKRB83G5d8KB invoke [1]", + "Program QMWoBmAyJLAsA1Lh9ugMTw2gciTihncciphzdNzdZYV invoke [2]" + ], + "preTokenBalances": [ + { + "accountIndex": 4, + "mint": "iouQcQBAiEXe6cKLS85zmZxUqaCqBdeHFpqKoSz615u", + "uiTokenAmount": { + "uiAmount": null, + "decimals": 6, + "amount": "0", + "uiAmountString": "0" + }, + "owner": "LieKvPRE8XeX3Y2xVNHjKlpAScD12lYySBVQ4HqoJ5op", + "programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "accountIndex": 5, + "mint": "iouQcQBAiEXe6cKLS85zmZxUqaCqBdeHFpqKoSz615u", + "uiTokenAmount": { + "uiAmount": 11513.0679, + "decimals": 6, + "amount": "11513067900", + "uiAmountString": "11513.0679" + }, + "owner": "rXhAofQCT7NN9TUqigyEAUzV1uLL4boeD8CRkNBSkYk", + "programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "accountIndex": 10, + "mint": "Saber2gLauYim4Mvftnrasomsv6NvAuncvMEZwcLpD1", + "uiTokenAmount": { + "uiAmount": null, + "decimals": 6, + "amount": "0", + "uiAmountString": "0" + }, + "owner": "CL9wkGFT3SZRRNa9dgaovuRV7jrVVigBUZ6DjcgySsCU", + "programId": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" + }, + { + "accountIndex": 11, + "mint": "Saber2gLauYim4Mvftnrasomsv6NvAuncvMEZwcLpD1", + "uiTokenAmount": { + "uiAmount": 15138.514093, + "decimals": 6, + "amount": "15138514093", + "uiAmountString": "15138.514093" + }, + "owner": "LieKvPRE8XeX3Y2xVNHjKlpAScD12lYySBVQ4HqoJ5op", + "programId": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" + } + ], + "postTokenBalances": [ + { + "accountIndex": 4, + "mint": "iouQcQBAiEXe6cKLS85zmZxUqaCqBdeHFpqKoSz615u", + "uiTokenAmount": { + "uiAmount": null, + "decimals": 6, + "amount": "0", + "uiAmountString": "0" + }, + "owner": "LieKvPRE8XeX3Y2xVNHjKlpAScD12lYySBVQ4HqoJ5op", + "programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "accountIndex": 5, + "mint": "iouQcQBAiEXe6cKLS85zmZxUqaCqBdeHFpqKoSz615u", + "uiTokenAmount": { + "uiAmount": 11513.103028, + "decimals": 6, + "amount": "11513103028", + "uiAmountString": "11513.103028" + }, + "owner": "rXhAofQCT7NN9TUqigyEAUzV1uLL4boeD8CRkNBSkYk", + "programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "accountIndex": 10, + "mint": "Saber2gLauYim4Mvftnrasomsv6NvAuncvMEZwcLpD1", + "uiTokenAmount": { + "uiAmount": null, + "decimals": 6, + "amount": "0", + "uiAmountString": "0" + }, + "owner": "CL9wkGFT3SZRRNa9dgaovuRV7jrVVigBUZ6DjcgySsCU", + "programId": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" + }, + { + "accountIndex": 11, + "mint": "Saber2gLauYim4Mvftnrasomsv6NvAuncvMEZwcLpD1", + "uiTokenAmount": { + "uiAmount": 15489.767829, + "decimals": 6, + "amount": "15489767829", + "uiAmountString": "15489.767829" + }, + "owner": "BeiHVPRE8XeX3Y2xVNrSsTpAScH94nYySBVQ4HqgN9at", + "programId": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" + } + ], + "rewards": [] + } + } + ], + "blockTime": 1639926816, + "blockHeight": 101210751 + }, + "err": null + } + }, + "subscription": 14 + } +} +``` + +
    diff --git a/docs/src/api/websocket/_blockUnsubscribe.mdx b/docs/src/api/websocket/_blockUnsubscribe.mdx new file mode 100644 index 00000000000000..a16b73ca639aa4 --- /dev/null +++ b/docs/src/api/websocket/_blockUnsubscribe.mdx @@ -0,0 +1,53 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## blockUnsubscribe + +Unsubscribe from block notifications + + + + +### Parameters: + + + subscription id to cancel + + +### Result: + +`` - unsubscribe success message + + + + + +### Code sample: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "blockUnsubscribe", + "params": [0] +} +``` + +### Response: + +```json +{ "jsonrpc": "2.0", "result": true, "id": 1 } +``` + + + + diff --git a/docs/src/api/websocket/_logsSubscribe.mdx b/docs/src/api/websocket/_logsSubscribe.mdx new file mode 100644 index 00000000000000..f715bb8b521bac --- /dev/null +++ b/docs/src/api/websocket/_logsSubscribe.mdx @@ -0,0 +1,130 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## logsSubscribe + +Subscribe to transaction logging + + + + +### Parameters: + + + filter criteria for the logs to receive results by account type. The following filters types are currently supported: + + + +A string with one of the following values: + +- `all` - subscribe to all transactions except for simple vote transactions +- `allWithVotes` - subscribe to all transactions including simple vote transactions + + + + + +An object with the following field: + +- `mentions: [ ]` - array of Pubkeys (as base-58 encoded strings) to listen for being mentioned in any transaction + + + + + + + +Configuration object containing the following fields: + + + + + +### Result: + +`` - Subscription id \(needed to unsubscribe\) + + + + + +### Code sample: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "logsSubscribe", + "params": [ + { + "mentions": [ "11111111111111111111111111111111" ] + }, + { + "commitment": "finalized" + } + ] +} +{ + "jsonrpc": "2.0", + "id": 1, + "method": "logsSubscribe", + "params": [ "all" ] +} +``` + +### Response: + +```json +{ "jsonrpc": "2.0", "result": 24040, "id": 1 } +``` + + + + +#### Notification Format: + +The notification will be an RpcResponse JSON object with value equal to: + +- `signature: ` - The transaction signature base58 encoded. +- `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) +- `logs: ` - Array of log messages the transaction instructions output during execution, null if simulation failed before the transaction was able to execute (for example due to an invalid blockhash or signature verification failure) + +Example: + +```json +{ + "jsonrpc": "2.0", + "method": "logsNotification", + "params": { + "result": { + "context": { + "slot": 5208469 + }, + "value": { + "signature": "5h6xBEauJ3PK6SWCZ1PGjBvj8vDdWG3KpwATGy1ARAXFSDwt8GFXM7W5Ncn16wmqokgpiKRLuS83KUxyZyv2sUYv", + "err": null, + "logs": [ + "SBF program 83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri success" + ] + } + }, + "subscription": 24040 + } +} +``` + + diff --git a/docs/src/api/websocket/_logsUnsubscribe.mdx b/docs/src/api/websocket/_logsUnsubscribe.mdx new file mode 100644 index 00000000000000..6a75606eb02b06 --- /dev/null +++ b/docs/src/api/websocket/_logsUnsubscribe.mdx @@ -0,0 +1,53 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## logsUnsubscribe + +Unsubscribe from transaction logging + + + + +### Parameters: + + + subscription id to cancel + + +### Result: + +`` - unsubscribe success message + + + + + +### Code sample: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "logsUnsubscribe", + "params": [0] +} +``` + +### Response: + +```json +{ "jsonrpc": "2.0", "result": true, "id": 1 } +``` + + + + diff --git a/docs/src/api/websocket/_programSubscribe.mdx b/docs/src/api/websocket/_programSubscribe.mdx new file mode 100644 index 00000000000000..bea83bac6c0fad --- /dev/null +++ b/docs/src/api/websocket/_programSubscribe.mdx @@ -0,0 +1,205 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## programSubscribe + +Subscribe to a program to receive notifications when the lamports or data for an account owned by the given program changes + + + + +### Parameters: + + + +Pubkey of the `program_id`, as base-58 encoded string + + + + + +Configuration object containing the following fields: + + + + + +filter results using various [filter objects](/api/http#filter-criteria) + +:::info +The resultant account must meet **ALL** filter criteria to be included in the returned results +::: + + + + + +Encoding format for Account data + + + +
    + +- `base58` is slow. +- [`jsonParsed`](/api/http#parsed-responses">) 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 `string`. + +
    + +
    + +
    + +### Result: + +`` - Subscription id \(needed to unsubscribe\) + +
    + + + +### Code sample: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "programSubscribe", + "params": [ + "11111111111111111111111111111111", + { + "encoding": "base64", + "commitment": "finalized" + } + ] +} +{ + "jsonrpc": "2.0", + "id": 1, + "method": "programSubscribe", + "params": [ + "11111111111111111111111111111111", + { + "encoding": "jsonParsed" + } + ] +} +{ + "jsonrpc": "2.0", + "id": 1, + "method": "programSubscribe", + "params": [ + "11111111111111111111111111111111", + { + "encoding": "base64", + "filters": [ + { + "dataSize": 80 + } + ] + } + ] +} +``` + +### Response: + +```json +{ "jsonrpc": "2.0", "result": 24040, "id": 1 } +``` + + +
    + +#### Notification format + +The notification format is a single program account object as seen in the [getProgramAccounts](/api/http#getprogramaccounts) RPC HTTP method. + +Base58 encoding: + +```json +{ + "jsonrpc": "2.0", + "method": "programNotification", + "params": { + "result": { + "context": { + "slot": 5208469 + }, + "value": { + "pubkey": "H4vnBqifaSACnKa7acsxstsY1iV1bvJNxsCY7enrd1hq", + "account": { + "data": [ + "11116bv5nS2h3y12kD1yUKeMZvGcKLSjQgX6BeV7u1FrjeJcKfsHPXHRDEHrBesJhZyqnnq9qJeUuF7WHxiuLuL5twc38w2TXNLxnDbjmuR", + "base58" + ], + "executable": false, + "lamports": 33594, + "owner": "11111111111111111111111111111111", + "rentEpoch": 636, + "space": 80 + } + } + }, + "subscription": 24040 + } +} +``` + +Parsed-JSON encoding: + +```json +{ + "jsonrpc": "2.0", + "method": "programNotification", + "params": { + "result": { + "context": { + "slot": 5208469 + }, + "value": { + "pubkey": "H4vnBqifaSACnKa7acsxstsY1iV1bvJNxsCY7enrd1hq", + "account": { + "data": { + "program": "nonce", + "parsed": { + "type": "initialized", + "info": { + "authority": "Bbqg1M4YVVfbhEzwA9SpC9FhsaG83YMTYoR4a8oTDLX", + "blockhash": "LUaQTmM7WbMRiATdMMHaRGakPtCkc2GHtH57STKXs6k", + "feeCalculator": { + "lamportsPerSignature": 5000 + } + } + } + }, + "executable": false, + "lamports": 33594, + "owner": "11111111111111111111111111111111", + "rentEpoch": 636, + "space": 80 + } + } + }, + "subscription": 24040 + } +} +``` + +
    diff --git a/docs/src/api/websocket/_programUnsubscribe.mdx b/docs/src/api/websocket/_programUnsubscribe.mdx new file mode 100644 index 00000000000000..b3decdcb9a50fe --- /dev/null +++ b/docs/src/api/websocket/_programUnsubscribe.mdx @@ -0,0 +1,53 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## programUnsubscribe + +Unsubscribe from program-owned account change notifications + + + + +### Parameters: + + + id of account Subscription to cancel + + +### Result: + +`` - unsubscribe success message + + + + + +### Code sample: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "programUnsubscribe", + "params": [0] +} +``` + +### Response: + +```json +{ "jsonrpc": "2.0", "result": true, "id": 1 } +``` + + + + diff --git a/docs/src/api/websocket/_rootSubscribe.mdx b/docs/src/api/websocket/_rootSubscribe.mdx new file mode 100644 index 00000000000000..98fd59407f023b --- /dev/null +++ b/docs/src/api/websocket/_rootSubscribe.mdx @@ -0,0 +1,62 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## rootSubscribe + +Subscribe to receive notification anytime a new root is set by the validator. + + + + +### Parameters: + +**None** + +### Result: + +`integer` - subscription id \(needed to unsubscribe\) + + + + + +### Code sample: + +```json +{ "jsonrpc": "2.0", "id": 1, "method": "rootSubscribe" } +``` + +### Response: + +```json +{ "jsonrpc": "2.0", "result": 0, "id": 1 } +``` + + + + +#### Notification Format: + +The result is the latest root slot number. + +```json +{ + "jsonrpc": "2.0", + "method": "rootNotification", + "params": { + "result": 42, + "subscription": 0 + } +} +``` + + diff --git a/docs/src/api/websocket/_rootUnsubscribe.mdx b/docs/src/api/websocket/_rootUnsubscribe.mdx new file mode 100644 index 00000000000000..8d4085f183678f --- /dev/null +++ b/docs/src/api/websocket/_rootUnsubscribe.mdx @@ -0,0 +1,53 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## rootUnsubscribe + +Unsubscribe from root notifications + + + + +### Parameters: + + + subscription id to cancel + + +### Result: + +`` - unsubscribe success message + + + + + +### Code sample: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "rootUnsubscribe", + "params": [0] +} +``` + +### Response: + +```json +{ "jsonrpc": "2.0", "result": true, "id": 1 } +``` + + + + diff --git a/docs/src/api/websocket/_signatureSubscribe.mdx b/docs/src/api/websocket/_signatureSubscribe.mdx new file mode 100644 index 00000000000000..70d0b602693593 --- /dev/null +++ b/docs/src/api/websocket/_signatureSubscribe.mdx @@ -0,0 +1,98 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## signatureSubscribe + +Subscribe to a transaction signature to receive notification when a given transaction is committed. On `signatureNotification` - the subscription is automatically cancelled. + + + + +### Parameters: + + + Transaction Signature, as base-58 encoded string + + + + +Configuration object containing the following fields: + + + + + +### Result: + +`` - subscription id (needed to unsubscribe) + + + + + +### Code sample: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "signatureSubscribe", + "params": [ + "2EBVM6cB8vAAD93Ktr6Vd8p67XPbQzCJX47MpReuiCXJAtcjaxpvWpcg9Ege1Nr5Tk3a2GFrByT7WPBjdsTycY9b", + { + "commitment": "finalized" + } + ] +} +``` + +### Response: + +```json +{ "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", + "method": "signatureNotification", + "params": { + "result": { + "context": { + "slot": 5207624 + }, + "value": { + "err": null + } + }, + "subscription": 24006 + } +} +``` + + diff --git a/docs/src/api/websocket/_signatureUnsubscribe.mdx b/docs/src/api/websocket/_signatureUnsubscribe.mdx new file mode 100644 index 00000000000000..880efed7c49fe7 --- /dev/null +++ b/docs/src/api/websocket/_signatureUnsubscribe.mdx @@ -0,0 +1,53 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## signatureUnsubscribe + +Unsubscribe from signature confirmation notification + + + + +### Parameters: + + + subscription id to cancel + + +### Result: + +`` - unsubscribe success message + + + + + +### Code sample: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "signatureUnsubscribe", + "params": [0] +} +``` + +### Response: + +```json +{ "jsonrpc": "2.0", "result": true, "id": 1 } +``` + + + + diff --git a/docs/src/api/websocket/_slotSubscribe.mdx b/docs/src/api/websocket/_slotSubscribe.mdx new file mode 100644 index 00000000000000..c746ff060e5b22 --- /dev/null +++ b/docs/src/api/websocket/_slotSubscribe.mdx @@ -0,0 +1,72 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## slotSubscribe + +Subscribe to receive notification anytime a slot is processed by the validator + + + + +### Parameters: + +**None** + +### Result: + +`` - Subscription id \(needed to unsubscribe\) + + + + + +### Code sample: + +```json +{ "jsonrpc": "2.0", "id": 1, "method": "slotSubscribe" } +``` + +### Response: + +```json +{ "jsonrpc": "2.0", "result": 0, "id": 1 } +``` + + + + +#### Notification Format: + +The notification will be an object with the following fields: + +- `parent: ` - The parent slot +- `root: ` - The current root slot +- `slot: ` - The newly set slot value + +Example: + +```json +{ + "jsonrpc": "2.0", + "method": "slotNotification", + "params": { + "result": { + "parent": 75, + "root": 44, + "slot": 76 + }, + "subscription": 0 + } +} +``` + + diff --git a/docs/src/api/websocket/_slotUnsubscribe.mdx b/docs/src/api/websocket/_slotUnsubscribe.mdx new file mode 100644 index 00000000000000..0ce506163c87ca --- /dev/null +++ b/docs/src/api/websocket/_slotUnsubscribe.mdx @@ -0,0 +1,53 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## slotUnsubscribe + +Unsubscribe from slot notifications + + + + +### Parameters: + + + subscription id to cancel + + +### Result: + +`` - unsubscribe success message + + + + + +### Code sample: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "slotUnsubscribe", + "params": [0] +} +``` + +### Response: + +```json +{ "jsonrpc": "2.0", "result": true, "id": 1 } +``` + + + + diff --git a/docs/src/api/websocket/_slotsUpdatesSubscribe.mdx b/docs/src/api/websocket/_slotsUpdatesSubscribe.mdx new file mode 100644 index 00000000000000..efb639b2034958 --- /dev/null +++ b/docs/src/api/websocket/_slotsUpdatesSubscribe.mdx @@ -0,0 +1,86 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## slotsUpdatesSubscribe + +Subscribe to receive a notification from the validator on a variety of updates +on every slot + +:::caution +This subscription is unstable + +**NOTE: the format of this subscription may change in the future and it may not always be supported** +::: + + + + +### Parameters: + +**None** + +### Result: + +`` - Subscription id (needed to unsubscribe) + + + + + +### Code sample: + +```json +{ "jsonrpc": "2.0", "id": 1, "method": "slotsUpdatesSubscribe" } +``` + +### Response: + +```json +{ "jsonrpc": "2.0", "result": 0, "id": 1 } +``` + + + + +#### Notification Format: + +The notification will be an object with the following fields: + +- `parent: ` - The parent slot +- `slot: ` - The newly updated slot +- `timestamp: ` - The Unix timestamp of the update +- `type: ` - The update type, one of: + - "firstShredReceived" + - "completed" + - "createdBank" + - "frozen" + - "dead" + - "optimisticConfirmation" + - "root" + +```bash +{ + "jsonrpc": "2.0", + "method": "slotsUpdatesNotification", + "params": { + "result": { + "parent": 75, + "slot": 76, + "timestamp": 1625081266243, + "type": "optimisticConfirmation" + }, + "subscription": 0 + } +} +``` + + diff --git a/docs/src/api/websocket/_slotsUpdatesUnsubscribe.mdx b/docs/src/api/websocket/_slotsUpdatesUnsubscribe.mdx new file mode 100644 index 00000000000000..8169e52118781b --- /dev/null +++ b/docs/src/api/websocket/_slotsUpdatesUnsubscribe.mdx @@ -0,0 +1,53 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## slotsUpdatesUnsubscribe + +Unsubscribe from slot-update notifications + + + + +### Parameters: + + + subscription id to cancel + + +### Result: + +`` - unsubscribe success message + + + + + +### Code sample: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "slotsUpdatesUnsubscribe", + "params": [0] +} +``` + +### Response: + +```json +{ "jsonrpc": "2.0", "result": true, "id": 1 } +``` + + + + diff --git a/docs/src/api/websocket/_voteSubscribe.mdx b/docs/src/api/websocket/_voteSubscribe.mdx new file mode 100644 index 00000000000000..4f6f9cc87be982 --- /dev/null +++ b/docs/src/api/websocket/_voteSubscribe.mdx @@ -0,0 +1,79 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## voteSubscribe + +Subscribe to receive notification anytime a new vote is observed in gossip. +These votes are pre-consensus therefore there is no guarantee these votes will +enter the ledger. + +:::caution +This subscription is unstable and only available if the validator was started +with the `--rpc-pubsub-enable-vote-subscription` flag. The format of this +subscription may change in the future +::: + + + + +### Parameters: + +**None** + +### Result: + +`` - subscription id (needed to unsubscribe) + + + + + +### Code sample: + +```json +{ "jsonrpc": "2.0", "id": 1, "method": "voteSubscribe" } +``` + +### Response: + +```json +{ "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 +- `signature: ` - The signature of the transaction that contained this vote + +```json +{ + "jsonrpc": "2.0", + "method": "voteNotification", + "params": { + "result": { + "hash": "8Rshv2oMkPu5E4opXTRyuyBeZBqQ4S477VG26wUTFxUM", + "slots": [1, 2], + "timestamp": null + }, + "subscription": 0 + } +} +``` + + diff --git a/docs/src/api/websocket/_voteUnsubscribe.mdx b/docs/src/api/websocket/_voteUnsubscribe.mdx new file mode 100644 index 00000000000000..db37b4205479a1 --- /dev/null +++ b/docs/src/api/websocket/_voteUnsubscribe.mdx @@ -0,0 +1,53 @@ +import { + DocBlock, + DocSideBySide, + CodeParams, + Parameter, + Field, + Values, + CodeSnippets, +} from "../../../components/CodeDocBlock"; + + + +## voteUnsubscribe + +Unsubscribe from vote notifications + + + + +### Parameters: + + + subscription id to cancel + + +### Result: + +`` - unsubscribe success message + + + + + +### Code sample: + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "voteUnsubscribe", + "params": [0] +} +``` + +### Response: + +```json +{ "jsonrpc": "2.0", "result": true, "id": 1 } +``` + + + + diff --git a/docs/src/cluster/rpc-endpoints.md b/docs/src/cluster/rpc-endpoints.md index 9ae28f7cd5c3b3..50173fa9087334 100644 --- a/docs/src/cluster/rpc-endpoints.md +++ b/docs/src/cluster/rpc-endpoints.md @@ -2,7 +2,7 @@ title: Solana Cluster RPC Endpoints --- -Solana maintains dedicated api nodes to fulfill [JSON-RPC](developing/clients/jsonrpc-api.md) +Solana maintains dedicated api nodes to fulfill [JSON-RPC](/api) requests for each public cluster, and third parties may as well. Here are the public RPC endpoints currently available and recommended for each public cluster: @@ -36,7 +36,7 @@ public RPC endpoints currently available and recommended for each public cluster ## Mainnet Beta -#### Endpoints* +#### Endpoints\* - `https://api.mainnet-beta.solana.com` - Solana-hosted api node cluster, backed by a load balancer; rate-limited @@ -48,7 +48,7 @@ public RPC endpoints currently available and recommended for each public cluster - Maximum connection rate per 10 seconds per IP: 40 - Maximum amount of data per 30 second: 100 MB -*The public RPC endpoints are not intended for production applications. Please +\*The public RPC endpoints are not intended for production applications. Please use dedicated/private RPC servers when you launch your application, drop NFTs, etc. The public services are subject to abuse and rate limits may change without prior notice. Likewise, high-traffic websites may be blocked without @@ -58,6 +58,6 @@ prior notice. - 403 -- Your IP address or website has been blocked. It is time to run your own RPC server(s) or find a private service. - 429 -- Your IP address is exceeding the rate limits. Slow down! Use the -[Retry-After](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After) -HTTP response header to determine how long to wait before making another -request. + [Retry-After](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After) + HTTP response header to determine how long to wait before making another + request. diff --git a/docs/src/developing/clients/javascript-api.md b/docs/src/developing/clients/javascript-api.md index 862905b39bc71d..8dad0f46a00698 100644 --- a/docs/src/developing/clients/javascript-api.md +++ b/docs/src/developing/clients/javascript-api.md @@ -4,7 +4,7 @@ title: Web3 JavaScript API ## What is Solana-Web3.js? -The Solana-Web3.js library aims to provide complete coverage of Solana. The library was built on top of the [Solana JSON RPC API](../clients/jsonrpc-api.md). +The Solana-Web3.js library aims to provide complete coverage of Solana. The library was built on top of the [Solana JSON RPC API](/api). You can find the full documentation for the `@solana/web3.js` library [here](https://solana-labs.github.io/solana-web3.js/). diff --git a/docs/src/developing/clients/javascript-reference.md b/docs/src/developing/clients/javascript-reference.md index 91b346bee64342..4d7dfd6c9a962b 100644 --- a/docs/src/developing/clients/javascript-reference.md +++ b/docs/src/developing/clients/javascript-reference.md @@ -4,7 +4,7 @@ title: Web3 API Reference ## Web3 API Reference Guide -The `@solana/web3.js` library is a package that has coverage over the [Solana JSON RPC API](../clients/jsonrpc-api.md). +The `@solana/web3.js` library is a package that has coverage over the [Solana JSON RPC API](/api). You can find the full documentation for the `@solana/web3.js` library [here](https://solana-labs.github.io/solana-web3.js/). @@ -14,7 +14,7 @@ You can find the full documentation for the `@solana/web3.js` library [here](htt [Source Documentation](https://solana-labs.github.io/solana-web3.js/classes/Connection.html) -Connection is used to interact with the [Solana JSON RPC](../clients/jsonrpc-api.md). You can use Connection to confirm transactions, get account info, and more. +Connection is used to interact with the [Solana JSON RPC](/api). You can use Connection to confirm transactions, get account info, and more. You create a connection by defining the JSON RPC cluster endpoint and the desired commitment. Once this is complete, you can use this connection object to interact with any of the Solana JSON RPC API. diff --git a/docs/src/developing/clients/jsonrpc-api.md b/docs/src/developing/clients/jsonrpc-api.md deleted file mode 100644 index a729ee70cf3064..00000000000000 --- a/docs/src/developing/clients/jsonrpc-api.md +++ /dev/null @@ -1,5490 +0,0 @@ ---- -title: JSON RPC API ---- - -Solana nodes accept HTTP requests using the [JSON-RPC 2.0](https://www.jsonrpc.org/specification) specification. - -To interact with a Solana node inside a JavaScript application, use the -[solana-web3.js](https://github.com/solana-labs/solana-web3.js) library, which -gives a convenient interface for the RPC methods. - -## RPC HTTP Endpoint - -**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 e.g. ws://localhost:8900, [http://192.168.1.88:8900](http://192.168.1.88:8900) - -## Methods - -- [getAccountInfo](jsonrpc-api.md#getaccountinfo) -- [getBalance](jsonrpc-api.md#getbalance) -- [getBlock](jsonrpc-api.md#getblock) -- [getBlockHeight](jsonrpc-api.md#getblockheight) -- [getBlockProduction](jsonrpc-api.md#getblockproduction) -- [getBlockCommitment](jsonrpc-api.md#getblockcommitment) -- [getBlocks](jsonrpc-api.md#getblocks) -- [getBlocksWithLimit](jsonrpc-api.md#getblockswithlimit) -- [getBlockTime](jsonrpc-api.md#getblocktime) -- [getClusterNodes](jsonrpc-api.md#getclusternodes) -- [getEpochInfo](jsonrpc-api.md#getepochinfo) -- [getEpochSchedule](jsonrpc-api.md#getepochschedule) -- [getFeeForMessage](jsonrpc-api.md#getfeeformessage) -- [getFirstAvailableBlock](jsonrpc-api.md#getfirstavailableblock) -- [getGenesisHash](jsonrpc-api.md#getgenesishash) -- [getHealth](jsonrpc-api.md#gethealth) -- [getHighestSnapshotSlot](jsonrpc-api.md#gethighestsnapshotslot) -- [getIdentity](jsonrpc-api.md#getidentity) -- [getInflationGovernor](jsonrpc-api.md#getinflationgovernor) -- [getInflationRate](jsonrpc-api.md#getinflationrate) -- [getInflationReward](jsonrpc-api.md#getinflationreward) -- [getLargestAccounts](jsonrpc-api.md#getlargestaccounts) -- [getLatestBlockhash](jsonrpc-api.md#getlatestblockhash) -- [getLeaderSchedule](jsonrpc-api.md#getleaderschedule) -- [getMaxRetransmitSlot](jsonrpc-api.md#getmaxretransmitslot) -- [getMaxShredInsertSlot](jsonrpc-api.md#getmaxshredinsertslot) -- [getMinimumBalanceForRentExemption](jsonrpc-api.md#getminimumbalanceforrentexemption) -- [getMultipleAccounts](jsonrpc-api.md#getmultipleaccounts) -- [getProgramAccounts](jsonrpc-api.md#getprogramaccounts) -- [getRecentPerformanceSamples](jsonrpc-api.md#getrecentperformancesamples) -- [getRecentPrioritizationFees](jsonrpc-api.md#getrecentprioritizationfees) -- [getSignaturesForAddress](jsonrpc-api.md#getsignaturesforaddress) -- [getSignatureStatuses](jsonrpc-api.md#getsignaturestatuses) -- [getSlot](jsonrpc-api.md#getslot) -- [getSlotLeader](jsonrpc-api.md#getslotleader) -- [getSlotLeaders](jsonrpc-api.md#getslotleaders) -- [getStakeActivation](jsonrpc-api.md#getstakeactivation) -- [getStakeMinimumDelegation](jsonrpc-api.md#getstakeminimumdelegation) -- [getSupply](jsonrpc-api.md#getsupply) -- [getTokenAccountBalance](jsonrpc-api.md#gettokenaccountbalance) -- [getTokenAccountsByDelegate](jsonrpc-api.md#gettokenaccountsbydelegate) -- [getTokenAccountsByOwner](jsonrpc-api.md#gettokenaccountsbyowner) -- [getTokenLargestAccounts](jsonrpc-api.md#gettokenlargestaccounts) -- [getTokenSupply](jsonrpc-api.md#gettokensupply) -- [getTransaction](jsonrpc-api.md#gettransaction) -- [getTransactionCount](jsonrpc-api.md#gettransactioncount) -- [getVersion](jsonrpc-api.md#getversion) -- [getVoteAccounts](jsonrpc-api.md#getvoteaccounts) -- [isBlockhashValid](jsonrpc-api.md#isblockhashvalid) -- [minimumLedgerSlot](jsonrpc-api.md#minimumledgerslot) -- [requestAirdrop](jsonrpc-api.md#requestairdrop) -- [sendTransaction](jsonrpc-api.md#sendtransaction) -- [simulateTransaction](jsonrpc-api.md#simulatetransaction) -- [Subscription Websocket](jsonrpc-api.md#subscription-websocket) - - [accountSubscribe](jsonrpc-api.md#accountsubscribe) - - [accountUnsubscribe](jsonrpc-api.md#accountunsubscribe) - - [logsSubscribe](jsonrpc-api.md#logssubscribe) - - [logsUnsubscribe](jsonrpc-api.md#logsunsubscribe) - - [programSubscribe](jsonrpc-api.md#programsubscribe) - - [programUnsubscribe](jsonrpc-api.md#programunsubscribe) - - [signatureSubscribe](jsonrpc-api.md#signaturesubscribe) - - [signatureUnsubscribe](jsonrpc-api.md#signatureunsubscribe) - - [slotSubscribe](jsonrpc-api.md#slotsubscribe) - - [slotUnsubscribe](jsonrpc-api.md#slotunsubscribe) - -### Unstable Methods - -Unstable methods may see breaking changes in patch releases and may not be supported in perpetuity. - -- [blockSubscribe](jsonrpc-api.md#blocksubscribe---unstable-disabled-by-default) -- [blockUnsubscribe](jsonrpc-api.md#blockunsubscribe) -- [slotsUpdatesSubscribe](jsonrpc-api.md#slotsupdatessubscribe---unstable) -- [slotsUpdatesUnsubscribe](jsonrpc-api.md#slotsupdatesunsubscribe) -- [voteSubscribe](jsonrpc-api.md#votesubscribe---unstable-disabled-by-default) -- [voteUnsubscribe](jsonrpc-api.md#voteunsubscribe) - -### Deprecated Methods - -- [getConfirmedBlock](jsonrpc-api.md#getconfirmedblock) -- [getConfirmedBlocks](jsonrpc-api.md#getconfirmedblocks) -- [getConfirmedBlocksWithLimit](jsonrpc-api.md#getconfirmedblockswithlimit) -- [getConfirmedSignaturesForAddress2](jsonrpc-api.md#getconfirmedsignaturesforaddress2) -- [getConfirmedTransaction](jsonrpc-api.md#getconfirmedtransaction) -- [getFeeCalculatorForBlockhash](jsonrpc-api.md#getfeecalculatorforblockhash) -- [getFeeRateGovernor](jsonrpc-api.md#getfeerategovernor) -- [getFees](jsonrpc-api.md#getfees) -- [getRecentBlockhash](jsonrpc-api.md#getrecentblockhash) -- [getSnapshotSlot](jsonrpc-api.md#getsnapshotslot) - -## 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: - -- `jsonrpc: `, set to `"2.0"` -- `id: `, a unique client-generated identifying integer -- `method: `, a string containing the method to be invoked -- `params: `, a JSON array of ordered parameter values - -Example using curl: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - { - "jsonrpc": "2.0", - "id": 1, - "method": "getBalance", - "params": [ - "83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri" - ] - } -' -``` - -The response output will be a JSON object with the following fields: - -- `jsonrpc: `, matching the request specification -- `id: `, matching the request identifier -- `result: `, requested data or success confirmation - -Requests can be sent in batches by sending an array of JSON-RPC request objects as the data for a single POST. - -## Definitions - -- Hash: A SHA-256 hash of a chunk of data. -- Pubkey: The public key of a Ed25519 key-pair. -- Transaction: A list of Solana instructions signed by a client keypair to authorize those actions. -- Signature: An Ed25519 signature of transaction's payload data including instructions. This can be used to identify transactions. - -## Configuring State Commitment - -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 -querying the ledger state, it's recommended to use lower levels of commitment -to report progress and higher levels to ensure the state will not be rolled back. - -In descending order of commitment (most finalized to least finalized), clients -may specify: - -- `"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 -- `"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. - -For processing many dependent transactions in series, it's recommended to use -`"confirmed"` commitment, which balances speed with rollback safety. -For total safety, it's recommended to use`"finalized"` commitment. - -#### Example - -The commitment parameter should be included as the last element in the `params` array: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - { - "jsonrpc": "2.0", - "id": 1, - "method": "getBalance", - "params": [ - "83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri", - { - "commitment": "finalized" - } - ] - } -' -``` - -#### Default: - -If commitment configuration is not provided, the node will default to `"finalized"` commitment - -Only methods that query bank state accept the commitment parameter. They are indicated in the API Reference below. - -#### RpcResponse Structure - -Many methods that take a commitment parameter return an RpcResponse JSON object comprised of two parts: - -- `context` : An RpcResponseContext JSON structure including a `slot` field at which the operation was evaluated. -- `value` : The value returned by the operation itself. - -#### Parsed Responses - -Some methods support an `encoding` parameter, and can return account or -instruction data in parsed JSON format if `"encoding":"jsonParsed"` is requested -and the node has a parser for the owning program. Solana nodes currently support -JSON parsing for the following native and SPL programs: - -| Program | Account State | Instructions | -| --- | --- | --- | -| Address Lookup | v1.14.4 | v1.14.4 | -| BPF Loader | n/a | stable | -| BPF Upgradeable Loader | stable | stable | -| Config | stable | | -| SPL Associated Token Account | n/a | stable | -| SPL Memo | n/a | stable | -| SPL Token | stable | stable | -| SPL Token 2022 | stable | stable | -| Stake | stable | stable | -| Vote | stable | stable | - -The list of account parsers can be found [here](https://github.com/solana-labs/solana/blob/master/account-decoder/src/parse_account_data.rs), and instruction parsers [here](https://github.com/solana-labs/solana/blob/master/transaction-status/src/parse_instruction.rs). - -## Health Check - -Although not a JSON RPC API, a `GET /health` at the RPC HTTP Endpoint provides a -health-check mechanism for use by load balancers or other network -infrastructure. This request will always return a HTTP 200 OK response with a body of -"ok", "behind" or "unknown" based on the following conditions: - -1. 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 "behind". "unknown" is returned when no slot - information from known validators is not yet available. -2. "ok" is always returned if no known validators are provided. - -## JSON RPC API Reference - -### getAccountInfo - -Returns all information associated with the account of provided Pubkey - -#### Parameters: - -- `` - Pubkey of account to query, as base-58 encoded string -- (optional) `` - Configuration object containing the following fields: - - (optional) `commitment: ` - [Commitment](jsonrpc-api.md#configuring-state-commitment) - - (optional) `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](jsonrpc-api.md#parsed-responses) 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. - - (optional) `minContextSlot: ` - set the minimum slot that the request can be evaluated at. - -#### Results: - -The result will be an RpcResponse JSON object with `value` equal to: - -- `` - if the requested account doesn't exist -- `` - otherwise, a JSON object containing: - - `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": "getAccountInfo", - "params": [ - "vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg", - { - "encoding": "base58" - } - ] - } -' -``` - -Response: - -```json -{ - "jsonrpc": "2.0", - "result": { - "context": { - "slot": 1 - }, - "value": { - "data": [ - "11116bv5nS2h3y12kD1yUKeMZvGcKLSjQgX6BeV7u1FrjeJcKfsHRTPuR3oZ1EioKtYGiYxpxMG5vpbZLsbcBYBEmZZcMKaSoGx9JZeAuWf", - "base58" - ], - "executable": false, - "lamports": 1000000000, - "owner": "11111111111111111111111111111111", - "rentEpoch": 2 - } - }, - "id": 1 -} -``` - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - { - "jsonrpc": "2.0", - "id": 1, - "method": "getAccountInfo", - "params": [ - "4fYNw3dojWmQ4dXtSGE9epjRGy9pFSx62YypT7avPYvA", - { - "encoding": "jsonParsed" - } - ] - } -' -``` - -Response: - -```json -{ - "jsonrpc": "2.0", - "result": { - "context": { - "slot": 1 - }, - "value": { - "data": { - "nonce": { - "initialized": { - "authority": "Bbqg1M4YVVfbhEzwA9SpC9FhsaG83YMTYoR4a8oTDLX", - "blockhash": "3xLP3jK6dVJwpeGeTDYTwdDK3TKchUf1gYYGHa4sF3XJ", - "feeCalculator": { - "lamportsPerSignature": 5000 - } - } - } - }, - "executable": false, - "lamports": 1000000000, - "owner": "11111111111111111111111111111111", - "rentEpoch": 2 - } - }, - "id": 1 -} -``` - -### getBalance - -Returns the balance of the account of provided Pubkey - -#### Parameters: - -- `` - Pubkey of account to query, as base-58 encoded string -- (optional) `` - Configuration object containing the following fields: - - (optional) `commitment: ` - [Commitment](jsonrpc-api.md#configuring-state-commitment) - - (optional) `minContextSlot: ` - set the minimum slot that the request can be evaluated at. - -#### Results: - -- `RpcResponse` - RpcResponse JSON object with `value` field set to the balance - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc":"2.0", "id":1, "method":"getBalance", "params":["83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri"]} -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": { "context": { "slot": 1 }, "value": 0 }, - "id": 1 -} -``` - -### getBlock - -Returns identity and transaction information about a confirmed block in the ledger - -#### Parameters: - -- `` - 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](jsonrpc-api.md#parsed-responses) 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", "accounts", "signatures", or "none". If parameter not provided, the default detail level is "full". If "accounts" are requested, transaction details only include signatures and an annotated list of accounts in each transaction. Transaction metadata is limited to only: fee, err, pre_balances, post_balances, pre_token_balances, and post_token_balances. - - (optional) `rewards: bool` - whether to populate the `rewards` array. If parameter not provided, the default includes rewards. - - (optional) `commitment: ` - [Commitment](jsonrpc-api.md#configuring-state-commitment); "processed" is not supported. If parameter not provided, the default is "finalized". - - (optional) `maxSupportedTransactionVersion: ` - set the max transaction version to return in responses. If the requested block contains a transaction with a higher version, an error will be returned. If this parameter is omitted, only legacy transactions will be returned, and a block containing any versioned transaction will prompt the error. - -#### Results: - -The result field will be an object with the following fields: - -- `` - if specified block is not confirmed -- `` - if block is confirmed, an object with the following fields: - - `blockhash: ` - the blockhash of this block, as base-58 encoded string - - `previousBlockhash: ` - the blockhash of this block's parent, as base-58 encoded string; if the parent block is not available due to ledger cleanup, this field will return "11111111111111111111111111111111" - - `parentSlot: ` - the slot index of this block's parent - - `transactions: ` - present if "full" transaction details are requested; an array of JSON objects containing: - - `transaction: ` - [Transaction](#transaction-structure) object, either in JSON format or encoded binary data, depending on encoding parameter - - `meta: ` - transaction status metadata object, containing `null` or: - - `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) - - `fee: ` - fee this transaction was charged, as u64 integer - - `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 - - `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 - - `rewards: ` - transaction-level rewards, populated if rewards are requested; an array of JSON objects containing: - - `pubkey: ` - The public key, as base-58 encoded string, of the account that received the reward - - `lamports: `- number of reward lamports credited or debited by the account, as a i64 - - `postBalance: ` - account balance in lamports after the reward was applied - - `rewardType: ` - type of reward: "fee", "rent", "voting", "staking" - - `commission: ` - vote account commission when the reward was credited, only present for voting and staking rewards - - DEPRECATED: `status: ` - Transaction status - - `"Ok": ` - Transaction was successful - - `"Err": ` - Transaction failed with TransactionError - - `loadedAddresses: ` - Transaction addresses loaded from address lookup tables. Undefined if `maxSupportedTransactionVersion` is not set in request params. - - `writable: ` - Ordered list of base-58 encoded addresses for writable loaded accounts - - `readonly: ` - Ordered list of base-58 encoded addresses for readonly loaded accounts - - `returnData: ` - the most-recent return data generated by an instruction in the transaction, with the following fields: - - `programId: `, the program that generated the return data, as base-58 encoded Pubkey - - `data: <[string, encoding]>`, the return data itself, as base-64 encoded binary data - - `computeUnitsConsumed: `, number of [compute units](developing/programming-model/runtime.md#compute-budget) consumed by the transaction - - `version: <"legacy"|number|undefined>` - Transaction version. Undefined if `maxSupportedTransactionVersion` is not set in request params. - - `signatures: ` - present if "signatures" are requested for transaction details; an array of signatures strings, corresponding to the transaction order in the block - - `rewards: ` - block-level rewards, present if rewards are requested; an array of JSON objects containing: - - `pubkey: ` - The public key, as base-58 encoded string, of the account that received the reward - - `lamports: `- number of reward lamports credited or debited by the account, as a i64 - - `postBalance: ` - account balance in lamports after the reward was applied - - `rewardType: ` - type of reward: "fee", "rent", "voting", "staking" - - `commission: ` - vote account commission when the reward was credited, only present for voting and staking rewards - - `blockTime: ` - estimated production time, as Unix timestamp (seconds since the Unix epoch). null if not available - - `blockHeight: ` - the number of blocks beneath this block - -#### 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","maxSupportedTransactionVersion":0,"transactionDetails":"full","rewards":false}]} -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": { - "blockHeight": 428, - "blockTime": null, - "blockhash": "3Eq21vXNB5s86c62bVuUfTeaMif1N2kUqRPBmGRJhyTA", - "parentSlot": 429, - "previousBlockhash": "mfcyqEXB3DnHXki6KjjmZck6YjmZLvpAByy2fj4nh6B", - "transactions": [ - { - "meta": { - "err": null, - "fee": 5000, - "innerInstructions": [], - "logMessages": [], - "postBalances": [499998932500, 26858640, 1, 1, 1], - "postTokenBalances": [], - "preBalances": [499998937500, 26858640, 1, 1, 1], - "preTokenBalances": [], - "rewards": null, - "status": { - "Ok": null - } - }, - "transaction": { - "message": { - "accountKeys": [ - "3UVYmECPPMZSCqWKfENfuoTv51fTDTWicX9xmBD2euKe", - "AjozzgE83A3x1sHNUR64hfH7zaEBWeMaFuAN9kQgujrc", - "SysvarS1otHashes111111111111111111111111111", - "SysvarC1ock11111111111111111111111111111111", - "Vote111111111111111111111111111111111111111" - ], - "header": { - "numReadonlySignedAccounts": 0, - "numReadonlyUnsignedAccounts": 3, - "numRequiredSignatures": 1 - }, - "instructions": [ - { - "accounts": [1, 2, 3, 0], - "data": "37u9WtQpcm6ULa3WRQHmj49EPs4if7o9f1jSRVZpm2dvihR9C8jY4NqEwXUbLwx15HBSNcP1", - "programIdIndex": 4 - } - ], - "recentBlockhash": "mfcyqEXB3DnHXki6KjjmZck6YjmZLvpAByy2fj4nh6B" - }, - "signatures": [ - "2nBhEBYYvfaAe16UMNqRHre4YNSskvuYgx3M6E4JP1oDYvZEJHvoPzyUidNgNX5r9sTyN1J9UxtbCXy2rqYcuyuv" - ] - } - } - ] - }, - "id": 1 -} -``` - -#### 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"]} -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": { - "blockHeight": 428, - "blockTime": null, - "blockhash": "3Eq21vXNB5s86c62bVuUfTeaMif1N2kUqRPBmGRJhyTA", - "parentSlot": 429, - "previousBlockhash": "mfcyqEXB3DnHXki6KjjmZck6YjmZLvpAByy2fj4nh6B", - "rewards": [], - "transactions": [ - { - "meta": { - "err": null, - "fee": 5000, - "innerInstructions": null, - "logMessages": null, - "postBalances": [499998932500, 26858640, 1, 1, 1], - "postTokenBalances": [], - "preBalances": [499998937500, 26858640, 1, 1, 1], - "preTokenBalances": [], - "rewards": [], - "status": { - "Ok": null - } - }, - "transaction": [ - "AVj7dxHlQ9IrvdYVIjuiRFs1jLaDMHixgrv+qtHBwz51L4/ImLZhszwiyEJDIp7xeBSpm/TX5B7mYzxa+fPOMw0BAAMFJMJVqLw+hJYheizSoYlLm53KzgT82cDVmazarqQKG2GQsLgiqktA+a+FDR4/7xnDX7rsusMwryYVUdixfz1B1Qan1RcZLwqvxvJl4/t3zHragsUp0L47E24tAFUgAAAABqfVFxjHdMkoVmOYaR1etoteuKObS21cc1VbIQAAAAAHYUgdNXR0u3xNdiTr072z2DVec9EQQ/wNo1OAAAAAAAtxOUhPBp2WSjUNJEgfvy70BbxI00fZyEPvFHNfxrtEAQQEAQIDADUCAAAAAQAAAAAAAACtAQAAAAAAAAdUE18R96XTJCe+YfRfUp6WP+YKCy/72ucOL8AoBFSpAA==", - "base64" - ] - } - ] - }, - "id": 1 -} -``` - -#### Transaction Structure - -Transactions are quite different from those on other blockchains. Be sure to review [Anatomy of a Transaction](developing/programming-model/transactions.md) to learn about transactions on Solana. - -The JSON structure of a transaction is defined as follows: - -- `signatures: ` - A list of base-58 encoded signatures applied to the transaction. The list is always of length `message.header.numRequiredSignatures` and not empty. The signature at index `i` corresponds to the public key at index `i` in `message.accountKeys`. The first one is used as the [transaction id](../../terminology.md#transaction-id). -- `message: ` - Defines the content of the transaction. - - `accountKeys: ` - List of base-58 encoded public keys used by the transaction, including by the instructions and for signatures. The first `message.header.numRequiredSignatures` public keys must sign the transaction. - - `header: ` - Details the account types and signatures required by the transaction. - - `numRequiredSignatures: ` - The total number of signatures required to make the transaction valid. The signatures must match the first `numRequiredSignatures` of `message.accountKeys`. - - `numReadonlySignedAccounts: ` - The last `numReadonlySignedAccounts` of the signed keys are read-only accounts. Programs may process multiple transactions that load read-only accounts within a single PoH entry, but are not permitted to credit or debit lamports or modify account data. Transactions targeting the same read-write account are evaluated sequentially. - - `numReadonlyUnsignedAccounts: ` - The last `numReadonlyUnsignedAccounts` of the unsigned keys are read-only accounts. - - `recentBlockhash: ` - A base-58 encoded hash of a recent block in the ledger used to prevent transaction duplication and to give transactions lifetimes. - - `instructions: ` - List of program instructions that will be executed in sequence and committed in one atomic transaction if all succeed. - - `programIdIndex: ` - Index into the `message.accountKeys` array indicating the program account that executes this instruction. - - `accounts: ` - List of ordered indices into the `message.accountKeys` array indicating which accounts to pass to the program. - - `data: ` - The program input data encoded in a base-58 string. - - `addressTableLookups: ` - List of address table lookups used by a transaction to dynamically load addresses from on-chain address lookup tables. Undefined if `maxSupportedTransactionVersion` is not set. - - `accountKey: ` - base-58 encoded public key for an address lookup table account. - - `writableIndexes: ` - List of indices used to load addresses of writable accounts from a lookup table. - - `readonlyIndexes: ` - List of indices used to load addresses of readonly accounts from a lookup table. - -#### Inner Instructions Structure - -The Solana runtime records the cross-program instructions that are invoked during transaction processing and makes these available for greater transparency of what was executed on-chain per transaction instruction. Invoked instructions are grouped by the originating transaction instruction and are listed in order of processing. - -The JSON structure of inner instructions is defined as a list of objects in the following structure: - -- `index: number` - Index of the transaction instruction from which the inner instruction(s) originated -- `instructions: ` - Ordered list of inner program instructions that were invoked during a single transaction instruction. - - `programIdIndex: ` - Index into the `message.accountKeys` array indicating the program account that executes this instruction. - - `accounts: ` - List of ordered indices into the `message.accountKeys` array indicating which accounts to pass to the program. - - `data: ` - The program input data encoded in a base-58 string. - -#### Token Balances Structure - -The JSON structure of token balances is defined as a list of objects in the following structure: - -- `accountIndex: ` - Index of the account in which the token balance is provided for. -- `mint: ` - Pubkey of the token's mint. -- `owner: ` - Pubkey of token balance's owner. -- `programId: ` - Pubkey of the Token program that owns the account. -- `uiTokenAmount: ` - - - `amount: ` - Raw amount of tokens as a string, ignoring decimals. - - `decimals: ` - Number of decimals configured for token's mint. - - `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 - -#### Parameters: - -- (optional) `` - Configuration object containing the following fields: - - (optional) `commitment: ` - [Commitment](jsonrpc-api.md#configuring-state-commitment) - - (optional) `minContextSlot: ` - set the minimum slot that the request can be evaluated at. - -#### Results: - -- `` - Current block height - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc":"2.0","id":1, "method":"getBlockHeight"} -' -``` - -Result: - -```json -{ "jsonrpc": "2.0", "result": 1233, "id": 1 } -``` - -### getBlockProduction - -Returns recent block production information from the current or previous epoch. - -#### Parameters: - -- (optional) `` - Configuration object containing the following optional fields: - - (optional) `commitment: ` - [Commitment](jsonrpc-api.md#configuring-state-commitment) - - (optional) `range: ` - Slot range to return block production for. If parameter not provided, defaults to current epoch. - - `firstSlot: ` - first slot to return block production information for (inclusive) - - (optional) `lastSlot: ` - last slot to return block production information for (inclusive). If parameter not provided, defaults to the highest slot - - (optional) `identity: ` - Only return results for this validator identity (base-58 encoded) - -#### 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 - number of leader slots and the number of blocks produced. - - `range: ` - Block production slot range - - `firstSlot: ` - first slot of the block production information (inclusive) - - `lastSlot: ` - last slot of block production information (inclusive) - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc":"2.0","id":1, "method":"getBlockProduction"} -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": { - "context": { - "slot": 9887 - }, - "value": { - "byIdentity": { - "85iYT5RuzRTDgjyRa3cP8SYhM2j21fj7NhfJ3peu1DPr": [9888, 9886] - }, - "range": { - "firstSlot": 0, - "lastSlot": 9887 - } - } - }, - "id": 1 -} -``` - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - { - "jsonrpc": "2.0", - "id": 1, - "method": "getBlockProduction", - "params": [ - { - "identity": "85iYT5RuzRTDgjyRa3cP8SYhM2j21fj7NhfJ3peu1DPr", - "range": { - "firstSlot": 40, - "lastSlot": 50 - } - } - ] - } -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": { - "context": { - "slot": 10102 - }, - "value": { - "byIdentity": { - "85iYT5RuzRTDgjyRa3cP8SYhM2j21fj7NhfJ3peu1DPr": [11, 11] - }, - "range": { - "firstSlot": 50, - "lastSlot": 40 - } - } - }, - "id": 1 -} -``` - -### getBlockCommitment - -Returns commitment for particular block - -#### Parameters: - -- `` - block, identified by Slot - -#### Results: - -The result field will be a JSON object containing: - -- `commitment` - commitment, comprising either: - - `` - Unknown block - - `` - commitment, array of u64 integers logging the amount of cluster stake in lamports that has voted on the block at each depth from 0 to `MAX_LOCKOUT_HISTORY` + 1 -- `totalStake` - total active stake, in lamports, of the current epoch - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc":"2.0","id":1, "method":"getBlockCommitment","params":[5]} -' -``` - -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 - ], - "totalStake": 42 - }, - "id": 1 -} -``` - -### getBlocks - -Returns a list of confirmed blocks between two slots - -#### Parameters: - -- `` - start_slot, as u64 integer -- (optional) `` - end_slot, as u64 integer (must be no more than 500,000 blocks higher than the `start_slot`) -- (optional) `` - Configuration object containing the following field: - - (optional) `commitment: ` - [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 u64 integers listing confirmed blocks -between `start_slot` and either `end_slot`, if provided, or latest confirmed block, -inclusive. Max range allowed is 500,000 slots. - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc": "2.0","id":1,"method":"getBlocks","params":[5, 10]} -' -``` - -Result: - -```json -{ "jsonrpc": "2.0", "result": [5, 6, 7, 8, 9, 10], "id": 1 } -``` - -### getBlocksWithLimit - -Returns a list of confirmed blocks starting at the given slot - -#### Parameters: - -- `` - start_slot, as u64 integer -- `` - limit, as u64 integer (must be no more than 500,000 blocks higher than the `start_slot`) -- (optional) `` - Configuration object containing the following field: - - (optional) `commitment: ` - [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 u64 integers listing confirmed blocks -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]} -' -``` - -Result: - -```json -{ "jsonrpc": "2.0", "result": [5, 6, 7], "id": 1 } -``` - -### getBlockTime - -Returns the estimated production time of a block. - -Each validator reports their UTC time to the ledger on a regular interval by -intermittently adding a timestamp to a Vote for a particular block. A requested -block's time is calculated from the stake-weighted mean of the Vote timestamps -in a set of recent blocks recorded on the ledger. - -#### Parameters: - -- `` - block, identified by Slot - -#### Results: - -- `` - 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]} -' -``` - -Result: - -```json -{ "jsonrpc": "2.0", "result": 1574721591, "id": 1 } -``` - -### getClusterNodes - -Returns information about all the nodes participating in the cluster - -#### Parameters: - -None - -#### Results: - -The result field will be an array of JSON objects, each with the following sub fields: - -- `pubkey: ` - Node public key, as base-58 encoded string -- `gossip: ` - Gossip network address for the node -- `tpu: ` - TPU network address for the node -- `rpc: ` - JSON RPC network address for the node, or `null` if the JSON RPC service is not enabled -- `version: ` - The software version of the node, or `null` if the version information is not available -- `featureSet: ` - The unique identifier of the node's feature set -- `shredVersion: ` - The shred version the node has been configured to use - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc":"2.0", "id":1, "method":"getClusterNodes"} -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": [ - { - "gossip": "10.239.6.48:8001", - "pubkey": "9QzsJf7LPLj8GkXbYT3LFDKqsj2hHG7TA3xinJHu8epQ", - "rpc": "10.239.6.48:8899", - "tpu": "10.239.6.48:8856", - "version": "1.0.0 c375ce1f" - } - ], - "id": 1 -} -``` - -### getEpochInfo - -Returns information about the current epoch - -#### Parameters: - -- (optional) `` - Configuration object containing the following fields: - - (optional) `commitment: ` - [Commitment](jsonrpc-api.md#configuring-state-commitment) - - (optional) `minContextSlot: ` - set the minimum slot that the request can be evaluated at. - -#### Results: - -The result field will be an object with the following fields: - -- `absoluteSlot: `, the current slot -- `blockHeight: `, the current block height -- `epoch: `, the current epoch -- `slotIndex: `, the current slot relative to the start of the current epoch -- `slotsInEpoch: `, the number of slots in this epoch -- `transactionCount: `, total number of transactions processed without error since genesis - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc":"2.0","id":1, "method":"getEpochInfo"} -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": { - "absoluteSlot": 166598, - "blockHeight": 166500, - "epoch": 27, - "slotIndex": 2790, - "slotsInEpoch": 8192, - "transactionCount": 22661093 - }, - "id": 1 -} -``` - -### getEpochSchedule - -Returns epoch schedule information from this cluster's genesis config - -#### Parameters: - -None - -#### Results: - -The result field will be an object with the following fields: - -- `slotsPerEpoch: `, the maximum number of slots in each epoch -- `leaderScheduleSlotOffset: `, the number of slots before beginning of an epoch to calculate a leader schedule for that epoch -- `warmup: `, whether epochs start short and grow -- `firstNormalEpoch: `, first normal-length epoch, log2(slotsPerEpoch) - log2(MINIMUM_SLOTS_PER_EPOCH) -- `firstNormalSlot: `, MINIMUM_SLOTS_PER_EPOCH \* (2.pow(firstNormalEpoch) - 1) - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc":"2.0","id":1, "method":"getEpochSchedule"} -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": { - "firstNormalEpoch": 8, - "firstNormalSlot": 8160, - "leaderScheduleSlotOffset": 8192, - "slotsPerEpoch": 8192, - "warmup": true - }, - "id": 1 -} -``` - -### getFeeForMessage - -**NEW: This method is only available in solana-core v1.9 or newer. Please use -[getFees](jsonrpc-api.md#getfees) for solana-core v1.8** - -Get the fee the network will charge for a particular Message - -#### Parameters: - -- `message: ` - Base-64 encoded Message -- (optional) `` - Configuration object containing the following optional fields: - - (optional) `commitment: ` - [Commitment](jsonrpc-api.md#configuring-state-commitment) (used for retrieving blockhash) - - (optional) `minContextSlot: ` - set the minimum slot that the request can be evaluated at. - -#### Results: - -- `` - Fee corresponding to the message at the specified blockhash - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' -{ - "id":1, - "jsonrpc":"2.0", - "method":"getFeeForMessage", - "params":[ - "AQABAgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQAA", - { - "commitment":"processed" - } - ] -} -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": { "context": { "slot": 5068 }, "value": 5000 }, - "id": 1 -} -``` - -### getFirstAvailableBlock - -Returns the slot of the lowest confirmed block that has not been purged from the ledger - -#### Parameters: - -None - -#### Results: - -- `` - Slot - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc":"2.0","id":1, "method":"getFirstAvailableBlock"} -' -``` - -Result: - -```json -{ "jsonrpc": "2.0", "result": 250000, "id": 1 } -``` - -### getGenesisHash - -Returns the genesis hash - -#### Parameters: - -None - -#### Results: - -- `` - a Hash as base-58 encoded string - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc":"2.0","id":1, "method":"getGenesisHash"} -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": "GH7ome3EiwEr7tu9JuTh2dpYWBJK3z69Xm1ZE3MEE6JC", - "id": 1 -} -``` - -### getHealth - -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 -provided. - -#### Parameters: - -None - -#### Results: - -If the node is healthy: "ok" -If the node is unhealthy, a JSON RPC error response is returned. The specifics -of the error response are **UNSTABLE** and may change in the future - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc":"2.0","id":1, "method":"getHealth"} -' -``` - -Healthy Result: - -```json -{ "jsonrpc": "2.0", "result": "ok", "id": 1 } -``` - -Unhealthy Result (generic): - -```json -{ - "jsonrpc": "2.0", - "error": { - "code": -32005, - "message": "Node is unhealthy", - "data": {} - }, - "id": 1 -} -``` - -Unhealthy Result (if additional information is available) - -```json -{ - "jsonrpc": "2.0", - "error": { - "code": -32005, - "message": "Node is behind by 42 slots", - "data": { - "numSlotsBehind": 42 - } - }, - "id": 1 -} -``` - -### getHighestSnapshotSlot - -**NEW: This method is only available in solana-core v1.9 or newer. Please use -[getSnapshotSlot](jsonrpc-api.md#getsnapshotslot) for solana-core v1.8** - -Returns the highest slot information that the node has snapshots for. - -This will find the highest full snapshot slot, and the highest incremental -snapshot slot _based on_ the full snapshot slot, if there is one. - -#### Parameters: - -None - -#### Results: - -- `` - - `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"} -' -``` - -Result: - -```json -{ "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 -} -``` - -### getIdentity - -Returns the identity pubkey for the current node - -#### Parameters: - -None - -#### Results: - -The result field will be a JSON object with the following fields: - -- `identity`, the identity pubkey of the current node \(as a base-58 encoded string\) - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc":"2.0","id":1, "method":"getIdentity"} -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": { "identity": "2r1F4iWqVcb8M1DbAjQuFpebkQHY9hcVU4WuW2DJBppN" }, - "id": 1 -} -``` - -### getInflationGovernor - -Returns the current inflation governor - -#### Parameters: - -- (optional) `` - Configuration object containing the following field: - - (optional) `commitment: ` - [Commitment](jsonrpc-api.md#configuring-state-commitment) - -#### Results: - -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 -- `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"} -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": { - "foundation": 0.05, - "foundationTerm": 7, - "initial": 0.15, - "taper": 0.15, - "terminal": 0.015 - }, - "id": 1 -} -``` - -### getInflationRate - -Returns the specific inflation values for the current epoch - -#### Parameters: - -None - -#### Results: - -The result field will be a JSON object with the following fields: - -- `total: `, total inflation -- `validator: `, inflation allocated to validators -- `foundation: `, inflation allocated to the foundation -- `epoch: `, epoch for which these values are valid - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc":"2.0","id":1, "method":"getInflationRate"} -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": { - "epoch": 100, - "foundation": 0.001, - "total": 0.149, - "validator": 0.148 - }, - "id": 1 -} -``` - -### getInflationReward - -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 fields: - - (optional) `commitment: ` - [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) `minContextSlot: ` - set the minimum slot that the request can be evaluated at. - -#### Results - -The result field will be a JSON array with the following fields: - -- `epoch: `, epoch for which reward occured -- `effectiveSlot: `, the slot in which the rewards are effective -- `amount: `, reward amount in lamports -- `postBalance: `, post balance of the account in lamports -- `commission: ` - vote account commission when the reward was credited - -#### Example - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - { - "jsonrpc": "2.0", - "id": 1, - "method": "getInflationReward", - "params": [ - ["6dmNQ5jwLeLk5REvio1JcMshcbvkYMwy26sJ8pbkvStu", "BGsqMegLpV6n6Ve146sSX2dTjUMj3M92HnU8BbNRMhF2"], {"epoch": 2} - ] - } -' -``` - -Response: - -```json -{ - "jsonrpc": "2.0", - "result": [ - { - "amount": 2500, - "effectiveSlot": 224, - "epoch": 2, - "postBalance": 499999442500 - }, - null - ], - "id": 1 -} -``` - -### getLargestAccounts - -Returns the 20 largest accounts, by lamport balance (results may be cached up to two hours) - -#### Parameters: - -- (optional) `` - Configuration object containing the following optional fields: - - (optional) `commitment: ` - [Commitment](jsonrpc-api.md#configuring-state-commitment) - - (optional) `filter: ` - filter results by account type; currently supported: `circulating|nonCirculating` - -#### Results: - -The result will be an RpcResponse JSON object with `value` equal to an array of: - -- `` - otherwise, a JSON object containing: - - `address: `, base-58 encoded address of the account - - `lamports: `, number of lamports in the account, as a u64 - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc":"2.0","id":1, "method":"getLargestAccounts"} -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": { - "context": { - "slot": 54 - }, - "value": [ - { - "lamports": 999974, - "address": "99P8ZgtJYe1buSK8JXkvpLh8xPsCFuLYhz9hQFNw93WJ" - }, - { - "lamports": 42, - "address": "uPwWLo16MVehpyWqsLkK3Ka8nLowWvAHbBChqv2FZeL" - }, - { - "lamports": 42, - "address": "aYJCgU7REfu3XF8b3QhkqgqQvLizx8zxuLBHA25PzDS" - }, - { - "lamports": 42, - "address": "CTvHVtQ4gd4gUcw3bdVgZJJqApXE9nCbbbP4VTS5wE1D" - }, - { - "lamports": 20, - "address": "4fq3xJ6kfrh9RkJQsmVd5gNMvJbuSHfErywvEjNQDPxu" - }, - { - "lamports": 4, - "address": "AXJADheGVp9cruP8WYu46oNkRbeASngN5fPCMVGQqNHa" - }, - { - "lamports": 2, - "address": "8NT8yS6LiwNprgW4yM1jPPow7CwRUotddBVkrkWgYp24" - }, - { - "lamports": 1, - "address": "SysvarEpochSchedu1e111111111111111111111111" - }, - { - "lamports": 1, - "address": "11111111111111111111111111111111" - }, - { - "lamports": 1, - "address": "Stake11111111111111111111111111111111111111" - }, - { - "lamports": 1, - "address": "SysvarC1ock11111111111111111111111111111111" - }, - { - "lamports": 1, - "address": "StakeConfig11111111111111111111111111111111" - }, - { - "lamports": 1, - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "lamports": 1, - "address": "Config1111111111111111111111111111111111111" - }, - { - "lamports": 1, - "address": "SysvarStakeHistory1111111111111111111111111" - }, - { - "lamports": 1, - "address": "SysvarRecentB1ockHashes11111111111111111111" - }, - { - "lamports": 1, - "address": "SysvarFees111111111111111111111111111111111" - }, - { - "lamports": 1, - "address": "Vote111111111111111111111111111111111111111" - } - ] - }, - "id": 1 -} -``` - -### getLatestBlockhash - -**NEW: This method is only available in solana-core v1.9 or newer. Please use -[getRecentBlockhash](jsonrpc-api.md#getrecentblockhash) for solana-core v1.8** - -Returns the latest blockhash - -#### Parameters: - -- (optional) `` - Configuration object containing the following fields: - - (optional) `commitment: ` - [Commitment](jsonrpc-api.md#configuring-state-commitment) (used for retrieving blockhash) - - (optional) `minContextSlot: ` - set the minimum slot that the request can be evaluated at. - -#### Results: - -- `RpcResponse` - RpcResponse JSON object with `value` field set to a JSON object including: -- `blockhash: ` - a Hash as base-58 encoded string -- `lastValidBlockHeight: ` - last [block height](../../terminology.md#block-height) at which the blockhash will be valid - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - { - "id":1, - "jsonrpc":"2.0", - "method":"getLatestBlockhash", - "params":[ - { - "commitment":"processed" - } - ] - } -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": { - "context": { - "slot": 2792 - }, - "value": { - "blockhash": "EkSnNWid2cvwEVnVx9aBqawnmiCNiDgp3gUdkDPTKN1N", - "lastValidBlockHeight": 3090 - } - }, - "id": 1 -} -``` - -### getLeaderSchedule - -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 -- (optional) `` - Configuration object containing the following field: - - (optional) `commitment: ` - [Commitment](jsonrpc-api.md#configuring-state-commitment) - - (optional) `identity: ` - Only return results for this validator identity (base-58 encoded) - -#### Results: - -- `` - if requested epoch is not found -- `` - otherwise, the result field will be a dictionary of validator identities, - as base-58 encoded strings, and their corresponding leader slot indices as values - (indices are relative to the first slot in the requested epoch) - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc":"2.0","id":1, "method":"getLeaderSchedule"} -' -``` - -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 - ] - }, - "id": 1 -} -``` - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - { - "jsonrpc": "2.0", - "id": 1, - "method": "getLeaderSchedule", - "params": [ - null, - { - "identity": "4Qkev8aNZcqFNSRhQzwyLMFSsi94jHqE8WNVTJzTP99F" - } - ] - } -' -``` - -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 - ] - }, - "id": 1 -} -``` - -### getMaxRetransmitSlot - -Get the max slot seen from retransmit stage. - -#### Results: - -- `` - Slot - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc":"2.0","id":1, "method":"getMaxRetransmitSlot"} -' -``` - -Result: - -```json -{ "jsonrpc": "2.0", "result": 1234, "id": 1 } -``` - -### getMaxShredInsertSlot - -Get the max slot seen from after shred insert. - -#### Results: - -- `` - Slot - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc":"2.0","id":1, "method":"getMaxShredInsertSlot"} -' -``` - -Result: - -```json -{ "jsonrpc": "2.0", "result": 1234, "id": 1 } -``` - -### getMinimumBalanceForRentExemption - -Returns minimum balance required to make account rent exempt. - -#### Parameters: - -- `` - account data length -- (optional) `` - Configuration object containing the following field: - - (optional) `commitment: ` - [Commitment](jsonrpc-api.md#configuring-state-commitment) - -#### Results: - -- `` - minimum lamports required in account - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc":"2.0", "id":1, "method":"getMinimumBalanceForRentExemption", "params":[50]} -' -``` - -Result: - -```json -{ "jsonrpc": "2.0", "result": 500, "id": 1 } -``` - -### getMultipleAccounts - -Returns the account information for a list of Pubkeys. - -#### Parameters: - -- `` - An array of Pubkeys to query, as base-58 encoded strings (up to a maximum of 100). -- (optional) `` - Configuration object containing the following fields: - - (optional) `commitment: ` - [Commitment](jsonrpc-api.md#configuring-state-commitment) - - (optional) `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](jsonrpc-api.md#parsed-responses) 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. - - (optional) `minContextSlot: ` - set the minimum slot that the request can be evaluated at. - -#### Results: - -The result will be an RpcResponse JSON object with `value` equal to: - -An array of: - -- `` - if the account at that Pubkey doesn't exist -- `` - otherwise, a JSON object containing: - - `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": "getMultipleAccounts", - "params": [ - [ - "vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg", - "4fYNw3dojWmQ4dXtSGE9epjRGy9pFSx62YypT7avPYvA" - ], - { - "dataSlice": { - "offset": 0, - "length": 0 - } - } - ] - } -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": { - "context": { - "slot": 1 - }, - "value": [ - { - "data": ["AAAAAAEAAAACtzNsyJrW0g==", "base64"], - "executable": false, - "lamports": 1000000000, - "owner": "11111111111111111111111111111111", - "rentEpoch": 2 - }, - { - "data": ["", "base64"], - "executable": false, - "lamports": 5000000000, - "owner": "11111111111111111111111111111111", - "rentEpoch": 2 - } - ] - }, - "id": 1 -} -``` - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - { - "jsonrpc": "2.0", - "id": 1, - "method": "getMultipleAccounts", - "params": [ - [ - "vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg", - "4fYNw3dojWmQ4dXtSGE9epjRGy9pFSx62YypT7avPYvA" - ], - { - "encoding": "base58" - } - ] - } -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": { - "context": { - "slot": 1 - }, - "value": [ - { - "data": [ - "11116bv5nS2h3y12kD1yUKeMZvGcKLSjQgX6BeV7u1FrjeJcKfsHRTPuR3oZ1EioKtYGiYxpxMG5vpbZLsbcBYBEmZZcMKaSoGx9JZeAuWf", - "base58" - ], - "executable": false, - "lamports": 1000000000, - "owner": "11111111111111111111111111111111", - "rentEpoch": 2 - }, - { - "data": ["", "base58"], - "executable": false, - "lamports": 5000000000, - "owner": "11111111111111111111111111111111", - "rentEpoch": 2 - } - ] - }, - "id": 1 -} -``` - -### getProgramAccounts - -Returns all accounts owned by the provided program Pubkey - -#### Parameters: - -- `` - Pubkey of program, as base-58 encoded string -- (optional) `` - Configuration object containing the following fields: - - (optional) `commitment: ` - [Commitment](jsonrpc-api.md#configuring-state-commitment) - - (optional) `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](jsonrpc-api.md#parsed-responses) 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. - - (optional) `filters: ` - filter results using up to 4 [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. - - (optional) `minContextSlot: ` - set the minimum slot that the request can be evaluated at. - -##### 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 encoded string - - `encoding: ` - encoding for filter `bytes` data, either "base58" or "base64". Data is limited in size to 128 or fewer decoded bytes. - **NEW: This field, and base64 support generally, is only available in solana-core v1.14.0 or newer. Please omit when querying nodes on earlier versions** - -- `dataSize: ` - compares the program account data length with the provided data size - -#### Results: - -By default the result field will be an array of JSON objects. If `withContext` flag is set the array will be wrapped in an RpcResponse JSON object. - -The array will contain: - -- `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 - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc":"2.0", "id":1, "method":"getProgramAccounts", "params":["4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T"]} -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": [ - { - "account": { - "data": "2R9jLfiAQ9bgdcw6h8s44439", - "executable": false, - "lamports": 15298080, - "owner": "4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T", - "rentEpoch": 28 - }, - "pubkey": "CxELquR1gPP8wHe33gZ4QxqGB3sZ9RSwsJ2KshVewkFY" - } - ], - "id": 1 -} -``` - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - { - "jsonrpc": "2.0", - "id": 1, - "method": "getProgramAccounts", - "params": [ - "4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T", - { - "filters": [ - { - "dataSize": 17 - }, - { - "memcmp": { - "offset": 4, - "bytes": "3Mc6vR" - } - } - ] - } - ] - } -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": [ - { - "account": { - "data": "2R9jLfiAQ9bgdcw6h8s44439", - "executable": false, - "lamports": 15298080, - "owner": "4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T", - "rentEpoch": 28 - }, - "pubkey": "CxELquR1gPP8wHe33gZ4QxqGB3sZ9RSwsJ2KshVewkFY" - } - ], - "id": 1 -} -``` - -### getRecentPerformanceSamples - -Returns a list of recent performance samples, in reverse slot order. Performance samples are taken every 60 seconds and -include the number of transactions and slots that occur in a given time window. - -#### Parameters: - -- (optional) `limit: ` - number of samples to return (maximum 720) - -#### Results: - -An array of: - -- `RpcPerfSample` - - `slot: ` - Slot in which sample was taken at - - `numTransactions: ` - Number of transactions in sample - - `numSlots: ` - Number of slots in sample - - `samplePeriodSecs: ` - Number of seconds in a sample window - -#### Example: - -Request: - -```bash -// Request -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc":"2.0", "id":1, "method":"getRecentPerformanceSamples", "params": [4]} -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": [ - { - "numSlots": 126, - "numTransactions": 126, - "samplePeriodSecs": 60, - "slot": 348125 - }, - { - "numSlots": 126, - "numTransactions": 126, - "samplePeriodSecs": 60, - "slot": 347999 - }, - { - "numSlots": 125, - "numTransactions": 125, - "samplePeriodSecs": 60, - "slot": 347873 - }, - { - "numSlots": 125, - "numTransactions": 125, - "samplePeriodSecs": 60, - "slot": 347748 - } - ], - "id": 1 -} -``` - -### getRecentPrioritizationFees - -Returns a list of prioritization fees from recent blocks. Currently, a -node's prioritization-fee cache stores data from up to 150 blocks. - -#### Parameters: - -- `` - (optional) An array of account address strings (up to a maximum of 128 addresses). If this parameter is provided, the response will reflect a fee to land a transaction locking all of the provided accounts as writable. - -#### Results: - -An array of: - -- `RpcPrioritizationFee` - - `slot: ` - Slot in which fee was observed - - `prioritizationFee: ` - the per-compute-unit fee paid by at least one successfully landed transaction, specified in increments of 0.000001 lamports - -#### Example: - -Request: - -```bash -// Request -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc":"2.0", "id":1, "method":"getRecentPrioritizationFees", "params": [["CxELquR1gPP8wHe33gZ4QxqGB3sZ9RSwsJ2KshVewkFY"]]} -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": [ - { - "slot": 348125, - "prioritizationFee": 0, - }, - { - "slot": 348126, - "prioritizationFee": 1000, - }, - { - "slot": 348127, - "prioritizationFee": 500, - }, - { - "slot": 348128, - "prioritizationFee": 0, - }, - { - "slot": 348129, - "prioritizationFee": 1234, - } - ], - "id": 1 -} -``` - -### 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: - - (optional) `limit: ` - maximum transaction signatures to return (between 1 and 1,000, default: 1,000). - - (optional) `before: ` - start searching backwards from this transaction signature. - If not provided the search starts from the top of the highest max confirmed block. - - (optional) `until: ` - search until this transaction signature, if found before limit reached. - - (optional) `commitment: ` - [Commitment](jsonrpc-api.md#configuring-state-commitment) - - (optional) `minContextSlot: ` - set the minimum slot that the request can be evaluated at. - -#### 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. - - `confirmationStatus: ` - The transaction's cluster confirmation status; either `processed`, `confirmed`, or `finalized`. See [Commitment](jsonrpc-api.md#configuring-state-commitment) for more on optimistic confirmation. - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - { - "jsonrpc": "2.0", - "id": 1, - "method": "getSignaturesForAddress", - "params": [ - "Vote111111111111111111111111111111111111111", - { - "limit": 1 - } - ] - } -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": [ - { - "err": null, - "memo": null, - "signature": "5h6xBEauJ3PK6SWCZ1PGjBvj8vDdWG3KpwATGy1ARAXFSDwt8GFXM7W5Ncn16wmqokgpiKRLuS83KUxyZyv2sUYv", - "slot": 114, - "blockTime": null - } - ], - "id": 1 -} -``` - -### getSignatureStatuses - -Returns the statuses of a list of signatures. Unless the -`searchTransactionHistory` configuration parameter is included, this method only -searches the recent status cache of signatures, which retains statuses for all -active slots plus `MAX_RECENT_BLOCKHASHES` rooted slots. - -#### Parameters: - -- `` - An array of transaction signatures to confirm, as base-58 encoded strings (up to a maximum of 256) -- (optional) `` - Configuration object containing the following field: - - `searchTransactionHistory: ` - if true, a Solana node will search its ledger cache for any signatures not found in the recent status cache - -#### Results: - -An RpcResponse containing a JSON object consisting of an array of TransactionStatus objects. - -- `RpcResponse` - RpcResponse JSON object with `value` field: - -An array of: - -- `` - Unknown transaction -- `` - - `slot: ` - The slot the transaction was processed - - `confirmations: ` - Number of blocks since signature confirmation, null if rooted, as well as finalized by a supermajority of the cluster - - `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) - - `confirmationStatus: ` - The transaction's cluster confirmation status; either `processed`, `confirmed`, or `finalized`. See [Commitment](jsonrpc-api.md#configuring-state-commitment) for more on optimistic confirmation. - - DEPRECATED: `status: ` - Transaction status - - `"Ok": ` - Transaction was successful - - `"Err": ` - Transaction failed with TransactionError - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - { - "jsonrpc": "2.0", - "id": 1, - "method": "getSignatureStatuses", - "params": [ - [ - "5VERv8NMvzbJMEkV8xnrLkEaWRtSz9CosKDYjCJjBRnbJLgp8uirBgmQpjKhoR4tjF3ZpRzrFmBV6UjKdiSZkQUW", - "5j7s6NiJS3JAkvgkoc18WVAsiSaci2pxB2A6ueCJP4tprA2TFg9wSyTLeYouxPBJEMzJinENTkpA52YStRW5Dia7" - ] - ] - } -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": { - "context": { - "slot": 82 - }, - "value": [ - { - "slot": 72, - "confirmations": 10, - "err": null, - "status": { - "Ok": null - }, - "confirmationStatus": "confirmed" - }, - null - ] - }, - "id": 1 -} -``` - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - { - "jsonrpc": "2.0", - "id": 1, - "method": "getSignatureStatuses", - "params": [ - [ - "5VERv8NMvzbJMEkV8xnrLkEaWRtSz9CosKDYjCJjBRnbJLgp8uirBgmQpjKhoR4tjF3ZpRzrFmBV6UjKdiSZkQUW" - ], - { - "searchTransactionHistory": true - } - ] - } -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": { - "context": { - "slot": 82 - }, - "value": [ - { - "slot": 48, - "confirmations": null, - "err": null, - "status": { - "Ok": null - }, - "confirmationStatus": "finalized" - }, - null - ] - }, - "id": 1 -} -``` - -### getSlot - -Returns the slot that has reached the [given or default commitment level](jsonrpc-api.md#configuring-state-commitment) - -#### Parameters: - -- (optional) `` - Configuration object containing the following fields: - - (optional) `commitment: ` - [Commitment](jsonrpc-api.md#configuring-state-commitment) - - (optional) `minContextSlot: ` - set the minimum slot that the request can be evaluated at. - -#### Results: - -- `` - Current slot - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc":"2.0","id":1, "method":"getSlot"} -' -``` - -Result: - -```json -{ "jsonrpc": "2.0", "result": 1234, "id": 1 } -``` - -### getSlotLeader - -Returns the current slot leader - -#### Parameters: - -- (optional) `` - Configuration object containing the following fields: - - (optional) `commitment: ` - [Commitment](jsonrpc-api.md#configuring-state-commitment) - - (optional) `minContextSlot: ` - set the minimum slot that the request can be evaluated at. - -#### Results: - -- `` - Node identity Pubkey as base-58 encoded string - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc":"2.0","id":1, "method":"getSlotLeader"} -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": "ENvAW7JScgYq6o4zKZwewtkzzJgDzuJAFxYasvmEQdpS", - "id": 1 -} -``` - -### getSlotLeaders - -Returns the slot leaders for a given slot range - -#### Parameters: - -- `` - Start slot, as u64 integer -- `` - Limit, as u64 integer (between 1 and 5,000) - -#### Results: - -- `` - Node identity public keys as base-58 encoded strings - -#### Example: - -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]} -' -``` - -Result: - -The first leader returned is the leader for slot #100: - -```json -{ - "jsonrpc": "2.0", - "result": [ - "ChorusmmK7i1AxXeiTtQgQZhQNiXYU84ULeaYF1EH15n", - "ChorusmmK7i1AxXeiTtQgQZhQNiXYU84ULeaYF1EH15n", - "ChorusmmK7i1AxXeiTtQgQZhQNiXYU84ULeaYF1EH15n", - "ChorusmmK7i1AxXeiTtQgQZhQNiXYU84ULeaYF1EH15n", - "Awes4Tr6TX8JDzEhCZY2QVNimT6iD1zWHzf1vNyGvpLM", - "Awes4Tr6TX8JDzEhCZY2QVNimT6iD1zWHzf1vNyGvpLM", - "Awes4Tr6TX8JDzEhCZY2QVNimT6iD1zWHzf1vNyGvpLM", - "Awes4Tr6TX8JDzEhCZY2QVNimT6iD1zWHzf1vNyGvpLM", - "DWvDTSh3qfn88UoQTEKRV2JnLt5jtJAVoiCo3ivtMwXP", - "DWvDTSh3qfn88UoQTEKRV2JnLt5jtJAVoiCo3ivtMwXP" - ], - "id": 1 -} -``` - -### getStakeActivation - -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 fields: - - (optional) `commitment: ` - [Commitment](jsonrpc-api.md#configuring-state-commitment) - - (optional) `epoch: ` - epoch for which to calculate activation details. If parameter not provided, defaults to current epoch. - - (optional) `minContextSlot: ` - set the minimum slot that the request can be evaluated at. - -#### Results: - -The result will be a JSON object with the following fields: - -- `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"]} -' -``` - -Result: - -```json -{ - "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 ' - { - "jsonrpc": "2.0", - "id": 1, - "method": "getStakeActivation", - "params": [ - "CYRJWqiSjLitBAcRxPvWpgX3s5TvmN2SuRY3eEYypFvT", - { - "epoch": 4 - } - ] - } -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": { - "active": 124429280, - "inactive": 73287840, - "state": "activating" - }, - "id": 1 -} -``` - -### getStakeMinimumDelegation - -Returns the stake minimum delegation, in lamports. - -#### Parameters: - -- (optional) `` - Configuration object containing the following field: - - (optional) `commitment: ` - [Commitment](jsonrpc-api.md#configuring-state-commitment) - -#### Results: - -The result will be an RpcResponse JSON object with `value` equal to: - -- `` - The stake minimum delegation, in lamports - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc":"2.0","id":1,"method":"getStakeMinimumDelegation"} -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": { - "context": { - "slot": 501 - }, - "value": 1000000000 - }, - "id": 1 -} -``` - -### getSupply - -Returns information about the current supply. - -#### Parameters: - -- (optional) `` - Configuration object containing the following optional fields: - - (optional) `commitment: ` - [Commitment](jsonrpc-api.md#configuring-state-commitment) - - (optional) `excludeNonCirculatingAccountsList: ` - exclude non circulating accounts list from response - -#### Results: - -The result will be an RpcResponse JSON object with `value` equal to a JSON object containing: - -- `total: ` - Total supply in lamports -- `circulating: ` - Circulating supply in lamports -- `nonCirculating: ` - Non-circulating supply in lamports -- `nonCirculatingAccounts: ` - an array of account addresses of non-circulating accounts, as strings. If `excludeNonCirculatingAccountsList` is enabled, the returned array will be empty. - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc":"2.0", "id":1, "method":"getSupply"} -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": { - "context": { - "slot": 1114 - }, - "value": { - "circulating": 16000, - "nonCirculating": 1000000, - "nonCirculatingAccounts": [ - "FEy8pTbP5fEoqMV1GdTz83byuA8EKByqYat1PKDgVAq5", - "9huDUZfxoJ7wGMTffUE7vh1xePqef7gyrLJu9NApncqA", - "3mi1GmwEE3zo2jmfDuzvjSX9ovRXsDUKHvsntpkhuLJ9", - "BYxEJTDerkaRWBem3XgnVcdhppktBXa2HbkHPKj2Ui4Z" - ], - "total": 1016000 - } - }, - "id": 1 -} -``` - -### getTokenAccountBalance - -Returns the token balance of an SPL Token account. - -#### Parameters: - -- `` - Pubkey of Token account to query, as base-58 encoded string -- (optional) `` - Configuration object containing the following field: - - (optional) `commitment: ` - [Commitment](jsonrpc-api.md#configuring-state-commitment) - -#### Results: - -The result will be an RpcResponse JSON object with `value` equal to a JSON object containing: - -- `amount: ` - the raw balance without decimals, a string representation of u64 -- `decimals: ` - number of base 10 digits to the right of the decimal place -- `uiAmount: ` - the balance, using mint-prescribed decimals **DEPRECATED** -- `uiAmountString: ` - the balance as a string, using mint-prescribed decimals - -For more details on returned data: The -[Token Balances Structure](jsonrpc-api.md#token-balances-structure) response from [getBlock](jsonrpc-api.md#getblock) follows a similar structure. - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc":"2.0", "id":1, "method":"getTokenAccountBalance", "params": ["7fUAJdStEuGbc3sM84cKRL6yYaaSstyLSU4ve5oovLS7"]} -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": { - "context": { - "slot": 1114 - }, - "value": { - "amount": "9864", - "decimals": 2, - "uiAmount": 98.64, - "uiAmountString": "98.64" - }, - "id": 1 - } -} -``` - -### getTokenAccountsByDelegate - -Returns all SPL Token accounts by approved Delegate. - -#### Parameters: - -- `` - 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 that owns the accounts, as base-58 encoded string -- (optional) `` - Configuration object containing the following fields: - - (optional) `commitment: ` - [Commitment](jsonrpc-api.md#configuring-state-commitment) - - (optional) `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](jsonrpc-api.md#parsed-responses) 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. - - (optional) `minContextSlot: ` - set the minimum slot that the request can be evaluated at. - -#### Results: - -The result will be an RpcResponse JSON object with `value` equal to an array of JSON objects, which 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: `, 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. - -#### Example: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - { - "jsonrpc": "2.0", - "id": 1, - "method": "getTokenAccountsByDelegate", - "params": [ - "4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T", - { - "programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "encoding": "jsonParsed" - } - ] - } -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": { - "context": { - "slot": 1114 - }, - "value": [ - { - "account": { - "data": { - "program": "spl-token", - "parsed": { - "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": "CnPoSPKXu7wJqxe59Fs72tkBeALovhsCxYeFwPCQH9TD" - }, - "type": "account" - }, - "space": 165 - }, - "executable": false, - "lamports": 1726080, - "owner": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", - "rentEpoch": 4 - }, - "pubkey": "28YTZEwqtMHWrhWcvv34se7pjS7wctgqzCPB3gReCFKp" - } - ] - }, - "id": 1 -} -``` - -### getTokenAccountsByOwner - -Returns all SPL Token accounts by token owner. - -#### Parameters: - -- `` - 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 that owns the accounts, as base-58 encoded string -- (optional) `` - Configuration object containing the following fields: - - (optional) `commitment: ` - [Commitment](jsonrpc-api.md#configuring-state-commitment) - - (optional) `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](jsonrpc-api.md#parsed-responses) 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. - - (optional) `minContextSlot: ` - set the minimum slot that the request can be evaluated at. - -#### Results: - -The result will be an RpcResponse JSON object with `value` equal to an array of JSON objects, which 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: `, 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. - -#### Example: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - { - "jsonrpc": "2.0", - "id": 1, - "method": "getTokenAccountsByOwner", - "params": [ - "4Qkev8aNZcqFNSRhQzwyLMFSsi94jHqE8WNVTJzTP99F", - { - "mint": "3wyAj7Rt1TWVPZVteFJPLa26JmLvdb1CAKEFZm3NY75E" - }, - { - "encoding": "jsonParsed" - } - ] - } -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": { - "context": { - "slot": 1114 - }, - "value": [ - { - "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" - }, - "type": "account" - }, - "space": 165 - }, - "executable": false, - "lamports": 1726080, - "owner": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", - "rentEpoch": 4 - }, - "pubkey": "C2gJg6tKpQs41PRS1nC8aw3ZKNZK3HQQZGVrDFDup5nx" - } - ] - }, - "id": 1 -} -``` - -### getTokenLargestAccounts - -Returns the 20 largest accounts of a particular SPL Token type. - -#### Parameters: - -- `` - Pubkey of token Mint to query, as base-58 encoded string -- (optional) `` - Configuration object containing the following field: - - (optional) `commitment: ` - [Commitment](jsonrpc-api.md#configuring-state-commitment) - -#### Results: - -The result will be an RpcResponse JSON object with `value` equal to an array of JSON objects containing: - -- `address: ` - the address of the token account -- `amount: ` - the raw token account balance without decimals, a string representation of u64 -- `decimals: ` - number of base 10 digits to the right of the decimal place -- `uiAmount: ` - the token account balance, using mint-prescribed decimals **DEPRECATED** -- `uiAmountString: ` - the token account balance as a string, using mint-prescribed decimals - -#### Example: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc":"2.0", "id":1, "method":"getTokenLargestAccounts", "params": ["3wyAj7Rt1TWVPZVteFJPLa26JmLvdb1CAKEFZm3NY75E"]} -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": { - "context": { - "slot": 1114 - }, - "value": [ - { - "address": "FYjHNoFtSQ5uijKrZFyYAxvEr87hsKXkXcxkcmkBAf4r", - "amount": "771", - "decimals": 2, - "uiAmount": 7.71, - "uiAmountString": "7.71" - }, - { - "address": "BnsywxTcaYeNUtzrPxQUvzAWxfzZe3ZLUJ4wMMuLESnu", - "amount": "229", - "decimals": 2, - "uiAmount": 2.29, - "uiAmountString": "2.29" - } - ] - }, - "id": 1 -} -``` - -### getTokenSupply - -Returns the total supply of an SPL Token type. - -#### Parameters: - -- `` - Pubkey of token Mint to query, as base-58 encoded string -- (optional) `` - Configuration object containing the following field: - - (optional) `commitment: ` - [Commitment](jsonrpc-api.md#configuring-state-commitment) - -#### Results: - -The result will be an RpcResponse JSON object with `value` equal to a JSON object containing: - -- `amount: ` - the raw total token supply without decimals, a string representation of u64 -- `decimals: ` - number of base 10 digits to the right of the decimal place -- `uiAmount: ` - the total token supply, using mint-prescribed decimals **DEPRECATED** -- `uiAmountString: ` - the total token supply as a string, using mint-prescribed decimals - -#### Example: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc":"2.0", "id":1, "method":"getTokenSupply", "params": ["3wyAj7Rt1TWVPZVteFJPLa26JmLvdb1CAKEFZm3NY75E"]} -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": { - "context": { - "slot": 1114 - }, - "value": { - "amount": "100000", - "decimals": 2, - "uiAmount": 1000, - "uiAmountString": "1000" - } - }, - "id": 1 -} -``` - -### getTransaction - -Returns transaction details for a confirmed transaction - -#### Parameters: - -- `` - 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](jsonrpc-api.md#parsed-responses) 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: ` - [Commitment](jsonrpc-api.md#configuring-state-commitment); "processed" is not supported. If parameter not provided, the default is "finalized". - - (optional) `maxSupportedTransactionVersion: ` - set the max transaction version to return in responses. If the requested transaction is a higher version, an error will be returned. If this parameter is omitted, only legacy transactions will be returned, and any versioned transaction will prompt the error. - -#### Results: - -- `` - if transaction is not found or not confirmed -- `` - if transaction is confirmed, an object with the following fields: - - `slot: ` - the slot this transaction was processed in - - `transaction: ` - [Transaction](#transaction-structure) object, either in JSON format or encoded binary data, depending on encoding parameter - - `blockTime: ` - estimated production time, as Unix timestamp (seconds since the Unix epoch) of when the transaction was processed. null if not available - - `meta: ` - transaction status metadata object: - - `err: ` - Error if transaction failed, null if transaction succeeded. [TransactionError definitions](https://docs.rs/solana-sdk/VERSION_FOR_DOCS_RS/solana_sdk/transaction/enum.TransactionError.html) - - `fee: ` - fee this transaction was charged, as u64 integer - - `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 - - `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 - - `"Ok": ` - Transaction was successful - - `"Err": ` - Transaction failed with TransactionError - - `rewards: ` - transaction-level rewards, populated if rewards are requested; an array of JSON objects containing: - - `pubkey: ` - The public key, as base-58 encoded string, of the account that received the reward - - `lamports: `- number of reward lamports credited or debited by the account, as a i64 - - `postBalance: ` - account balance in lamports after the reward was applied - - `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 - - `loadedAddresses: ` - Transaction addresses loaded from address lookup tables. Undefined if `maxSupportedTransactionVersion` is not set in request params. - - `writable: ` - Ordered list of base-58 encoded addresses for writable loaded accounts - - `readonly: ` - Ordered list of base-58 encoded addresses for readonly loaded accounts - - `returnData: ` - the most-recent return data generated by an instruction in the transaction, with the following fields: - - `programId: `, the program that generated the return data, as base-58 encoded Pubkey - - `data: <[string, encoding]>`, the return data itself, as base-64 encoded binary data - - `computeUnitsConsumed: `, number of [compute units](developing/programming-model/runtime.md#compute-budget) consumed by the transaction - - `version: <"legacy"|number|undefined>` - Transaction version. Undefined if `maxSupportedTransactionVersion` is not set in request params. - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - { - "jsonrpc": "2.0", - "id": 1, - "method": "getTransaction", - "params": [ - "2nBhEBYYvfaAe16UMNqRHre4YNSskvuYgx3M6E4JP1oDYvZEJHvoPzyUidNgNX5r9sTyN1J9UxtbCXy2rqYcuyuv", - "json" - ] - } -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": { - "meta": { - "err": null, - "fee": 5000, - "innerInstructions": [], - "postBalances": [499998932500, 26858640, 1, 1, 1], - "postTokenBalances": [], - "preBalances": [499998937500, 26858640, 1, 1, 1], - "preTokenBalances": [], - "rewards": [], - "status": { - "Ok": null - } - }, - "slot": 430, - "transaction": { - "message": { - "accountKeys": [ - "3UVYmECPPMZSCqWKfENfuoTv51fTDTWicX9xmBD2euKe", - "AjozzgE83A3x1sHNUR64hfH7zaEBWeMaFuAN9kQgujrc", - "SysvarS1otHashes111111111111111111111111111", - "SysvarC1ock11111111111111111111111111111111", - "Vote111111111111111111111111111111111111111" - ], - "header": { - "numReadonlySignedAccounts": 0, - "numReadonlyUnsignedAccounts": 3, - "numRequiredSignatures": 1 - }, - "instructions": [ - { - "accounts": [1, 2, 3, 0], - "data": "37u9WtQpcm6ULa3WRQHmj49EPs4if7o9f1jSRVZpm2dvihR9C8jY4NqEwXUbLwx15HBSNcP1", - "programIdIndex": 4 - } - ], - "recentBlockhash": "mfcyqEXB3DnHXki6KjjmZck6YjmZLvpAByy2fj4nh6B" - }, - "signatures": [ - "2nBhEBYYvfaAe16UMNqRHre4YNSskvuYgx3M6E4JP1oDYvZEJHvoPzyUidNgNX5r9sTyN1J9UxtbCXy2rqYcuyuv" - ] - } - }, - "blockTime": null, - "id": 1 -} -``` - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - { - "jsonrpc": "2.0", - "id": 1, - "method": "getTransaction", - "params": [ - "2nBhEBYYvfaAe16UMNqRHre4YNSskvuYgx3M6E4JP1oDYvZEJHvoPzyUidNgNX5r9sTyN1J9UxtbCXy2rqYcuyuv", - "base64" - ] - } -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": { - "meta": { - "err": null, - "fee": 5000, - "innerInstructions": [], - "postBalances": [499998932500, 26858640, 1, 1, 1], - "postTokenBalances": [], - "preBalances": [499998937500, 26858640, 1, 1, 1], - "preTokenBalances": [], - "rewards": null, - "status": { - "Ok": null - } - }, - "slot": 430, - "transaction": [ - "AVj7dxHlQ9IrvdYVIjuiRFs1jLaDMHixgrv+qtHBwz51L4/ImLZhszwiyEJDIp7xeBSpm/TX5B7mYzxa+fPOMw0BAAMFJMJVqLw+hJYheizSoYlLm53KzgT82cDVmazarqQKG2GQsLgiqktA+a+FDR4/7xnDX7rsusMwryYVUdixfz1B1Qan1RcZLwqvxvJl4/t3zHragsUp0L47E24tAFUgAAAABqfVFxjHdMkoVmOYaR1etoteuKObS21cc1VbIQAAAAAHYUgdNXR0u3xNdiTr072z2DVec9EQQ/wNo1OAAAAAAAtxOUhPBp2WSjUNJEgfvy70BbxI00fZyEPvFHNfxrtEAQQEAQIDADUCAAAAAQAAAAAAAACtAQAAAAAAAAdUE18R96XTJCe+YfRfUp6WP+YKCy/72ucOL8AoBFSpAA==", - "base64" - ] - }, - "id": 1 -} -``` - -### getTransactionCount - -Returns the current Transaction count from the ledger - -#### Parameters: - -- (optional) `` - Configuration object containing the following fields: - - (optional) `commitment: ` - [Commitment](jsonrpc-api.md#configuring-state-commitment) - - (optional) `minContextSlot: ` - set the minimum slot that the request can be evaluated at. - -#### Results: - -- `` - count - -#### Example: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc":"2.0","id":1, "method":"getTransactionCount"} -' - -``` - -Result: - -```json -{ "jsonrpc": "2.0", "result": 268, "id": 1 } -``` - -### getVersion - -Returns the current solana versions running on the node - -#### Parameters: - -None - -#### Results: - -The result field will be a JSON object with the following fields: - -- `solana-core`, software version of solana-core -- `feature-set`, unique identifier of the current software's feature set - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc":"2.0","id":1, "method":"getVersion"} -' -``` - -Result: - -```json -{ "jsonrpc": "2.0", "result": { "solana-core": "1.14.3" }, "id": 1 } -``` - -### getVoteAccounts - -Returns the account info and associated stake for all the voting accounts in the current bank. - -#### Parameters: - -- (optional) `` - Configuration object containing the following field: - - (optional) `commitment: ` - [Commitment](jsonrpc-api.md#configuring-state-commitment) - - (optional) `votePubkey: ` - Only return results for this validator vote address (base-58 encoded) - - (optional) `keepUnstakedDelinquents: ` - Do not filter out delinquent validators with no stake - - (optional) `delinquentSlotDistance: ` - Specify the number of slots behind the tip that a validator must fall to be considered delinquent. **NOTE:** For the sake of consistency between ecosystem products, _it is **not** recommended that this argument be specified._ - -#### Results: - -The result field will be a JSON object of `current` and `delinquent` accounts, -each containing an array of JSON objects with the following sub fields: - -- `votePubkey: ` - Vote account address, as base-58 encoded string -- `nodePubkey: ` - Validator identity, as base-58 encoded string -- `activatedStake: ` - the stake, in lamports, delegated to this vote account and active in this epoch -- `epochVoteAccount: ` - bool, whether the vote account is staked for this epoch -- `commission: `, percentage (0-100) of rewards payout owed to the vote account -- `lastVote: ` - Most recent slot voted on by this vote account -- `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"} -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": { - "current": [ - { - "commission": 0, - "epochVoteAccount": true, - "epochCredits": [ - [1, 64, 0], - [2, 192, 64] - ], - "nodePubkey": "B97CCUW3AEZFGy6uUg6zUdnNYvnVq5VG8PUtb2HayTDD", - "lastVote": 147, - "activatedStake": 42, - "votePubkey": "3ZT31jkAGhUaw8jsy4bTknwBMP8i4Eueh52By4zXcsVw" - } - ], - "delinquent": [ - { - "commission": 127, - "epochVoteAccount": false, - "epochCredits": [], - "nodePubkey": "6ZPxeQaDo4bkZLRsdNrCzchNQr5LN9QMc9sipXv9Kw8f", - "lastVote": 0, - "activatedStake": 0, - "votePubkey": "CmgCk4aMS7KW1SHX3s9K5tBJ6Yng2LBaC8MFov4wx9sm" - } - ] - }, - "id": 1 -} -``` - -#### Example: Restrict results to a single validator vote account - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - { - "jsonrpc": "2.0", - "id": 1, - "method": "getVoteAccounts", - "params": [ - { - "votePubkey": "3ZT31jkAGhUaw8jsy4bTknwBMP8i4Eueh52By4zXcsVw" - } - ] - } -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": { - "current": [ - { - "commission": 0, - "epochVoteAccount": true, - "epochCredits": [ - [1, 64, 0], - [2, 192, 64] - ], - "nodePubkey": "B97CCUW3AEZFGy6uUg6zUdnNYvnVq5VG8PUtb2HayTDD", - "lastVote": 147, - "activatedStake": 42, - "votePubkey": "3ZT31jkAGhUaw8jsy4bTknwBMP8i4Eueh52By4zXcsVw" - } - ], - "delinquent": [] - }, - "id": 1 -} -``` - -### isBlockhashValid - -**NEW: This method is only available in solana-core v1.9 or newer. Please use -[getFeeCalculatorForBlockhash](jsonrpc-api.md#getfeecalculatorforblockhash) for solana-core v1.8** - -Returns whether a blockhash is still valid or not - -#### Parameters: - -- `blockhash: ` - the blockhash of this block, as base-58 encoded string -- (optional) `` - Configuration object containing the following fields: - - (optional) `commitment: ` - [Commitment](jsonrpc-api.md#configuring-state-commitment) (used for retrieving blockhash) - - (optional) `minContextSlot: ` - set the minimum slot that the request can be evaluated at. - -#### Results: - -- `` - True if the blockhash is still valid - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - { - "id":45, - "jsonrpc":"2.0", - "method":"isBlockhashValid", - "params":[ - "J7rBdM6AecPDEZp8aPq5iPSNKVkU5Q76F3oAV4eW5wsW", - {"commitment":"processed"} - ] - } -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": { - "context": { - "slot": 2483 - }, - "value": false - }, - "id": 1 -} -``` - -### minimumLedgerSlot - -Returns the lowest slot that the node has information about in its ledger. This -value may increase over time if the node is configured to purge older ledger data - -#### Parameters: - -None - -#### Results: - -- `u64` - Minimum ledger slot - -#### Example: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc":"2.0","id":1, "method":"minimumLedgerSlot"} -' - -``` - -Result: - -```json -{ "jsonrpc": "2.0", "result": 1234, "id": 1 } -``` - -### requestAirdrop - -Requests an airdrop of lamports to a Pubkey - -#### Parameters: - -- `` - Pubkey of account to receive lamports, as base-58 encoded string -- `` - lamports, as a u64 -- (optional) `` - Configuration object containing the following field: - - (optional) `commitment: ` - [Commitment](jsonrpc-api.md#configuring-state-commitment) (used for retrieving blockhash and verifying airdrop success) - -#### Results: - -- `` - Transaction Signature of airdrop, as base-58 encoded string - -#### Example: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc":"2.0","id":1, "method":"requestAirdrop", "params":["83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri", 1000000000]} -' - -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": "5VERv8NMvzbJMEkV8xnrLkEaWRtSz9CosKDYjCJjBRnbJLgp8uirBgmQpjKhoR4tjF3ZpRzrFmBV6UjKdiSZkQUW", - "id": 1 -} -``` - -### sendTransaction - -Submits a signed transaction to the cluster for processing. - -This method does not alter the transaction in any way; it relays the -transaction created by clients to the node as-is. - -If the node's rpc service receives the transaction, this method immediately -succeeds, without waiting for any confirmations. A successful response from -this method does not guarantee the transaction is processed or confirmed by the -cluster. - -While the rpc service will reasonably retry to submit it, the transaction -could be rejected if transaction's `recent_blockhash` expires before it lands. - -Use [`getSignatureStatuses`](jsonrpc-api.md#getsignaturestatuses) to ensure -a transaction is processed and confirmed. - -Before submitting, the following preflight checks are performed: - -1. The transaction signatures are verified -2. The transaction is simulated against the bank slot specified by the preflight - commitment. On failure an error will be returned. Preflight checks may be - disabled if desired. It is recommended to specify the same commitment and - preflight commitment to avoid confusing behavior. - -The returned signature is the first signature in the transaction, which -is used to identify the transaction ([transaction id](../../terminology.md#transaction-id)). -This identifier can be easily extracted from the transaction data before -submission. - -#### Parameters: - -- `` - fully-signed Transaction, as encoded string -- (optional) `` - Configuration object containing the following field: - - `skipPreflight: ` - if true, skip the preflight transaction checks (default: false) - - (optional) `preflightCommitment: ` - [Commitment](jsonrpc-api.md#configuring-state-commitment) level to use for preflight (default: `"finalized"`). - - (optional) `encoding: ` - Encoding used for the transaction data. Either `"base58"` (_slow_, **DEPRECATED**), or `"base64"`. (default: `"base58"`). - - (optional) `maxRetries: ` - 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. - - (optional) `minContextSlot: ` - set the minimum slot at which to perform preflight transaction checks. - -#### Results: - -- `` - First Transaction Signature embedded in the transaction, as base-58 encoded string ([transaction id](../../terminology.md#transaction-id)) - -#### Example: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - { - "jsonrpc": "2.0", - "id": 1, - "method": "sendTransaction", - "params": [ - "4hXTCkRzt9WyecNzV1XPgCDfGAZzQKNxLXgynz5QDuWWPSAZBZSHptvWRL3BjCvzUXRdKvHL2b7yGrRQcWyaqsaBCncVG7BFggS8w9snUts67BSh3EqKpXLUm5UMHfD7ZBe9GhARjbNQMLJ1QD3Spr6oMTBU6EhdB4RD8CP2xUxr2u3d6fos36PD98XS6oX8TQjLpsMwncs5DAMiD4nNnR8NBfyghGCWvCVifVwvA8B8TJxE1aiyiv2L429BCWfyzAme5sZW8rDb14NeCQHhZbtNqfXhcp2tAnaAT" - ] - } -' - -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": "2id3YC2jK9G5Wo2phDx4gJVAew8DcY5NAojnVuao8rkxwPYPe8cSwE5GzhEgJA2y8fVjDEo6iR6ykBvDxrTQrtpb", - "id": 1 -} -``` - -### simulateTransaction - -Simulate sending a transaction - -#### Parameters: - -- `` - Transaction, as an encoded string. The transaction must have a valid blockhash, but is not required to be signed. -- (optional) `` - Configuration object containing the following fields: - - `sigVerify: ` - if true the transaction signatures will be verified (default: false, conflicts with `replaceRecentBlockhash`) - - (optional) `commitment: ` - [Commitment](jsonrpc-api.md#configuring-state-commitment) level to simulate the transaction at (default: `"finalized"`). - - (optional) `encoding: ` - Encoding used for the transaction data. Either `"base58"` (_slow_, **DEPRECATED**), or `"base64"`. (default: `"base58"`). - - (optional) `replaceRecentBlockhash: ` - if true the transaction recent blockhash will be replaced with the most recent blockhash. - (default: false, conflicts with `sigVerify`) - - (optional) `accounts: ` - Accounts configuration object containing the following fields: - - (optional) `encoding: ` - encoding for returned Account data, either "base64" (default), "base64+zstd" or "jsonParsed". - ["jsonParsed" encoding](jsonrpc-api.md#parsed-responses) 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 - - (optional) `minContextSlot: ` - set the minimum slot that the request can be evaluated at. - -#### Results: - -An RpcResponse containing a TransactionStatus object -The result will be an RpcResponse JSON object with `value` set to a JSON object with the following fields: - -- `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) -- `logs: ` - Array of log messages the transaction instructions output during execution, null if simulation failed before the transaction was able to execute (for example due to an invalid blockhash or signature verification failure) -- `accounts: ` - array of accounts with the same length as the `accounts.addresses` array in the request - - `` - if the account doesn't exist or if `err` is not null - - `` - otherwise, a JSON object containing: - - `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 -- `unitsConsumed: `, The number of compute budget units consumed during the processing of this transaction -- `returnData: ` - the most-recent return data generated by an instruction in the transaction, with the following fields: - - `programId: `, the program that generated the return data, as base-58 encoded Pubkey - - `data: <[string, encoding]>`, the return data itself, as base-64 encoded binary data - -#### Example: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - { - "jsonrpc": "2.0", - "id": 1, - "method": "simulateTransaction", - "params": [ - "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEDArczbMia1tLmq7zz4DinMNN0pJ1JtLdqIJPUw3YrGCzYAMHBsgN27lcgB6H2WQvFgyZuJYHa46puOQo9yQ8CVQbd9uHXZaGT2cvhRs7reawctIXtX1s3kTqM9YV+/wCp20C7Wj2aiuk5TReAXo+VTVg8QTHjs0UjNMMKCvpzZ+ABAgEBARU=", - { - "encoding":"base64", - } - ] - } -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": { - "context": { - "slot": 218 - }, - "value": { - "err": null, - "accounts": null, - "logs": [ - "Program 83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri invoke [1]", - "Program 83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri consumed 2366 of 1400000 compute units", - "Program return: 83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri KgAAAAAAAAA=", - "Program 83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri success" - ], - "returnData": { - "data": [ - "Kg==", - "base64" - ], - "programId": "83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri" - }, - "unitsConsumed": 2366 - } - }, - "id": 1 -} -``` - -## Subscription Websocket - -After connecting to the RPC PubSub websocket at `ws://
    /`: - -- Submit subscription requests to the websocket using the methods below -- Multiple subscriptions may be active at once -- Many subscriptions take the optional [`commitment` parameter](jsonrpc-api.md#configuring-state-commitment), defining how finalized a change should be to trigger a notification. For subscriptions, if commitment is unspecified, the default value is `"finalized"`. - -### accountSubscribe - -Subscribe to an account to receive notifications when the lamports or data for a given account public key changes - -#### Parameters: - -- `` - account Pubkey, as base-58 encoded string -- (optional) `` - Configuration object containing the following optional fields: - - (optional) `commitment: ` - [Commitment](jsonrpc-api.md#configuring-state-commitment) - - `encoding: ` - encoding for Account data, either "base58" (_slow_), "base64", "base64+zstd" or "jsonParsed". - ["jsonParsed" encoding](jsonrpc-api.md#parsed-responses) 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: - -- `` - Subscription id \(needed to unsubscribe\) - -#### Example: - -Request: - -```json -{ - "jsonrpc": "2.0", - "id": 1, - "method": "accountSubscribe", - "params": [ - "CM78CPUeXjn8o3yroDHxUtKsZZgoy4GPkPPXfouKNH12", - { - "encoding": "base64", - "commitment": "finalized" - } - ] -} -{ - "jsonrpc": "2.0", - "id": 1, - "method": "accountSubscribe", - "params": [ - "CM78CPUeXjn8o3yroDHxUtKsZZgoy4GPkPPXfouKNH12", - { - "encoding": "jsonParsed" - } - ] -} -``` - -Result: - -```json -{ "jsonrpc": "2.0", "result": 23784, "id": 1 } -``` - -#### Notification Format: - -The notification format is the same as seen in the [getAccountInfo](jsonrpc-api.md#getAccountInfo) RPC HTTP method. - -Base58 encoding: - -```json -{ - "jsonrpc": "2.0", - "method": "accountNotification", - "params": { - "result": { - "context": { - "slot": 5199307 - }, - "value": { - "data": [ - "11116bv5nS2h3y12kD1yUKeMZvGcKLSjQgX6BeV7u1FrjeJcKfsHPXHRDEHrBesJhZyqnnq9qJeUuF7WHxiuLuL5twc38w2TXNLxnDbjmuR", - "base58" - ], - "executable": false, - "lamports": 33594, - "owner": "11111111111111111111111111111111", - "rentEpoch": 635 - } - }, - "subscription": 23784 - } -} -``` - -Parsed-JSON encoding: - -```json -{ - "jsonrpc": "2.0", - "method": "accountNotification", - "params": { - "result": { - "context": { - "slot": 5199307 - }, - "value": { - "data": { - "program": "nonce", - "parsed": { - "type": "initialized", - "info": { - "authority": "Bbqg1M4YVVfbhEzwA9SpC9FhsaG83YMTYoR4a8oTDLX", - "blockhash": "LUaQTmM7WbMRiATdMMHaRGakPtCkc2GHtH57STKXs6k", - "feeCalculator": { - "lamportsPerSignature": 5000 - } - } - } - }, - "executable": false, - "lamports": 33594, - "owner": "11111111111111111111111111111111", - "rentEpoch": 635 - } - }, - "subscription": 23784 - } -} -``` - -### accountUnsubscribe - -Unsubscribe from account change notifications - -#### Parameters: - -- `` - id of account Subscription to cancel - -#### Results: - -- `` - unsubscribe success message - -#### Example: - -Request: - -```json -{ "jsonrpc": "2.0", "id": 1, "method": "accountUnsubscribe", "params": [0] } -``` - -Result: - -```json -{ "jsonrpc": "2.0", "result": true, "id": 1 } -``` - -### blockSubscribe - Unstable, disabled by default - -**This subscription is unstable and only available if the validator was started -with the `--rpc-pubsub-enable-block-subscription` flag. The format of this -subscription may change in the future** - -Subscribe to receive notification anytime a new block is Confirmed or Finalized. - -#### Parameters: - -- `filter: |` - filter criteria for the logs to receive results by account type; currently supported: - - "all" - include all transactions in block - - `{ "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: ` - [Commitment](jsonrpc-api.md#configuring-state-commitment) - - (optional) `encoding: ` - encoding for Account data, either "base58" (_slow_), "base64", "base64+zstd" or "jsonParsed". - ["jsonParsed" encoding](jsonrpc-api.md#parsed-responses) 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. - -#### Results: - -- `integer` - subscription id \(needed to unsubscribe\) - -#### Example: - -Request: - -```json -{ "jsonrpc": "2.0", "id": "1", "method": "blockSubscribe", "params": ["all"] } -``` - -```json -{ - "jsonrpc": "2.0", - "id": "1", - "method": "blockSubscribe", - "params": [ - { - "mentionsAccountOrProgram": "LieKvPRE8XeX3Y2xVNHjKlpAScD12lYySBVQ4HqoJ5op" - }, - { - "commitment": "confirmed", - "encoding": "base64", - "showRewards": true, - "transactionDetails": "full" - } - ] -} -``` - -Result: - -```json -{ "jsonrpc": "2.0", "result": 0, "id": 1 } -``` - -#### Notification Format: - -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. - -```json -{ - "jsonrpc": "2.0", - "method": "blockNotification", - "params": { - "result": { - "context": { - "slot": 112301554 - }, - "value": { - "slot": 112301554, - "block": { - "previousBlockhash": "GJp125YAN4ufCSUvZJVdCyWQJ7RPWMmwxoyUQySydZA", - "blockhash": "6ojMHjctdqfB55JDpEpqfHnP96fiaHEcvzEQ2NNcxzHP", - "parentSlot": 112301553, - "transactions": [ - { - "transaction": [ - "OpltwoUvWxYi1P2U8vbIdE/aPntjYo5Aa0VQ2JJyeJE2g9Vvxk8dDGgFMruYfDu8/IfUWb0REppTe7IpAuuLRgIBAAkWnj4KHRpEWWW7gvO1c0BHy06wZi2g7/DLqpEtkRsThAXIdBbhXCLvltw50ZnjDx2hzw74NVn49kmpYj2VZHQJoeJoYJqaKcvuxCi/2i4yywedcVNDWkM84Iuw+cEn9/ROCrXY4qBFI9dveEERQ1c4kdU46xjxj9Vi+QXkb2Kx45QFVkG4Y7HHsoS6WNUiw2m4ffnMNnOVdF9tJht7oeuEfDMuUEaO7l9JeUxppCvrGk3CP45saO51gkwVYEgKzhpKjCx3rgsYxNR81fY4hnUQXSbbc2Y55FkwgRBpVvQK7/+clR4Gjhd3L4y+OtPl7QF93Akg1LaU9wRMs5nvfDFlggqI9PqJl+IvVWrNRdBbPS8LIIhcwbRTkSbqlJQWxYg3Bo2CTVbw7rt1ZubuHWWp0mD/UJpLXGm2JprWTePNULzHu67sfqaWF99LwmwjTyYEkqkRt1T0Je5VzHgJs0N5jY4iIU9K3lMqvrKOIn/2zEMZ+ol2gdgjshx+sphIyhw65F3J/Dbzk04LLkK+CULmN571Y+hFlXF2ke0BIuUG6AUF+4214Cu7FXnqo3rkxEHDZAk0lRrAJ8X/Z+iwuwI5cgbd9uHXZaGT2cvhRs7reawctIXtX1s3kTqM9YV+/wCpDLAp8axcEkaQkLDKRoWxqp8XLNZSKial7Rk+ELAVVKWoWLRXRZ+OIggu0OzMExvVLE5VHqy71FNHq4gGitkiKYNFWSLIE4qGfdFLZXy/6hwS+wq9ewjikCpd//C9BcCL7Wl0iQdUslxNVCBZHnCoPYih9JXvGefOb9WWnjGy14sG9j70+RSVx6BlkFELWwFvIlWR/tHn3EhHAuL0inS2pwX7ZQTAU6gDVaoqbR2EiJ47cKoPycBNvHLoKxoY9AZaBjPl6q8SKQJSFyFd9n44opAgI6zMTjYF/8Ok4VpXEESp3QaoUyTI9sOJ6oFP6f4dwnvQelgXS+AEfAsHsKXxGAIUDQENAgMEBQAGBwgIDg8IBJCER3QXl1AVDBADCQoOAAQLERITDAjb7ugh3gOuTy==", - "base64" - ], - "meta": { - "err": null, - "status": { - "Ok": null - }, - "fee": 5000, - "preBalances": [ - 1758510880, 2067120, 1566000, 1461600, 2039280, 2039280, - 1900080, 1865280, 0, 3680844220, 2039280 - ], - "postBalances": [ - 1758505880, 2067120, 1566000, 1461600, 2039280, 2039280, - 1900080, 1865280, 0, 3680844220, 2039280 - ], - "innerInstructions": [ - { - "index": 0, - "instructions": [ - { - "programIdIndex": 13, - "accounts": [1, 15, 3, 4, 2, 14], - "data": "21TeLgZXNbtHXVBzCaiRmH" - }, - { - "programIdIndex": 14, - "accounts": [3, 4, 1], - "data": "6qfC8ic7Aq99" - }, - { - "programIdIndex": 13, - "accounts": [1, 15, 3, 5, 2, 14], - "data": "21TeLgZXNbsn4QEpaSEr3q" - }, - { - "programIdIndex": 14, - "accounts": [3, 5, 1], - "data": "6LC7BYyxhFRh" - } - ] - }, - { - "index": 1, - "instructions": [ - { - "programIdIndex": 14, - "accounts": [4, 3, 0], - "data": "7aUiLHFjSVdZ" - }, - { - "programIdIndex": 19, - "accounts": [17, 18, 16, 9, 11, 12, 14], - "data": "8kvZyjATKQWYxaKR1qD53V" - }, - { - "programIdIndex": 14, - "accounts": [9, 11, 18], - "data": "6qfC8ic7Aq99" - } - ] - } - ], - "logMessages": [ - "Program QMNeHCGYnLVDn1icRAfQZpjPLBNkfGbSKRB83G5d8KB invoke [1]", - "Program QMWoBmAyJLAsA1Lh9ugMTw2gciTihncciphzdNzdZYV invoke [2]" - ], - "preTokenBalances": [ - { - "accountIndex": 4, - "mint": "iouQcQBAiEXe6cKLS85zmZxUqaCqBdeHFpqKoSz615u", - "uiTokenAmount": { - "uiAmount": null, - "decimals": 6, - "amount": "0", - "uiAmountString": "0" - }, - "owner": "LieKvPRE8XeX3Y2xVNHjKlpAScD12lYySBVQ4HqoJ5op", - "programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "accountIndex": 5, - "mint": "iouQcQBAiEXe6cKLS85zmZxUqaCqBdeHFpqKoSz615u", - "uiTokenAmount": { - "uiAmount": 11513.0679, - "decimals": 6, - "amount": "11513067900", - "uiAmountString": "11513.0679" - }, - "owner": "rXhAofQCT7NN9TUqigyEAUzV1uLL4boeD8CRkNBSkYk", - "programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "accountIndex": 10, - "mint": "Saber2gLauYim4Mvftnrasomsv6NvAuncvMEZwcLpD1", - "uiTokenAmount": { - "uiAmount": null, - "decimals": 6, - "amount": "0", - "uiAmountString": "0" - }, - "owner": "CL9wkGFT3SZRRNa9dgaovuRV7jrVVigBUZ6DjcgySsCU", - "programId": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" - }, - { - "accountIndex": 11, - "mint": "Saber2gLauYim4Mvftnrasomsv6NvAuncvMEZwcLpD1", - "uiTokenAmount": { - "uiAmount": 15138.514093, - "decimals": 6, - "amount": "15138514093", - "uiAmountString": "15138.514093" - }, - "owner": "LieKvPRE8XeX3Y2xVNHjKlpAScD12lYySBVQ4HqoJ5op", - "programId": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" - } - ], - "postTokenBalances": [ - { - "accountIndex": 4, - "mint": "iouQcQBAiEXe6cKLS85zmZxUqaCqBdeHFpqKoSz615u", - "uiTokenAmount": { - "uiAmount": null, - "decimals": 6, - "amount": "0", - "uiAmountString": "0" - }, - "owner": "LieKvPRE8XeX3Y2xVNHjKlpAScD12lYySBVQ4HqoJ5op", - "programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "accountIndex": 5, - "mint": "iouQcQBAiEXe6cKLS85zmZxUqaCqBdeHFpqKoSz615u", - "uiTokenAmount": { - "uiAmount": 11513.103028, - "decimals": 6, - "amount": "11513103028", - "uiAmountString": "11513.103028" - }, - "owner": "rXhAofQCT7NN9TUqigyEAUzV1uLL4boeD8CRkNBSkYk", - "programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "accountIndex": 10, - "mint": "Saber2gLauYim4Mvftnrasomsv6NvAuncvMEZwcLpD1", - "uiTokenAmount": { - "uiAmount": null, - "decimals": 6, - "amount": "0", - "uiAmountString": "0" - }, - "owner": "CL9wkGFT3SZRRNa9dgaovuRV7jrVVigBUZ6DjcgySsCU", - "programId": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" - }, - { - "accountIndex": 11, - "mint": "Saber2gLauYim4Mvftnrasomsv6NvAuncvMEZwcLpD1", - "uiTokenAmount": { - "uiAmount": 15489.767829, - "decimals": 6, - "amount": "15489767829", - "uiAmountString": "15489.767829" - }, - "owner": "BeiHVPRE8XeX3Y2xVNrSsTpAScH94nYySBVQ4HqgN9at", - "programId": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" - } - ], - "rewards": [] - } - } - ], - "blockTime": 1639926816, - "blockHeight": 101210751 - }, - "err": null - } - }, - "subscription": 14 - } -} -``` - -### blockUnsubscribe - -Unsubscribe from block notifications - -#### Parameters: - -- `` - subscription id to cancel - -#### Results: - -- `` - unsubscribe success message - -#### Example: - -Request: - -```json -{ "jsonrpc": "2.0", "id": 1, "method": "blockUnsubscribe", "params": [0] } -``` - -Response: - -```json -{ "jsonrpc": "2.0", "result": true, "id": 1 } -``` - -### logsSubscribe - -Subscribe to transaction logging - -#### Parameters: - -- `filter: |` - filter criteria for the logs to receive results by account type; currently supported: - - "all" - subscribe to all transactions except for simple vote transactions - - "allWithVotes" - subscribe to all transactions including simple vote transactions - - `{ "mentions": [ ] }` - subscribe to all transactions that mention the provided Pubkey (as base-58 encoded string) -- (optional) `` - Configuration object containing the following optional fields: - - (optional) `commitment: ` - [Commitment](jsonrpc-api.md#configuring-state-commitment) - -#### Results: - -- `` - Subscription id \(needed to unsubscribe\) - -#### Example: - -Request: - -```json -{ - "jsonrpc": "2.0", - "id": 1, - "method": "logsSubscribe", - "params": [ - { - "mentions": [ "11111111111111111111111111111111" ] - }, - { - "commitment": "finalized" - } - ] -} -{ - "jsonrpc": "2.0", - "id": 1, - "method": "logsSubscribe", - "params": [ "all" ] -} -``` - -Result: - -```json -{ "jsonrpc": "2.0", "result": 24040, "id": 1 } -``` - -#### Notification Format: - -The notification will be an RpcResponse JSON object with value equal to: - -- `signature: ` - The transaction signature base58 encoded. -- `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) -- `logs: ` - Array of log messages the transaction instructions output during execution, null if simulation failed before the transaction was able to execute (for example due to an invalid blockhash or signature verification failure) - -Example: - -```json -{ - "jsonrpc": "2.0", - "method": "logsNotification", - "params": { - "result": { - "context": { - "slot": 5208469 - }, - "value": { - "signature": "5h6xBEauJ3PK6SWCZ1PGjBvj8vDdWG3KpwATGy1ARAXFSDwt8GFXM7W5Ncn16wmqokgpiKRLuS83KUxyZyv2sUYv", - "err": null, - "logs": [ - "BPF program 83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri success" - ] - } - }, - "subscription": 24040 - } -} -``` - -### logsUnsubscribe - -Unsubscribe from transaction logging - -#### Parameters: - -- `` - id of subscription to cancel - -#### Results: - -- `` - unsubscribe success message - -#### Example: - -Request: - -```json -{ "jsonrpc": "2.0", "id": 1, "method": "logsUnsubscribe", "params": [0] } -``` - -Result: - -```json -{ "jsonrpc": "2.0", "result": true, "id": 1 } -``` - -### programSubscribe - -Subscribe to a program to receive notifications when the lamports or data for a given account owned by the program changes - -#### Parameters: - -- `` - program_id Pubkey, as base-58 encoded string -- (optional) `` - Configuration object containing the following optional fields: - - (optional) `commitment: ` - [Commitment](jsonrpc-api.md#configuring-state-commitment) - - `encoding: ` - encoding for Account data, either "base58" (_slow_), "base64", "base64+zstd" or "jsonParsed". - ["jsonParsed" encoding](jsonrpc-api.md#parsed-responses) 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 - -#### Results: - -- `` - Subscription id \(needed to unsubscribe\) - -#### Example: - -Request: - -```json -{ - "jsonrpc": "2.0", - "id": 1, - "method": "programSubscribe", - "params": [ - "11111111111111111111111111111111", - { - "encoding": "base64", - "commitment": "finalized" - } - ] -} -{ - "jsonrpc": "2.0", - "id": 1, - "method": "programSubscribe", - "params": [ - "11111111111111111111111111111111", - { - "encoding": "jsonParsed" - } - ] -} -{ - "jsonrpc": "2.0", - "id": 1, - "method": "programSubscribe", - "params": [ - "11111111111111111111111111111111", - { - "encoding": "base64", - "filters": [ - { - "dataSize": 80 - } - ] - } - ] -} -``` - -Result: - -```json -{ "jsonrpc": "2.0", "result": 24040, "id": 1 } -``` - -#### Notification Format: - -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", - "method": "programNotification", - "params": { - "result": { - "context": { - "slot": 5208469 - }, - "value": { - "pubkey": "H4vnBqifaSACnKa7acsxstsY1iV1bvJNxsCY7enrd1hq", - "account": { - "data": [ - "11116bv5nS2h3y12kD1yUKeMZvGcKLSjQgX6BeV7u1FrjeJcKfsHPXHRDEHrBesJhZyqnnq9qJeUuF7WHxiuLuL5twc38w2TXNLxnDbjmuR", - "base58" - ], - "executable": false, - "lamports": 33594, - "owner": "11111111111111111111111111111111", - "rentEpoch": 636 - } - } - }, - "subscription": 24040 - } -} -``` - -Parsed-JSON encoding: - -```json -{ - "jsonrpc": "2.0", - "method": "programNotification", - "params": { - "result": { - "context": { - "slot": 5208469 - }, - "value": { - "pubkey": "H4vnBqifaSACnKa7acsxstsY1iV1bvJNxsCY7enrd1hq", - "account": { - "data": { - "program": "nonce", - "parsed": { - "type": "initialized", - "info": { - "authority": "Bbqg1M4YVVfbhEzwA9SpC9FhsaG83YMTYoR4a8oTDLX", - "blockhash": "LUaQTmM7WbMRiATdMMHaRGakPtCkc2GHtH57STKXs6k", - "feeCalculator": { - "lamportsPerSignature": 5000 - } - } - } - }, - "executable": false, - "lamports": 33594, - "owner": "11111111111111111111111111111111", - "rentEpoch": 636 - } - } - }, - "subscription": 24040 - } -} -``` - -### programUnsubscribe - -Unsubscribe from program-owned account change notifications - -#### Parameters: - -- `` - id of account Subscription to cancel - -#### Results: - -- `` - unsubscribe success message - -#### Example: - -Request: - -```json -{ "jsonrpc": "2.0", "id": 1, "method": "programUnsubscribe", "params": [0] } -``` - -Result: - -```json -{ "jsonrpc": "2.0", "result": true, "id": 1 } -``` - -### signatureSubscribe - -Subscribe to a transaction signature to receive notification when the transaction is confirmed On `signatureNotification`, the subscription is automatically cancelled - -#### Parameters: - -- `` - Transaction Signature, as base-58 encoded string -- (optional) `` - Configuration object containing the following field: - - (optional) `commitment: ` - [Commitment](jsonrpc-api.md#configuring-state-commitment) - -#### Results: - -- `integer` - subscription id \(needed to unsubscribe\) - -#### Example: - -Request: - -```json -{ - "jsonrpc": "2.0", - "id": 1, - "method": "signatureSubscribe", - "params": [ - "2EBVM6cB8vAAD93Ktr6Vd8p67XPbQzCJX47MpReuiCXJAtcjaxpvWpcg9Ege1Nr5Tk3a2GFrByT7WPBjdsTycY9b" - ] -} - -{ - "jsonrpc": "2.0", - "id": 1, - "method": "signatureSubscribe", - "params": [ - "2EBVM6cB8vAAD93Ktr6Vd8p67XPbQzCJX47MpReuiCXJAtcjaxpvWpcg9Ege1Nr5Tk3a2GFrByT7WPBjdsTycY9b", - { - "commitment": "finalized" - } - ] -} -``` - -Result: - -```json -{ "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", - "method": "signatureNotification", - "params": { - "result": { - "context": { - "slot": 5207624 - }, - "value": { - "err": null - } - }, - "subscription": 24006 - } -} -``` - -### signatureUnsubscribe - -Unsubscribe from signature confirmation notification - -#### Parameters: - -- `` - subscription id to cancel - -#### Results: - -- `` - unsubscribe success message - -#### Example: - -Request: - -```json -{ "jsonrpc": "2.0", "id": 1, "method": "signatureUnsubscribe", "params": [0] } -``` - -Result: - -```json -{ "jsonrpc": "2.0", "result": true, "id": 1 } -``` - -### slotSubscribe - -Subscribe to receive notification anytime a slot is processed by the validator - -#### Parameters: - -None - -#### Results: - -- `integer` - subscription id \(needed to unsubscribe\) - -#### Example: - -Request: - -```json -{ "jsonrpc": "2.0", "id": 1, "method": "slotSubscribe" } -``` - -Result: - -```json -{ "jsonrpc": "2.0", "result": 0, "id": 1 } -``` - -#### Notification Format: - -The notification will be an object with the following fields: - -- `parent: ` - The parent slot -- `root: ` - The current root slot -- `slot: ` - The newly set slot value - -Example: - -```json -{ - "jsonrpc": "2.0", - "method": "slotNotification", - "params": { - "result": { - "parent": 75, - "root": 44, - "slot": 76 - }, - "subscription": 0 - } -} -``` - -### slotUnsubscribe - -Unsubscribe from slot notifications - -#### Parameters: - -- `` - subscription id to cancel - -#### Results: - -- `` - unsubscribe success message - -#### Example: - -Request: - -```json -{ "jsonrpc": "2.0", "id": 1, "method": "slotUnsubscribe", "params": [0] } -``` - -Result: - -```json -{ "jsonrpc": "2.0", "result": true, "id": 1 } -``` - -### slotsUpdatesSubscribe - Unstable - -**This subscription is unstable; the format of this subscription may change in -the future and it may not always be supported** - -Subscribe to receive a notification from the validator on a variety of updates -on every slot - -#### Parameters: - -None - -#### Results: - -- `integer` - subscription id \(needed to unsubscribe\) - -#### Example: - -Request: - -```json -{ "jsonrpc": "2.0", "id": 1, "method": "slotsUpdatesSubscribe" } -``` - -Result: - -```json -{ "jsonrpc": "2.0", "result": 0, "id": 1 } -``` - -#### Notification Format: - -The notification will be an object with the following fields: - -- `parent: ` - The parent slot -- `slot: ` - The newly updated slot -- `timestamp: ` - The Unix timestamp of the update -- `type: ` - The update type, one of: - - "firstShredReceived" - - "completed" - - "createdBank" - - "frozen" - - "dead" - - "optimisticConfirmation" - - "root" - -```bash -{ - "jsonrpc": "2.0", - "method": "slotsUpdatesNotification", - "params": { - "result": { - "parent": 75, - "slot": 76, - "timestamp": 1625081266243, - "type": "optimisticConfirmation" - }, - "subscription": 0 - } -} -``` - -### slotsUpdatesUnsubscribe - -Unsubscribe from slot-update notifications - -#### Parameters: - -- `` - subscription id to cancel - -#### Results: - -- `` - unsubscribe success message - -#### Example: - -Request: - -```json -{ - "jsonrpc": "2.0", - "id": 1, - "method": "slotsUpdatesUnsubscribe", - "params": [0] -} -``` - -Result: - -```json -{ "jsonrpc": "2.0", "result": true, "id": 1 } -``` - -### rootSubscribe - -Subscribe to receive notification anytime a new root is set by the validator. - -#### Parameters: - -None - -#### Results: - -- `integer` - subscription id \(needed to unsubscribe\) - -#### Example: - -Request: - -```json -{ "jsonrpc": "2.0", "id": 1, "method": "rootSubscribe" } -``` - -Result: - -```json -{ "jsonrpc": "2.0", "result": 0, "id": 1 } -``` - -#### Notification Format: - -The result is the latest root slot number. - -```json -{ - "jsonrpc": "2.0", - "method": "rootNotification", - "params": { - "result": 42, - "subscription": 0 - } -} -``` - -### rootUnsubscribe - -Unsubscribe from root notifications - -#### Parameters: - -- `` - subscription id to cancel - -#### Results: - -- `` - unsubscribe success message - -#### Example: - -Request: - -```json -{ "jsonrpc": "2.0", "id": 1, "method": "rootUnsubscribe", "params": [0] } -``` - -Result: - -```json -{ "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 -subscription may change in the future** - -Subscribe to receive notification anytime a new vote is observed in gossip. -These votes are pre-consensus therefore there is no guarantee these votes will -enter the ledger. - -#### Parameters: - -None - -#### Results: - -- `integer` - subscription id \(needed to unsubscribe\) - -#### Example: - -Request: - -```json -{ "jsonrpc": "2.0", "id": 1, "method": "voteSubscribe" } -``` - -Result: - -```json -{ "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 -- `signature: ` - The signature of the transaction that contained this vote - -```json -{ - "jsonrpc": "2.0", - "method": "voteNotification", - "params": { - "result": { - "hash": "8Rshv2oMkPu5E4opXTRyuyBeZBqQ4S477VG26wUTFxUM", - "slots": [1, 2], - "timestamp": null - }, - "subscription": 0 - } -} -``` - -### voteUnsubscribe - -Unsubscribe from vote notifications - -#### Parameters: - -- `` - subscription id to cancel - -#### Results: - -- `` - unsubscribe success message - -#### Example: - -Request: - -```json -{ "jsonrpc": "2.0", "id": 1, "method": "voteUnsubscribe", "params": [0] } -``` - -Response: - -```json -{ "jsonrpc": "2.0", "result": true, "id": 1 } -``` - -## JSON RPC API Deprecated Methods - -### getConfirmedBlock - -**DEPRECATED: Please use [getBlock](jsonrpc-api.md#getblock) instead** -This method is expected to be removed in solana-core v2.0 - -Returns identity and transaction information about a confirmed block in the ledger - -#### Parameters: - -- `` - 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](jsonrpc-api.md#parsed-responses) 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: ` - [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 object with the following fields: - -- `` - if specified block is not confirmed -- `` - if block is confirmed, an object with the following fields: - - `blockhash: ` - the blockhash of this block, as base-58 encoded string - - `previousBlockhash: ` - the blockhash of this block's parent, as base-58 encoded string; if the parent block is not available due to ledger cleanup, this field will return "11111111111111111111111111111111" - - `parentSlot: ` - the slot index of this block's parent - - `transactions: ` - present if "full" transaction details are requested; an array of JSON objects containing: - - `transaction: ` - [Transaction](#transaction-structure) object, either in JSON format or encoded binary data, depending on encoding parameter - - `meta: ` - transaction status metadata object, containing `null` or: - - `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) - - `fee: ` - fee this transaction was charged, as u64 integer - - `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 - - `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 - - `"Ok": ` - Transaction was successful - - `"Err": ` - Transaction failed with TransactionError - - `signatures: ` - present if "signatures" are requested for transaction details; an array of signatures strings, corresponding to the transaction order in the block - - `rewards: ` - present if rewards are requested; an array of JSON objects containing: - - `pubkey: ` - The public key, as base-58 encoded string, of the account that received the reward - - `lamports: `- number of reward lamports credited or debited by the account, as a i64 - - `postBalance: ` - account balance in lamports after the reward was applied - - `rewardType: ` - type of reward: "fee", "rent", "voting", "staking" - - `commission: ` - vote account commission when the reward was credited, only present for voting and staking rewards - - `blockTime: ` - estimated production time, as Unix timestamp (seconds since the Unix epoch). null if not available - -#### 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}]} -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": { - "blockTime": null, - "blockhash": "3Eq21vXNB5s86c62bVuUfTeaMif1N2kUqRPBmGRJhyTA", - "parentSlot": 429, - "previousBlockhash": "mfcyqEXB3DnHXki6KjjmZck6YjmZLvpAByy2fj4nh6B", - "transactions": [ - { - "meta": { - "err": null, - "fee": 5000, - "innerInstructions": [], - "logMessages": [], - "postBalances": [499998932500, 26858640, 1, 1, 1], - "postTokenBalances": [], - "preBalances": [499998937500, 26858640, 1, 1, 1], - "preTokenBalances": [], - "status": { - "Ok": null - } - }, - "transaction": { - "message": { - "accountKeys": [ - "3UVYmECPPMZSCqWKfENfuoTv51fTDTWicX9xmBD2euKe", - "AjozzgE83A3x1sHNUR64hfH7zaEBWeMaFuAN9kQgujrc", - "SysvarS1otHashes111111111111111111111111111", - "SysvarC1ock11111111111111111111111111111111", - "Vote111111111111111111111111111111111111111" - ], - "header": { - "numReadonlySignedAccounts": 0, - "numReadonlyUnsignedAccounts": 3, - "numRequiredSignatures": 1 - }, - "instructions": [ - { - "accounts": [1, 2, 3, 0], - "data": "37u9WtQpcm6ULa3WRQHmj49EPs4if7o9f1jSRVZpm2dvihR9C8jY4NqEwXUbLwx15HBSNcP1", - "programIdIndex": 4 - } - ], - "recentBlockhash": "mfcyqEXB3DnHXki6KjjmZck6YjmZLvpAByy2fj4nh6B" - }, - "signatures": [ - "2nBhEBYYvfaAe16UMNqRHre4YNSskvuYgx3M6E4JP1oDYvZEJHvoPzyUidNgNX5r9sTyN1J9UxtbCXy2rqYcuyuv" - ] - } - } - ] - }, - "id": 1 -} -``` - -#### 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"]} -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": { - "blockTime": null, - "blockhash": "3Eq21vXNB5s86c62bVuUfTeaMif1N2kUqRPBmGRJhyTA", - "parentSlot": 429, - "previousBlockhash": "mfcyqEXB3DnHXki6KjjmZck6YjmZLvpAByy2fj4nh6B", - "rewards": [], - "transactions": [ - { - "meta": { - "err": null, - "fee": 5000, - "innerInstructions": [], - "logMessages": [], - "postBalances": [499998932500, 26858640, 1, 1, 1], - "postTokenBalances": [], - "preBalances": [499998937500, 26858640, 1, 1, 1], - "preTokenBalances": [], - "status": { - "Ok": null - } - }, - "transaction": [ - "AVj7dxHlQ9IrvdYVIjuiRFs1jLaDMHixgrv+qtHBwz51L4/ImLZhszwiyEJDIp7xeBSpm/TX5B7mYzxa+fPOMw0BAAMFJMJVqLw+hJYheizSoYlLm53KzgT82cDVmazarqQKG2GQsLgiqktA+a+FDR4/7xnDX7rsusMwryYVUdixfz1B1Qan1RcZLwqvxvJl4/t3zHragsUp0L47E24tAFUgAAAABqfVFxjHdMkoVmOYaR1etoteuKObS21cc1VbIQAAAAAHYUgdNXR0u3xNdiTr072z2DVec9EQQ/wNo1OAAAAAAAtxOUhPBp2WSjUNJEgfvy70BbxI00fZyEPvFHNfxrtEAQQEAQIDADUCAAAAAQAAAAAAAACtAQAAAAAAAAdUE18R96XTJCe+YfRfUp6WP+YKCy/72ucOL8AoBFSpAA==", - "base64" - ] - } - ] - }, - "id": 1 -} -``` - -For more details on returned data: -[Transaction Structure](jsonrpc-api.md#transaction-structure) -[Inner Instructions Structure](jsonrpc-api.md#inner-instructions-structure) -[Token Balances Structure](jsonrpc-api.md#token-balances-structure) - -### getConfirmedBlocks - -**DEPRECATED: Please use [getBlocks](jsonrpc-api.md#getblocks) instead** -This method is expected to be removed in solana-core v2.0 - -Returns a list of confirmed blocks between two slots - -#### Parameters: - -- `` - start_slot, as u64 integer -- (optional) `` - end_slot, as u64 integer -- (optional) `` - Configuration object containing the following field: - - (optional) `commitment: ` - [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 u64 integers listing confirmed blocks -between `start_slot` and either `end_slot`, if provided, or latest confirmed block, -inclusive. Max range allowed is 500,000 slots. - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc": "2.0","id":1,"method":"getConfirmedBlocks","params":[5, 10]} -' -``` - -Result: - -```json -{ "jsonrpc": "2.0", "result": [5, 6, 7, 8, 9, 10], "id": 1 } -``` - -### getConfirmedBlocksWithLimit - -**DEPRECATED: Please use [getBlocksWithLimit](jsonrpc-api.md#getblockswithlimit) instead** -This method is expected to be removed in solana-core v2.0 - -Returns a list of confirmed blocks starting at the given slot - -#### Parameters: - -- `` - start_slot, as u64 integer -- `` - limit, as u64 integer -- (optional) `` - Configuration object containing the following field: - - (optional) `commitment: ` - [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 u64 integers listing confirmed blocks -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]} -' -``` - -Result: - -```json -{ "jsonrpc": "2.0", "result": [5, 6, 7], "id": 1 } -``` - -### getConfirmedSignaturesForAddress2 - -**DEPRECATED: Please use [getSignaturesForAddress](jsonrpc-api.md#getsignaturesforaddress) instead** -This method is expected to be removed in solana-core v2.0 - -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: - - (optional) `limit: ` - maximum transaction signatures to return (between 1 and 1,000, default: 1,000). - - (optional) `before: ` - start searching backwards from this transaction signature. - If not provided the search starts from the top of the highest max confirmed block. - - (optional) `until: ` - search until this transaction signature, if found before limit reached. - - (optional) `commitment: ` - [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. - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - { - "jsonrpc": "2.0", - "id": 1, - "method": "getConfirmedSignaturesForAddress2", - "params": [ - "Vote111111111111111111111111111111111111111", - { - "limit": 1 - } - ] - } -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": [ - { - "err": null, - "memo": null, - "signature": "5h6xBEauJ3PK6SWCZ1PGjBvj8vDdWG3KpwATGy1ARAXFSDwt8GFXM7W5Ncn16wmqokgpiKRLuS83KUxyZyv2sUYv", - "slot": 114, - "blockTime": null - } - ], - "id": 1 -} -``` - -### getConfirmedTransaction - -**DEPRECATED: Please use [getTransaction](jsonrpc-api.md#gettransaction) instead** -This method is expected to be removed in solana-core v2.0 - -Returns transaction details for a confirmed transaction - -#### Parameters: - -- `` - 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](jsonrpc-api.md#parsed-responses) 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: ` - [Commitment](jsonrpc-api.md#configuring-state-commitment); "processed" is not supported. If parameter not provided, the default is "finalized". - -#### Results: - -- `` - if transaction is not found or not confirmed -- `` - if transaction is confirmed, an object with the following fields: - - `slot: ` - the slot this transaction was processed in - - `transaction: ` - [Transaction](#transaction-structure) object, either in JSON format or encoded binary data, depending on encoding parameter - - `blockTime: ` - estimated production time, as Unix timestamp (seconds since the Unix epoch) of when the transaction was processed. null if not available - - `meta: ` - transaction status metadata object: - - `err: ` - Error if transaction failed, null if transaction succeeded. [TransactionError definitions](https://docs.rs/solana-sdk/VERSION_FOR_DOCS_RS/solana_sdk/transaction/enum.TransactionError.html) - - `fee: ` - fee this transaction was charged, as u64 integer - - `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 - - `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 - - `"Ok": ` - Transaction was successful - - `"Err": ` - Transaction failed with TransactionError - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - { - "jsonrpc": "2.0", - "id": 1, - "method": "getConfirmedTransaction", - "params": [ - "2nBhEBYYvfaAe16UMNqRHre4YNSskvuYgx3M6E4JP1oDYvZEJHvoPzyUidNgNX5r9sTyN1J9UxtbCXy2rqYcuyuv", - "json" - ] - } -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": { - "meta": { - "err": null, - "fee": 5000, - "innerInstructions": [], - "postBalances": [499998932500, 26858640, 1, 1, 1], - "postTokenBalances": [], - "preBalances": [499998937500, 26858640, 1, 1, 1], - "preTokenBalances": [], - "status": { - "Ok": null - } - }, - "slot": 430, - "transaction": { - "message": { - "accountKeys": [ - "3UVYmECPPMZSCqWKfENfuoTv51fTDTWicX9xmBD2euKe", - "AjozzgE83A3x1sHNUR64hfH7zaEBWeMaFuAN9kQgujrc", - "SysvarS1otHashes111111111111111111111111111", - "SysvarC1ock11111111111111111111111111111111", - "Vote111111111111111111111111111111111111111" - ], - "header": { - "numReadonlySignedAccounts": 0, - "numReadonlyUnsignedAccounts": 3, - "numRequiredSignatures": 1 - }, - "instructions": [ - { - "accounts": [1, 2, 3, 0], - "data": "37u9WtQpcm6ULa3WRQHmj49EPs4if7o9f1jSRVZpm2dvihR9C8jY4NqEwXUbLwx15HBSNcP1", - "programIdIndex": 4 - } - ], - "recentBlockhash": "mfcyqEXB3DnHXki6KjjmZck6YjmZLvpAByy2fj4nh6B" - }, - "signatures": [ - "2nBhEBYYvfaAe16UMNqRHre4YNSskvuYgx3M6E4JP1oDYvZEJHvoPzyUidNgNX5r9sTyN1J9UxtbCXy2rqYcuyuv" - ] - } - }, - "blockTime": null, - "id": 1 -} -``` - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - { - "jsonrpc": "2.0", - "id": 1, - "method": "getConfirmedTransaction", - "params": [ - "2nBhEBYYvfaAe16UMNqRHre4YNSskvuYgx3M6E4JP1oDYvZEJHvoPzyUidNgNX5r9sTyN1J9UxtbCXy2rqYcuyuv", - "base64" - ] - } -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": { - "meta": { - "err": null, - "fee": 5000, - "innerInstructions": [], - "postBalances": [499998932500, 26858640, 1, 1, 1], - "postTokenBalances": [], - "preBalances": [499998937500, 26858640, 1, 1, 1], - "preTokenBalances": [], - "status": { - "Ok": null - } - }, - "slot": 430, - "transaction": [ - "AVj7dxHlQ9IrvdYVIjuiRFs1jLaDMHixgrv+qtHBwz51L4/ImLZhszwiyEJDIp7xeBSpm/TX5B7mYzxa+fPOMw0BAAMFJMJVqLw+hJYheizSoYlLm53KzgT82cDVmazarqQKG2GQsLgiqktA+a+FDR4/7xnDX7rsusMwryYVUdixfz1B1Qan1RcZLwqvxvJl4/t3zHragsUp0L47E24tAFUgAAAABqfVFxjHdMkoVmOYaR1etoteuKObS21cc1VbIQAAAAAHYUgdNXR0u3xNdiTr072z2DVec9EQQ/wNo1OAAAAAAAtxOUhPBp2WSjUNJEgfvy70BbxI00fZyEPvFHNfxrtEAQQEAQIDADUCAAAAAQAAAAAAAACtAQAAAAAAAAdUE18R96XTJCe+YfRfUp6WP+YKCy/72ucOL8AoBFSpAA==", - "base64" - ] - }, - "id": 1 -} -``` - -### getFeeCalculatorForBlockhash - -**DEPRECATED: Please use [isBlockhashValid](jsonrpc-api.md#isblockhashvalid) or [getFeeForMessage](jsonrpc-api.md#getfeeformessage) instead** -This method is expected to be removed in solana-core v2.0 - -Returns the fee calculator associated with the query blockhash, or `null` if the blockhash has expired - -#### Parameters: - -- `` - query blockhash as a Base58 encoded string -- (optional) `` - Configuration object containing the following fields: - - (optional) `commitment: ` - [Commitment](jsonrpc-api.md#configuring-state-commitment) - - (optional) `minContextSlot: ` - set the minimum slot that the request can be evaluated at. - -#### Results: - -The result will be an RpcResponse JSON object with `value` equal to: - -- `` - if the query blockhash has expired -- `` - otherwise, a JSON object containing: - - `feeCalculator: `, `FeeCalculator` object describing the cluster fee rate at the queried blockhash - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - { - "jsonrpc": "2.0", - "id": 1, - "method": "getFeeCalculatorForBlockhash", - "params": [ - "GJxqhuxcgfn5Tcj6y3f8X4FeCDd2RQ6SnEMo1AAxrPRZ" - ] - } -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": { - "context": { - "slot": 221 - }, - "value": { - "feeCalculator": { - "lamportsPerSignature": 5000 - } - } - }, - "id": 1 -} -``` - -### getFeeRateGovernor - -Returns the fee rate governor information from the root bank - -#### Parameters: - -None - -#### Results: - -The `result` field will be an `object` with the following fields: - -- `burnPercent: `, Percentage of fees collected to be destroyed -- `maxLamportsPerSignature: `, Largest value `lamportsPerSignature` can attain for the next slot -- `minLamportsPerSignature: `, Smallest value `lamportsPerSignature` can attain for the next slot -- `targetLamportsPerSignature: `, Desired fee rate for the cluster -- `targetSignaturesPerSlot: `, Desired signature rate for the cluster - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc":"2.0","id":1, "method":"getFeeRateGovernor"} -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": { - "context": { - "slot": 54 - }, - "value": { - "feeRateGovernor": { - "burnPercent": 50, - "maxLamportsPerSignature": 100000, - "minLamportsPerSignature": 5000, - "targetLamportsPerSignature": 10000, - "targetSignaturesPerSlot": 20000 - } - } - }, - "id": 1 -} -``` - -### getFees - -**DEPRECATED: Please use [getFeeForMessage](jsonrpc-api.md#getfeeformessage) instead** -This method is expected to be removed in solana-core v2.0 - -Returns a recent block hash from the ledger, a fee schedule that can be used to -compute the cost of submitting a transaction using it, and the last slot in -which the blockhash will be valid. - -#### Parameters: - -- (optional) `` - Configuration object containing the following field: - - (optional) `commitment: ` - [Commitment](jsonrpc-api.md#configuring-state-commitment) - -#### Results: - -The result will be an RpcResponse JSON object with `value` set to a JSON object with the following fields: - -- `blockhash: ` - a Hash as base-58 encoded string -- `feeCalculator: ` - FeeCalculator object, the fee schedule for this block hash -- `lastValidSlot: ` - DEPRECATED - this value is inaccurate and should not be relied upon -- `lastValidBlockHeight: ` - last [block height](../../terminology.md#block-height) at which the blockhash will be valid - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc":"2.0","id":1, "method":"getFees"} -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": { - "context": { - "slot": 1 - }, - "value": { - "blockhash": "CSymwgTNX1j3E4qhKfJAUE41nBWEwXufoYryPbkde5RR", - "feeCalculator": { - "lamportsPerSignature": 5000 - }, - "lastValidSlot": 297, - "lastValidBlockHeight": 296 - } - }, - "id": 1 -} -``` - -### getRecentBlockhash - -**DEPRECATED: Please use [getLatestBlockhash](jsonrpc-api.md#getlatestblockhash) instead** -This method is expected to be removed in solana-core v2.0 - -Returns a recent block hash from the ledger, and a fee schedule that can be used to compute the cost of submitting a transaction using it. - -#### Parameters: - -- (optional) `` - Configuration object containing the following field: - - (optional) `commitment: ` - [Commitment](jsonrpc-api.md#configuring-state-commitment) - -#### Results: - -An RpcResponse containing a JSON object consisting of a string blockhash and FeeCalculator JSON object. - -- `RpcResponse` - RpcResponse JSON object with `value` field set to a JSON object including: -- `blockhash: ` - a Hash as base-58 encoded string -- `feeCalculator: ` - FeeCalculator object, the fee schedule for this block hash - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc":"2.0","id":1, "method":"getRecentBlockhash"} -' -``` - -Result: - -```json -{ - "jsonrpc": "2.0", - "result": { - "context": { - "slot": 1 - }, - "value": { - "blockhash": "CSymwgTNX1j3E4qhKfJAUE41nBWEwXufoYryPbkde5RR", - "feeCalculator": { - "lamportsPerSignature": 5000 - } - } - }, - "id": 1 -} -``` - -### getSnapshotSlot - -**DEPRECATED: Please use [getHighestSnapshotSlot](jsonrpc-api.md#gethighestsnapshotslot) instead** -This method is expected to be removed in solana-core v2.0 - -Returns the highest slot that the node has a snapshot for - -#### Parameters: - -None - -#### Results: - -- `` - Snapshot slot - -#### Example: - -Request: - -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc":"2.0","id":1, "method":"getSnapshotSlot"} -' -``` - -Result: - -```json -{ "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 -} -``` diff --git a/docs/src/developing/clients/rust-api.md b/docs/src/developing/clients/rust-api.md index 6deaf81443acdb..dd49310d00f525 100644 --- a/docs/src/developing/clients/rust-api.md +++ b/docs/src/developing/clients/rust-api.md @@ -19,7 +19,7 @@ Some important crates: that do not run on-chain will import this. - [`solana-client`] — For interacting with a Solana node via the - [JSON RPC API](jsonrpc-api). + [JSON RPC API](/api). - [`solana-cli-config`] — Loading and saving the Solana CLI configuration file. diff --git a/docs/src/developing/intro/rent.md b/docs/src/developing/intro/rent.md index 05cdebb948abf1..544608efe4551a 100644 --- a/docs/src/developing/intro/rent.md +++ b/docs/src/developing/intro/rent.md @@ -21,7 +21,7 @@ Currently, the rent rate is a static amount and stored in the the [Rent sysvar]( Accounts that maintain a minimum LAMPORT balance greater than 2 years worth of rent payments are considered "_rent exempt_" and will not incur a rent collection. -> At the time of writing this, new Accounts and Programs **are required** to be initialized with enough LAMPORTS to become rent-exempt. The RPC endpoints have the ability to calculate this [estimated rent exempt balance](../clients/jsonrpc-api.md#getminimumbalanceforrentexemption) and is recommended to be used. +> At the time of writing this, new Accounts and Programs **are required** to be initialized with enough LAMPORTS to become rent-exempt. The RPC endpoints have the ability to calculate this [estimated rent exempt balance](../../api/http#getminimumbalanceforrentexemption) and is recommended to be used. Every time an account's balance is reduced, a check is performed to see if the account is still rent exempt. Transactions that would cause an account's balance to drop below the rent exempt threshold will fail. diff --git a/docs/src/developing/intro/transaction_fees.md b/docs/src/developing/intro/transaction_fees.md index 520cfe30431d1c..382dae826217e8 100644 --- a/docs/src/developing/intro/transaction_fees.md +++ b/docs/src/developing/intro/transaction_fees.md @@ -92,4 +92,4 @@ Note that adding a `RequestUnits` compute budget instruction will take up 39 ext ### Calculate transaction fees with RPC API -In order to simplify fee calculation for developers, a new `getFeeForMessage` RPC API is planned to be released in v1.9 of the Solana protocol. This new method accepts a blockhash along with an encoded transaction message and will return the amount of fees that would be deducted if the transaction message is signed, sent, and processed by the cluster. Full documentation can be found on the "edge" version of the Solana docs here: [https://edge.docs.solana.com/developing/clients/jsonrpc-api#getfeeformessage](https://edge.docs.solana.com/developing/clients/jsonrpc-api#getfeeformessage) +In order to simplify fee calculation for developers, a new [`getFeeForMessage`](/api/http#getfeeformessage) RPC API is planned to be released in v1.9 of the Solana protocol. This new method accepts a blockhash along with an encoded transaction message and will return the amount of fees that would be deducted if the transaction message is signed, sent, and processed by the cluster. diff --git a/docs/src/developing/programming-model/accounts.md b/docs/src/developing/programming-model/accounts.md index 9fda255643c105..90227b1b62c3c2 100644 --- a/docs/src/developing/programming-model/accounts.md +++ b/docs/src/developing/programming-model/accounts.md @@ -148,10 +148,12 @@ that would reduce the balance to below the minimum amount will fail. Program executable accounts are required by the runtime to be rent-exempt to avoid being purged. -Note: Use the [`getMinimumBalanceForRentExemption` RPC -endpoint](developing/clients/jsonrpc-api.md#getminimumbalanceforrentexemption) to calculate the +:::info +Use the [`getMinimumBalanceForRentExemption`](../../api/http#getminimumbalanceforrentexemption) RPC +endpoint to calculate the minimum balance for a particular account size. The following calculation is illustrative only. +::: For example, a program executable with the size of 15,000 bytes requires a balance of 105,290,880 lamports (=~ 0.105 SOL) to be rent-exempt: diff --git a/docs/src/developing/test-validator.md b/docs/src/developing/test-validator.md index 72dea3ea4a0878..b835692a9a4668 100644 --- a/docs/src/developing/test-validator.md +++ b/docs/src/developing/test-validator.md @@ -140,7 +140,7 @@ JSON RPC URL: http://127.0.0.1:8899 ``` - The network address of the [Gossip](/validator/gossip#gossip-overview), - [Transaction Processing Unit](/validator/tpu) and [JSON RPC](clients/jsonrpc-api#json-rpc-api-reference) + [Transaction Processing Unit](/validator/tpu) and [JSON RPC](../api/http#json-rpc-api-reference) service, respectively ``` @@ -148,7 +148,7 @@ JSON RPC URL: http://127.0.0.1:8899 ``` - Session running time, current slot of the the three block - [commitment levels](clients/jsonrpc-api#configuring-state-commitment), + [commitment levels](../api/http#configuring-state-commitment), slot height of the last snapshot, transaction count, [voting authority](/running-validator/vote-accounts#vote-authority) balance @@ -166,4 +166,4 @@ Since this may not always be desired, especially when testing programs meant for ```bash solana-test-validator --deactivate-feature --deactivate-feature -``` \ No newline at end of file +``` diff --git a/docs/src/developing/transaction_confirmation.md b/docs/src/developing/transaction_confirmation.md new file mode 100644 index 00000000000000..9fa1c6ab0b5fa3 --- /dev/null +++ b/docs/src/developing/transaction_confirmation.md @@ -0,0 +1,199 @@ +--- +title: "Transaction Confirmation" +--- + +into to transaction confirmation? + +Problems relating to [transaction confirmation](./transaction_confirmation.md) are common with many newer developers while building applications. This article aims to boost the overall understanding of the confirmation mechanism used on the Solana blockchain, including some recommended best practices. + +## Brief background on transactions + +Let’s first make sure we’re all on the same page and thinking about the same things... + +### What is a transaction? + +Transactions consist of two components: a [message](./../terminology.md#message) and a [list of signatures](./../terminology.md#signature). The transaction message is where the magic happens and at a high level it consists of three components: + +- a **list of instructions** to invoke, +- a **list of accounts** to load, and +- a **“recent blockhash.”** + +In this article, we’re going to be focusing a lot on a transaction’s [recent blockhash](./../terminology.md#blockhash) because it plays a big role in transaction confirmation. + +### Transaction lifecycle refresher + +Below is a high level view of the lifecycle of a transaction. This article will touch on everything except steps 1 and 4. + +1. Create a list of instructions along with the list of accounts that instructions need to read and write +2. Fetch a recent blockhash and use it to prepare a transaction message +3. Simulate the transaction to ensure it behaves as expected +4. Prompt user to sign the prepared transaction message with their private key +5. Send the transaction to an RPC node which attempts to forward it to the current block producer +6. Hope that a block producer validates and commits the transaction into their produced block +7. Confirm the transaction has either been included in a block or detect when it has expired + +## What is a Blockhash? + +A [“blockhash”](./../terminology.md#blockhash) refers to the last Proof of History (PoH) hash for a [“slot”](./../terminology.md#slot) (description below). Since Solana uses PoH as a trusted clock, a transaction’s recent blockhash can be thought of as a **timestamp**. + +### Proof of History refresher + +Solana’s Proof of History mechanism uses a very long chain of recursive SHA-256 hashes to build a trusted clock. The “history” part of the name comes from the fact that block producers hash transaction id’s into the stream to record which transactions were processed in their block. + +[PoH hash calculation](https://github.com/solana-labs/solana/blob/9488a73f5252ad0d7ea830a0b456d9aa4bfbb7c1/entry/src/poh.rs#L82): `next_hash = hash(prev_hash, hash(transaction_ids))` + +PoH can be used as a trusted clock because each hash must be produced sequentially. Each produced block contains a blockhash and a list of hash checkpoints called “ticks” so that validators can verify the full chain of hashes in parallel and prove that some amount of time has actually passed. The stream of hashes can be broken up into the following time units: + +# Transaction Expiration + +By default, all Solana transactions will expire if not committed to a block in a certain amount of time. The **vast majority** of transaction confirmation issues are related to how RPC nodes and validators detect and handle **expired** transactions. A solid understanding of how transaction expiration works should help you diagnose the bulk of your transaction confirmation issues. + +## How does transaction expiration work? + +Each transaction includes a “recent blockhash” which is used as a PoH clock timestamp and expires when that blockhash is no longer “recent” enough. More concretely, Solana validators look up the corresponding slot number for each transaction’s blockhash that they wish to process in a block. If the validator [can’t find a slot number for the blockhash](https://github.com/solana-labs/solana/blob/9488a73f5252ad0d7ea830a0b456d9aa4bfbb7c1/runtime/src/bank.rs#L3687) or if the looked up slot number is more than 151 slots lower than the slot number of the block being processed, the transaction will be rejected. + +Slots are configured to last about [400ms](https://github.com/solana-labs/solana/blob/47b938e617b77eb3fc171f19aae62222503098d7/sdk/program/src/clock.rs#L12) but often fluctuate between 400ms and 600ms, so a given blockhash can only be used by transactions for about 60 to 90 seconds. + +Transaction has expired pseudocode: `currentBankSlot > slotForTxRecentBlockhash + 151` + +Transaction not expired pseudocode: `currentBankSlot - slotForTxRecentBlockhash < 152` + +### Example of transaction expiration + +Let’s walk through a quick example: + +1. A validator is producing a new block for slot #1000 +2. The validator receives a transaction with recent blockhash `1234...` from a user +3. The validator checks the `1234...` blockhash against the list of recent blockhashes leading up to its new block and discovers that it was the blockhash for slot #849 +4. Since slot #849 is exactly 151 slots lower than slot #1000, the transaction hasn’t expired yet and can still be processed! +5. But wait, before actually processing the transaction, the validator finished the block for slot #1000 and starts producing the block for slot #1001 (validators get to produce blocks for 4 consecutive slots). +6. The validator checks the same transaction again and finds that it’s now too old and drops it because it’s now 152 slots lower than the current slot :( + +## Why do transactions expire? + +There’s a very good reason for this actually, it’s to help validators avoid processing the same transaction twice. + +A naive brute force approach to prevent double processing could be to check every new transaction against the blockchain’s entire transaction history. But by having transactions expire after a short amount of time, validators only need to check if a new transaction is in a relatively small set of _recently_ processed transactions. + +### Other blockchains + +Solana’s approach of prevent double processing is quite different from other blockchains. For example, Ethereum tracks a counter (nonce) for each transaction sender and will only process transactions that use the next valid nonce. + +Ethereum’s approach is simple for validators to implement, but it can be problematic for users. Many people have encountered situations when their Ethereum transactions got stuck in a _pending_ state for a long time and all the later transactions, which used higher nonce values, were blocked from processing. + +### Advantages on Solana + +There are a few advantages to Solana’s approach: + +1. A single fee payer can submit multiple transactions at the same time that are allowed to be processed in any order. This might happen if you’re using multiple applications at the same time. +2. If a transaction doesn’t get committed to a block and expires, users can try again knowing that their previous transaction won’t ever be processed. + +By not using counters, the Solana wallet experience may be easier for users to understand because they can get to success, failure, or expiration states quickly and avoid annoying pending states. + +### Disadvantages on Solana + +Of course there are some disadvantages too: + +1. Validators have to actively track a set of all processed transaction id’s to prevent double processing. +2. If the expiration time period is too short, users might not be able to submit their transaction before it expires. + +These disadvantages highlight a tradeoff in how transaction expiration is configured. If the expiration time of a transaction is increased, validators need to use more memory to track more transactions. If expiration time is decreased, users don’t have enough time to submit their transaction. + +Currently, Solana clusters require that transactions use blockhashes that are no more than [151 slots](https://github.com/solana-labs/solana/blob/9488a73f5252ad0d7ea830a0b456d9aa4bfbb7c1/sdk/program/src/clock.rs#L65) old. + +> This [Github issue](https://github.com/solana-labs/solana/issues/23582) contains some calculations that estimate that mainnet-beta validators need about 150MB of memory to track transactions. +> This could be slimmed down in the future if necessary without decreasing expiration time as I’ve detailed in that issue. + +## Transaction confirmation tips + +As mentioned before, blockhashes expire after a time period of only 151 slots which can pass as quickly as **one minute** when slots are processed within the target time of 400ms. + +One minute is not a lot of time considering that a client needs to fetch a recent blockhash, wait for the user to sign, and finally hope that the broadcasted transaction reaches a leader that is willing to accept it. Let’s go through some tips to help avoid confirmation failures due to transaction expiration! + +### Fetch blockhashes with the appropriate commitment level + +Given the short expiration time frame, it’s imperative that clients help users create transactions with blockhash that is as recent as possible. + +When fetching blockhashes, the current recommended RPC API is called [`getLatestBlockhash`](/api/http#getlatestblockhash). By default, this API uses the `"finalized"` commitment level to return the most recently finalized block’s blockhash. However, you can override this behavior by [setting the `commitment` parameter](/api/http#configuring-state-commitment) to a different commitment level. + +**Recommendation** + +The `"confirmed"` commitment level should almost always be used for RPC requests because it’s usually only a few slots behind the `"processed"` commitment and has a very low chance of belonging to a dropped [fork](./../cluster/fork-generation.md). + +But feel free to consider the other options: + +- Choosing `"processed"` will let you fetch the most recent blockhash compared to other commitment levels and therefore gives you the most time to prepare and process a transaction. But due to the prevalence of forking in the Solana protocol, roughly 5% of blocks don’t end up being finalized by the cluster so there’s a real chance that your transaction uses a blockhash that belongs to a dropped fork. Transactions that use blockhashes for abandoned blocks won’t ever be considered recent by any blocks that are in the finalized blockchain. +- Using the default commitment level `"finalized"` will eliminate any risk that the blockhash you choose will belong to a dropped fork. The tradeoff is that there is typically at least a 32 slot difference between the most recent confirmed block and the most recent finalized block. This tradeoff is pretty severe and effectively reduces the expiration of your transactions by about 13 seconds but this could be even more during unstable cluster conditions. + +### Use an appropriate preflight commitment level + +If your transaction uses a blockhash that was fetched from one RPC node then you send, or simulate, that transaction with a different RPC node, you could run into issues due to one node lagging behind the other. + +When RPC nodes receive a `sendTransaction` request, they will attempt to determine the expiration block of your transaction using the most recent finalized block or with the block selected by the `preflightCommitment` parameter. A **VERY** common issue is that a received transaction’s blockhash was produced after the block used to calculate the expiration for that transaction. If an RPC node can’t determine when your transaction expires, it will only forward your transaction **one time** and then will **drop** the transaction. + +Similarly, when RPC nodes receive a `simulateTransaction` request, they will simulate your transaction using the most recent finalized block or with the block selected by the `preflightCommitment` parameter. If the block chosen for simulation is older than the block used for your transaction’s blockhash, the simulation will fail with the dreaded “blockhash not found” error. + +**Recommendation** + +Even if you use `skipPreflight`, **ALWAYS** set the `preflightCommitment` parameter to the same commitment level used to fetch your transaction’s blockhash for both `sendTransaction` and `simulateTransaction` requests. + +### Be wary of lagging RPC nodes when sending transactions + +When your application uses an RPC pool service or when the RPC endpoint differs between creating a transaction and sending a transaction, you need to be wary of situations where one RPC node is lagging behind the other. For example, if you fetch a transaction blockhash from one RPC node then you send that transaction to a second RPC node for forwarding or simulation, the second RPC node might be lagging behind the first. + +**Recommendation** + +For `sendTransaction` requests, clients should keep resending a transaction to a RPC node on a frequent interval so that if an RPC node is slightly lagging behind the cluster, it will eventually catch up and detect your transaction’s expiration properly. + +For `simulateTransaction` requests, clients should use the [`replaceRecentBlockhash`](/api/http#simulatetransaction) parameter to tell the RPC node to replace the simulated transaction’s blockhash with a blockhash that will always be valid for simulation. + +### Avoid reusing stale blockhashes + +Even if your application has fetched a very recent blockhash, be sure that you’re not reusing that blockhash in transactions for too long. The ideal scenario is that a recent blockhash is fetched right before a user signs their transaction. + +**Recommendation for applications** + +Poll for new recent blockhashes on a frequent basis to ensure that whenever a user triggers an action that creates a transaction, your application already has a fresh blockhash that’s ready to go. + +**Recommendation for wallets** + +Poll for new recent blockhashes on a frequent basis and replace a transaction’s recent blockhash right before they sign the transaction to ensure the blockhash is as fresh as possible. + +### Use healthy RPC nodes when fetching blockhashes + +By fetching the latest blockhash with the `"confirmed"` commitment level from an RPC node, it’s going to respond with the blockhash for the latest confirmed block that it’s aware of. Solana’s block propagation protocol prioritizes sending blocks to staked nodes so RPC nodes naturally lag about a block behind the rest of the cluster. They also have to do more work to handle application requests and can lag a lot more under heavy user traffic. + +Lagging RPC nodes can therefore respond to blockhash requests with blockhashes that were confirmed by the cluster quite awhile ago. By default, a lagging RPC node detects that it is more than 150 slots behind the cluster will stop responding to requests, but just before hitting that threshold they can still return a blockhash that is just about to expire. + +**Recommendation** + +Monitor the health of your RPC nodes to ensure that they have an up-to-date view of the cluster state with one of the following methods: + +1. Fetch your RPC node’s highest processed slot by using the [`getSlot`](/api/http#getslot) RPC API with the `"processed"` commitment level and then call the [`getMaxShredInsertSlot](/api/http#getmaxshredinsertslot) RPC API to get the highest slot that your RPC node has received a “shred” of a block for. If the difference between these responses is very large, the cluster is producing blocks far ahead of what the RPC node has processed. +2. Call the `getLatestBlockhash` RPC API with the `"confirmed"` commitment level on a few different RPC API nodes and use the blockhash from the node that returns the highest slot for its [context slot](/api/http#rpcresponse-structure). + +### Wait long enough for expiration + +**Recommendation** + +When calling [`getLatestBlockhash`](/api/http#getlatestblockhash) RPC API to get a recent blockhash for your transaction, take note of the `"lastValidBlockHeight"` in the response. + +Then, poll the [`getBlockHeight`](/api/http#getblockheight) RPC API with the “confirmed” commitment level until it returns a block height greater than the previously returned last valid block height. + +### Consider using “durable” transactions + +Sometimes transaction expiration issues are really hard to avoid (e.g. offline signing, cluster instability). If the previous tips are still not sufficient for your use-case, you can switch to using durable transactions (they just require a bit of setup). + +To start using durable transactions, a user first needs to submit a transaction that [invokes instructions that create a special on-chain “nonce” account](https://docs.rs/solana-program/latest/solana_program/system_instruction/fn.create_nonce_account.html) and stores a “durable blockhash” inside of it. At any point in the future (as long as the nonce account hasn’t been used yet), the user can create a durable transaction by following these 2 rules: + +1. The instruction list must start with an [“advance nonce” system instruction](https://docs.rs/solana-program/latest/solana_program/system_instruction/fn.advance_nonce_account.html) which loads their on-chain nonce account +2. The transaction’s blockhash must be equal to the durable blockhash stored by the on-chain nonce account + +Here’s how these transactions are processed by the Solana runtime: + +1. If the transaction’s blockhash is no longer “recent”, the runtime checks if the transaction’s instruction list begins with an “advance nonce” system instruction +2. If so, it then loads the nonce account specified by the “advance nonce” instruction +3. Then it checks that the stored durable blockhash matches the transaction’s blockhash +4. Lastly it makes sure to advance the nonce account’s stored blockhash to the latest recent blockhash to ensure that the same transaction can never be processed again + +For more details about how these durable transactions work, you can read the [original proposal](./../implemented-proposals/durable-tx-nonces.md) and [check out an example](./clients/javascript-reference#nonceaccount) in the Solana docs. diff --git a/docs/src/developing/versioned-transactions.md b/docs/src/developing/versioned-transactions.md index d283a5530afd69..eaf7902ae34553 100644 --- a/docs/src/developing/versioned-transactions.md +++ b/docs/src/developing/versioned-transactions.md @@ -16,7 +16,7 @@ The Solana runtime supports two transaction versions: ## Max supported transaction version -All RPC requests that return a transaction **_should_** specify the highest version of transactions they will support in their application using the `maxSupportedTransactionVersion` option. Including [`getBlock`](./clients/jsonrpc-api.md#getblock) and [`getTransaction`](./clients/jsonrpc-api.md#gettransaction), +All RPC requests that return a transaction **_should_** specify the highest version of transactions they will support in their application using the `maxSupportedTransactionVersion` option, including [`getBlock`](../api/http#getblock) and [`getTransaction`](../api/http#gettransaction). An RPC request will fail if a [Versioned Transaction](./versioned-transactions.md) is returned that is higher than the set `maxSupportedTransactionVersion`. (i.e. if a version `0` transaction is returned when `legacy` is selected) @@ -77,7 +77,7 @@ Below is an example of how to create a Versioned Transaction, using the `@solana Firstly, import the web3.js library and create a `connection` to your desired cluster. -We then define the recent `blockhash` and `minRent` we will need for our transaction and the account. +We then define the recent `blockhash` and `minRent` we will need for our transaction and the account: ```js const web3 = require("@solana/web3.js"); @@ -131,7 +131,7 @@ You can sign the transaction by either: > NOTE: > After calling the `transaction.sign()` method, all the previous transaction `signatures` will be fully replaced by new signatures created from the provided in `Signers`. -After your `VersionedTransaction` has been signed by all required accounts, you can send it to the cluster and `await` the response. +After your `VersionedTransaction` has been signed by all required accounts, you can send it to the cluster and `await` the response: ```js // send our v0 transaction to the cluster @@ -146,4 +146,4 @@ console.log(`https://explorer.solana.com/tx/${txid}?cluster=devnet`); - using [Versioned Transactions for Address Lookup Tables](./lookup-tables.md#how-to-create-an-address-lookup-table) - view an [example of a v0 transaction](https://explorer.solana.com/tx/3jpoANiFeVGisWRY5UP648xRXs3iQasCHABPWRWnoEjeA93nc79WrnGgpgazjq4K9m8g2NJoyKoWBV1Kx5VmtwHQ/?cluster=devnet) on Solana Explorer -- read the [accepted proposal](./../proposals/transactions-v2.md) for Versioned Transaction and Address Lookup Tables +- read the [accepted proposal](./../proposals/versioned-transactions.md) for Versioned Transaction and Address Lookup Tables diff --git a/docs/src/getstarted/hello-world.md b/docs/src/getstarted/hello-world.md index 4aa696f62b3726..78d0715225d77d 100644 --- a/docs/src/getstarted/hello-world.md +++ b/docs/src/getstarted/hello-world.md @@ -44,8 +44,9 @@ Next, import the project into your local workspace by clicking the "**Import**" Normally with [local development](./local.md), you will need to create a file system wallet for use with the Solana CLI. But with the Solana Playground, you only need to click a few buttons to create a browser based wallet. -> **Note:** -> Your _Playground Wallet_ will be saved in your browser's local storage. Clearing your browser cache will remove your saved wallet. When creating a new wallet, you will have the option to save a local copy of your wallet's keypair file. +:::caution +Your _Playground Wallet_ will be saved in your browser's local storage. Clearing your browser cache will remove your saved wallet. When creating a new wallet, you will have the option to save a local copy of your wallet's keypair file. +::: Click on the red status indicator button at the bottom left of the screen, (optionally) save your wallet's keypair file to your computer for backup, then click "**Continue**". @@ -103,8 +104,9 @@ If you look at the Playground's terminal, you should see your Solana program beg ![Viewing a successful build of your Rust based program](/img/quickstarts/solana-get-started-successful-build.png) -> Note: -> You may receive _warning_ when your program is compiled due to unused variables. Don't worry, these warning will not affect your build. They are due to our very simple program not using all the variables we declared in the `process_instruction` function. +:::caution +You may receive _warning_ when your program is compiled due to unused variables. Don't worry, these warning will not affect your build. They are due to our very simple program not using all the variables we declared in the `process_instruction` function. +::: ### Deploy your program @@ -137,8 +139,9 @@ Once you have successfully deployed a Solana program to the blockchain, you will Like most developers creating dApps and websites, we will interact with our on chain program using JavaScript. Specifically, will use the open source [NPM package](https://www.npmjs.com/package/@solana/web3.js) `@solana/web3.js` to aid in our client application. -> **NOTE:** -> This web3.js package is an abstraction layer on top of the [JSON RPC API](./../developing/clients/jsonrpc-api.md) that reduced the need for rewriting common boilerplate, helping to simplify your client side application code. +:::info +This web3.js package is an abstraction layer on top of the [JSON RPC API](/api) that reduced the need for rewriting common boilerplate, helping to simplify your client side application code. +::: ### Initialize client @@ -154,8 +157,9 @@ We have created `client` folder and a default `client.ts`. This is where we will In playground, there are many utilities that are globally available for us to use without installing or setting up anything. Most important ones for our `hello world` program are `web3` for `@solana/web3.js` and `pg` for Solana Playground utilities. -> Note: -> You can go over all of the available globals by pressing `CTRL+SPACE` (or `CMD+SPACE` on macOS) inside the editor. +:::info +You can go over all of the available globals by pressing `CTRL+SPACE` (or `CMD+SPACE` on macOS) inside the editor. +::: ### Call the program @@ -191,8 +195,9 @@ const txHash = await web3.sendAndConfirmTransaction( console.log("Transaction sent with hash:", txHash); ``` -> Note: -> The first signer in the signers array is the transaction fee payer by default. We are signing with our keypair `pg.wallet.keypair`. +:::info +The first signer in the signers array is the transaction fee payer by default. We are signing with our keypair `pg.wallet.keypair`. +::: ### Run the application diff --git a/docs/src/implemented-proposals/rpc-transaction-history.md b/docs/src/implemented-proposals/rpc-transaction-history.md index 4853d19e6f2290..c8eb878eae45ce 100644 --- a/docs/src/implemented-proposals/rpc-transaction-history.md +++ b/docs/src/implemented-proposals/rpc-transaction-history.md @@ -10,13 +10,13 @@ fall back to the external data store. The affected RPC endpoints are: -- [getFirstAvailableBlock](developing/clients/jsonrpc-api.md#getfirstavailableblock) -- [getConfirmedBlock](developing/clients/jsonrpc-api.md#getconfirmedblock) -- [getConfirmedBlocks](developing/clients/jsonrpc-api.md#getconfirmedblocks) -- [getConfirmedSignaturesForAddress](developing/clients/jsonrpc-api.md#getconfirmedsignaturesforaddress) -- [getConfirmedTransaction](developing/clients/jsonrpc-api.md#getconfirmedtransaction) -- [getSignatureStatuses](developing/clients/jsonrpc-api.md#getsignaturestatuses) -- [getBlockTime](developing/clients/jsonrpc-api.md#getblocktime) +- [getFirstAvailableBlock](../api/http#getfirstavailableblock) +- [getConfirmedBlock](../api/http#getconfirmedblock) +- [getConfirmedBlocks](../api/http#getconfirmedblocks) +- [getConfirmedSignaturesForAddress](../api/http#getconfirmedsignaturesforaddress) +- [getConfirmedTransaction](../api/http#getconfirmedtransaction) +- [getSignatureStatuses](../api/http#getsignaturestatuses) +- [getBlockTime](../api/http#getblocktime) Some system design constraints: diff --git a/docs/src/implemented-proposals/transaction-fees.md b/docs/src/implemented-proposals/transaction-fees.md index 02245647b594c0..042db21a50af76 100644 --- a/docs/src/implemented-proposals/transaction-fees.md +++ b/docs/src/implemented-proposals/transaction-fees.md @@ -6,14 +6,14 @@ title: Deterministic Transaction Fees Before sending a transaction to the cluster, a client may query the network to determine what the transaction's fee will be via the rpc request -[getFeeForMessage](/developing/clients/jsonrpc-api#getfeeformessage). +[getFeeForMessage](../api/http#getfeeformessage). ## Fee Parameters The fee is based on the number of signatures in the transaction, the more signatures a transaction contains, the higher the fee. In addition, a transaction can specify an additional fee that determines how the transaction is -relatively prioritized against others. A transaction's prioritization fee is +relatively prioritized against others. A transaction's prioritization fee is calculated by multiplying the number of compute units by the compute unit price (measured in micro-lamports) set by the transaction via compute budget instructions. diff --git a/docs/src/integrations/exchange.md b/docs/src/integrations/exchange.md index 7d4e741022da3f..02306f4332d6d4 100644 --- a/docs/src/integrations/exchange.md +++ b/docs/src/integrations/exchange.md @@ -156,7 +156,7 @@ We recommend using a unique deposit account for each of your users. Solana accounts must be made rent-exempt by containing 2-years worth of [rent](developing/programming-model/accounts.md#rent) in SOL. In order to find the minimum rent-exempt balance for your deposit accounts, query the -[`getMinimumBalanceForRentExemption` endpoint](developing/clients/jsonrpc-api.md#getminimumbalanceforrentexemption): +[`getMinimumBalanceForRentExemption` endpoint](../api/http#getminimumbalanceforrentexemption): ```bash curl localhost:8899 -X POST -H "Content-Type: application/json" -d '{ @@ -218,7 +218,7 @@ To track all the deposit accounts for your exchange, poll for each confirmed block and inspect for addresses of interest, using the JSON-RPC service of your Solana API node. -- To identify which blocks are available, send a [`getBlocks` request](developing/clients/jsonrpc-api.md#getblocks), +- To identify which blocks are available, send a [`getBlocks`](../api/http#getblocks) request, passing the last block you have already processed as the start-slot parameter: ```bash @@ -235,7 +235,7 @@ curl https://api.devnet.solana.com -X POST -H "Content-Type: application/json" - Not every slot produces a block, so there may be gaps in the sequence of integers. -- For each block, request its contents with a [`getBlock` request](developing/clients/jsonrpc-api.md#getblock): +- For each block, request its contents with a [`getBlock`](../api/http#getblock) request: ### Block Fetching Tips @@ -352,7 +352,7 @@ generally _not_ a viable method for tracking all your deposit addresses over all slots, but may be useful for examining a few accounts for a specific period of time. -- Send a [`getSignaturesForAddress`](developing/clients/jsonrpc-api.md#getsignaturesforaddress) +- Send a [`getSignaturesForAddress`](../api/http#getsignaturesforaddress) request to the api node: ```bash @@ -402,7 +402,7 @@ curl localhost:8899 -X POST -H "Content-Type: application/json" -d '{ ``` - For each signature returned, get the transaction details by sending a - [`getTransaction`](developing/clients/jsonrpc-api.md#gettransaction) request: + [`getTransaction`](../api/http#gettransaction) request: ```bash curl https://api.devnet.solana.com -X POST -H 'Content-Type: application/json' -d '{ @@ -544,8 +544,7 @@ before retrying a withdrawal transfer that does not appear to have been confirmed or finalized by the cluster. Otherwise, you risk a double spend. See more on [blockhash expiration](#blockhash-expiration) below. -First, get a recent blockhash using the [`getFees` endpoint](developing/clients/jsonrpc-api.md#getfees) -or the CLI command: +First, get a recent blockhash using the [`getFees`](../api/http#getfees) endpoint or the CLI command: ```bash solana fees --url http://localhost:8899 @@ -559,12 +558,12 @@ solana transfer --no-wait --allow-unfunded-recipient --b ``` You can also build, sign, and serialize the transaction manually, and fire it off to -the cluster using the JSON-RPC [`sendTransaction` endpoint](developing/clients/jsonrpc-api.md#sendtransaction). +the cluster using the JSON-RPC [`sendTransaction`](../api/http#sendtransaction) endpoint. #### Transaction Confirmations & Finality Get the status of a batch of transactions using the -[`getSignatureStatuses` JSON-RPC endpoint](developing/clients/jsonrpc-api.md#getsignaturestatuses). +[`getSignatureStatuses`](../api/http#getsignaturestatuses) JSON-RPC endpoint. The `confirmations` field reports how many [confirmed blocks](../terminology.md#confirmed-block) have elapsed since the transaction was processed. If `confirmations: null`, it is [finalized](../terminology.md#finality). @@ -615,7 +614,7 @@ curl localhost:8899 -X POST -H "Content-Type: application/json" -d '{ #### Blockhash Expiration You can check whether a particular blockhash is still valid by sending a -[`getFeeCalculatorForBlockhash`](developing/clients/jsonrpc-api.md#getfeecalculatorforblockhash) +[`getFeeCalculatorForBlockhash`](../api/http#getfeecalculatorforblockhash) request with the blockhash as a parameter. If the response value is `null`, the blockhash is expired, and the withdrawal transaction using that blockhash should never succeed. diff --git a/docs/src/integrations/retrying-transactions.md b/docs/src/integrations/retrying-transactions.md index 66c59c205cdaf4..c2d7ff24be2292 100644 --- a/docs/src/integrations/retrying-transactions.md +++ b/docs/src/integrations/retrying-transactions.md @@ -38,7 +38,7 @@ so that they can be processed into a block. There are two main ways in which a transaction can be sent to leaders: 1. By proxy via an RPC server and the - [sendTransaction](../developing/clients/jsonrpc-api#sendtransaction) + [sendTransaction](../api/http#sendtransaction) JSON-RPC method 2. Directly to leaders via a [TPU Client](https://docs.rs/solana-client/1.7.3/solana_client/tpu_client/index.html) @@ -138,7 +138,7 @@ is queried from the advanced part of the pool (Backend A). When the transaction is submitted to the lagging part of the pool (Backend B), the nodes will not recognize the advanced blockhash and will drop the transaction. This can be detected upon transaction submission if developers enable -[preflight checks](../developing/clients/jsonrpc-api#sendtransaction) +[preflight checks](../api/http#sendtransaction) on `sendTransaction`. ![Dropped via RPC Pool](../../static/img/rt-dropped-via-rpc-pool.png) @@ -190,7 +190,7 @@ the transaction will be processed or finalized by the cluster. - `skipPreflight`: `boolean` - if true, skip the preflight transaction checks (default: false) - (optional) `preflightCommitment`: `string` - - [Commitment](../developing/clients/jsonrpc-api#configuring-state-commitment) + [Commitment](../api/http#configuring-state-commitment) level to use for preflight simulations against the bank slot (default: "finalized"). - (optional) `encoding`: `string` - Encoding used for the transaction data. @@ -204,7 +204,7 @@ Response - `transaction id`: `string` - First transaction signature embedded in the transaction, as base-58 encoded string. This transaction id can be used with - [getSignatureStatuses](../developing/clients/jsonrpc-api#getsignaturestatuses) + [`getSignatureStatuses`](../api/http#getsignaturestatuses) to poll for status updates. ::: @@ -219,9 +219,9 @@ developers to manually control the retry process A common pattern for manually retrying transactions involves temporarily storing the `lastValidBlockHeight` that comes from -[getLatestBlockhash](../developing/clients/jsonrpc-api#getlatestblockhash). +[getLatestBlockhash](../api/http#getlatestblockhash). Once stashed, an application can then -[poll the cluster’s blockheight](../developing/clients/jsonrpc-api#getblockheight) +[poll the cluster’s blockheight](../api/http#getblockheight) and manually retry the transaction at an appropriate interval. In times of network congestion, it’s advantageous to set `maxRetries` to 0 and manually rebroadcast via a custom algorithm. While some applications may employ an @@ -289,7 +289,7 @@ const sleep = async (ms: number) => { When polling via `getLatestBlockhash`, applications should specify their intended -[commitment](../developing/clients/jsonrpc-api#configuring-state-commitment) +[commitment](../api/http#configuring-state-commitment) level. By setting its commitment to `confirmed` (voted on) or `finalized` (~30 blocks after `confirmed`), an application can avoid polling a blockhash from a minority fork. @@ -331,6 +331,6 @@ In Solana, a dropped transaction can be safely discarded once the blockhash it references is older than the `lastValidBlockHeight` received from `getLatestBlockhash`. Developers should keep track of this `lastValidBlockHeight` by querying -[`getEpochInfo`](../developing/clients/jsonrpc-api#getepochinfo) +[`getEpochInfo`](../api/http#getepochinfo) and comparing with `blockHeight` in the response. Once a blockhash is invalidated, clients may re-sign with a newly-queried blockhash. diff --git a/docs/src/pages/CodeDocBlock.module.css b/docs/src/pages/CodeDocBlock.module.css new file mode 100644 index 00000000000000..7cffc5625bd7a0 --- /dev/null +++ b/docs/src/pages/CodeDocBlock.module.css @@ -0,0 +1,80 @@ +/* stylelint-disable docusaurus/copyright-header */ + +.DocBlock { + border-top: 1px solid #414141; + padding-top: 3rem; + /* display: flex; */ + /* justify-content: space-between; */ + margin-top: 5rem; + /* width: 100%; */ + /* align-items: center; */ +} + +.DocSideBySide { + margin-top: 2rem; +} + +.CodeParams { + display: block; + width: 100%; +} + +.CodeSnippets { + display: block; + width: 100%; +} + +@media screen and (min-width: 768px) { + .DocSideBySide { + display: flex; + width: 100%; + } + .CodeParams { + margin-right: 3rem; + width: 50%; + } + .CodeSnippets { + width: 50%; + } +} + +.Parameter { + padding: 1em 0em; + margin-bottom: 1em; + border-top: 1px solid #414141; + /* // border-bottom: 1px solid #414141; */ +} + +.ParameterName { + font-weight: 700; +} + +.ParameterHeader { + font-family: mono; + padding: 0.1em 0em; +} + +.Field { + /* // padding: 1em 0em; */ + margin: 1em 0em 1em 1em; + /* // border-top: 1px solid #414141; */ + /* // border-bottom: 1px solid #414141; */ +} +.Field section { + padding: 0em 1em; +} + +.FlagItem { + margin: 0 0.5rem; + color: #767676; + font-weight: 600; +} + +.Heading { + font-size: 1.24rem; + font-weight: 700; +} +.SubHeading { + /* font-size: 1.24rem; */ + font-weight: 600; +} diff --git a/docs/src/pages/api.js b/docs/src/pages/api.js new file mode 100644 index 00000000000000..6252d21df5027e --- /dev/null +++ b/docs/src/pages/api.js @@ -0,0 +1,82 @@ +import React from "react"; +import Link from "@docusaurus/Link"; +import styles from "./styles.module.css"; +import Card from "../../components/Card"; +import CardLayout from "../../layouts/CardLayout"; + +function APIPage() { + return ( + +
    +
    +
    +

    JSON RPC API

    + +
    +

    + Interact with Solana nodes directly with the JSON RPC API via + the HTTP and Websocket methods. +

    + + + Explore the API + +
    +
    + +
    +

    Explore the JSON RPC Methods

    + +
    + + + + + +
    +
    +
    +
    +
    + ); +} + +export default APIPage; diff --git a/docs/src/pages/developers.js b/docs/src/pages/developers.js index 344ad73a55ebda..fb612bb0d0b5dd 100644 --- a/docs/src/pages/developers.js +++ b/docs/src/pages/developers.js @@ -136,7 +136,7 @@ function Developers() { /> **Learn more:** compute units and the [Compute Budget](./developing/programming-model/runtime#compute-budget) in the Runtime and [requesting a fee estimate](./developing/clients/jsonrpc-api.md#getfeeformessage) from the RPC. +> **Learn more:** compute units and the [Compute Budget](./developing/programming-model/runtime#compute-budget) in the Runtime and [requesting a fee estimate](../api/http#getfeeformessage) from the RPC. ## Prioritization fee