[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
This commit is contained in:
Nick Frostbutter 2023-01-26 18:14:47 -05:00 committed by GitHub
parent 23531fc659
commit 9b270020f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
109 changed files with 9195 additions and 5589 deletions

View File

@ -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 <section className={styles.DocBlock}>{children}</section>;
}
export function DocSideBySide({ children }) {
return <section className={styles.DocSideBySide}>{children}</section>;
}
export function CodeParams({ children }) {
return <section className={styles.CodeParams}>{children}</section>;
}
export function CodeSnippets({ children }) {
return (
<section className={styles.CodeSnippets}>
{/* <p className={styles.Heading}>Code Sample:</p> */}
{children}
</section>
);
}
/*
Display a single Parameter
*/
export function Parameter(props) {
const {
name = null,
type = null,
required = null,
optional = null,
children,
} = computeHeader(props);
return (
<section className={styles.Parameter}>
<p className={styles.ParameterHeader}>
{name && name} {type && type} {required && required}{" "}
{optional && optional}
</p>
{children}
</section>
);
}
/*
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 (
<section className={styles.Field}>
<p className={styles.ParameterHeader}>
{name && name} {type && type} {required && required}{" "}
{optional && optional}
{defaultValue && defaultValue}
</p>
<section>
{values && values}
{children}
</section>
</section>
);
}
/*
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) => (
<code style={{ marginRight: ".5em" }} key={value}>
{value}
</code>
));
}
return (
<p style={{}}>
<span className={styles.SubHeading}>Values:</span>&nbsp;{values}
</p>
);
}
/*
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 = <span className={styles.ParameterName}>{name}</span>;
if (href) name = <Link href={href}>{name}</Link>;
}
// format the Parameter's type
if (type) type = <code>{type}</code>;
// format the Parameter's values
if (values && Array.isArray(values)) {
values = values.map((value) => (
<code style={{ marginRight: ".5em" }}>{value}</code>
));
}
// format the `defaultValue` flag
if (defaultValue) {
defaultValue = (
<span className={styles.FlagItem}>
Default: <code>{defaultValue.toString()}</code>
</span>
);
}
// format the `required` flag
if (required) {
required = <span className={styles.FlagItem}>required</span>;
}
// format the `optional` flag
else if (optional) {
optional = <span className={styles.FlagItem}>optional</span>;
}
return {
name,
type,
href,
values,
required,
defaultValue,
optional,
children,
};
}

View File

@ -38,7 +38,8 @@ cat > "$CONFIG_FILE" <<EOF
{ "source": "/apps/drones", "destination": "/developing/on-chain-programs/examples" },
{ "source": "/apps/hello-world", "destination": "/developing/on-chain-programs/examples" },
{ "source": "/apps/javascript-api", "destination": "/developing/clients/javascript-api" },
{ "source": "/apps/jsonrpc-api", "destination": "/developing/clients/jsonrpc-api" },
{ "source": "/apps/jsonrpc-api", "destination": "/api" },
{ "source": "/developing/clients/jsonrpc-api", "destination": "/api" },
{ "source": "/apps/programming-faq", "destination": "/developing/on-chain-programs/faq" },
{ "source": "/apps/rent", "destination": "/developing/programming-model/accounts#rent" },
{ "source": "/apps/sysvars", "destination": "/developing/runtime-facilities/sysvars" },

View File

@ -1,4 +1,6 @@
module.exports = {
// load the API specific sidebars file
...require("./sidebars/api.js"),
introductionSidebar: [
{
type: "category",
@ -195,8 +197,8 @@ module.exports = {
label: "Clients",
items: [
{
type: "doc",
id: "developing/clients/jsonrpc-api",
type: "link",
href: "/api",
label: "JSON RPC API",
},
{

492
docs/sidebars/api.js Normal file
View File

@ -0,0 +1,492 @@
module.exports = {
apiSidebar: [
{
type: "link",
href: "/api",
label: "JSON RPC API",
},
{
type: "doc",
id: "api/http",
label: "HTTP Methods",
},
{
type: "doc",
id: "api/websocket",
label: "Websocket Methods",
},
],
apiHttpMethodsSidebar: [
{
type: "link",
href: "/api",
label: "JSON RPC API",
},
{
type: "doc",
id: "api/websocket",
label: "Websocket Methods",
},
{
type: "category",
link: { type: "doc", id: "api/http" },
label: "HTTP Methods",
collapsed: false,
items: [
{
type: "link",
href: "#getaccountinfo",
label: "getAccountInfo",
},
{
type: "link",
href: "#getbalance",
label: "getBalance",
},
{
type: "link",
href: "#getblockheight",
label: "getBlockHeight",
},
{
type: "link",
href: "#getblock",
label: "getBlock",
},
{
type: "link",
href: "#getblockproduction",
label: "getBlockProduction",
},
{
type: "link",
href: "#getblockcommitment",
label: "getBlockCommitment",
},
{
type: "link",
href: "#getblocks",
label: "getBlocks",
},
{
type: "link",
href: "#getblockswithlimit",
label: "getBlocksWithLimit",
},
{
type: "link",
href: "#getblocktime",
label: "getBlockTime",
},
{
type: "link",
href: "#getclusternodes",
label: "getClusterNodes",
},
{
type: "link",
href: "#getepochinfo",
label: "getEpochInfo",
},
{
type: "link",
href: "#getepochschedule",
label: "getEpochSchedule",
},
{
type: "link",
href: "#getfeeformessage",
label: "getFeeForMessage",
},
{
type: "link",
href: "#getfirstavailableblock",
label: "getFirstAvailableBlock",
},
{
type: "link",
href: "#getgenesishash",
label: "getGenesisHash",
},
{
type: "link",
href: "#gethealth",
label: "getHealth",
},
{
type: "link",
href: "#gethighestsnapshotslot",
label: "getHighestSnapshotSlot",
},
{
type: "link",
href: "#getidentity",
label: "getIdentity",
},
{
type: "link",
href: "#getinflationgovernor",
label: "getInflationGovernor",
},
{
type: "link",
href: "#getinflationrate",
label: "getInflationRate",
},
{
type: "link",
href: "#getinflationreward",
label: "getInflationReward",
},
{
type: "link",
href: "#getlargestaccounts",
label: "getLargestAccounts",
},
{
type: "link",
href: "#getlatestblockhash",
label: "getLatestBlockhash",
},
{
type: "link",
href: "#getleaderschedule",
label: "getLeaderSchedule",
},
{
type: "link",
href: "#getmaxretransmitslot",
label: "getMaxRetransmitSlot",
},
{
type: "link",
href: "#getmaxshredinsertslot",
label: "getMaxShredInsertSlot",
},
{
type: "link",
href: "#getminimumbalanceforrentexemption",
label: "getMinimumBalanceForRentExemption",
},
{
type: "link",
href: "#getmultipleaccounts",
label: "getMultipleAccounts",
},
{
type: "link",
href: "#getprogramaccounts",
label: "getProgramAccounts",
},
{
type: "link",
href: "#getrecentperformancesamples",
label: "getRecentPerformanceSamples",
},
{
type: "link",
href: "#getrecentprioritizationfees",
label: "getRecentPrioritizationFees",
},
{
type: "link",
href: "#getsignaturesforaddress",
label: "getSignaturesForAddress",
},
{
type: "link",
href: "#getsignaturestatuses",
label: "getSignatureStatuses",
},
{
type: "link",
href: "#getslot",
label: "getSlot",
},
{
type: "link",
href: "#getslotleader",
label: "getSlotLeader",
},
{
type: "link",
href: "#getslotleaders",
label: "getSlotLeaders",
},
{
type: "link",
href: "#getstakeactivation",
label: "getStakeActivation",
},
{
type: "link",
href: "#getstakeminimumdelegation",
label: "getStakeMinimumDelegation",
},
{
type: "link",
href: "#getsupply",
label: "getSupply",
},
{
type: "link",
href: "#gettokenaccountbalance",
label: "getTokenAccountBalance",
},
{
type: "link",
href: "#gettokenaccountsbydelegate",
label: "getTokenAccountsByDelegate",
},
{
type: "link",
href: "#gettokenaccountsbyowner",
label: "getTokenAccountsByOwner",
},
{
type: "link",
href: "#gettokenlargestaccounts",
label: "getTokenLargestAccounts",
},
{
type: "link",
href: "#gettokensupply",
label: "getTokenSupply",
},
{
type: "link",
href: "#gettransaction",
label: "getTransaction",
},
{
type: "link",
href: "#gettransactioncount",
label: "getTransactionCount",
},
{
type: "link",
href: "#getversion",
label: "getVersion",
},
{
type: "link",
href: "#getvoteaccounts",
label: "getVoteAccounts",
},
{
type: "link",
href: "#isblockhashvalid",
label: "isBlockhashValid",
},
{
type: "link",
href: "#minimumledgerslot",
label: "minimumLedgerSlot",
},
{
type: "link",
href: "#requestairdrop",
label: "requestAirdrop",
},
{
type: "link",
href: "#sendtransaction",
label: "sendTransaction",
},
{
type: "link",
href: "#simulatetransaction",
label: "simulateTransaction",
},
],
},
// {
// type: "category",
// label: "Unstable Methods",
// collapsed: true,
// items: [
// {
// type: "link",
// href: "#blocksubscribe",
// label: "blockSubscribe",
// },
// ],
// },
{
type: "category",
label: "Deprecated Methods",
collapsed: true,
items: [
{
type: "link",
href: "#getconfirmedblock",
label: "getConfirmedBlock",
},
{
type: "link",
href: "#getconfirmedblocks",
label: "getConfirmedBlocks",
},
{
type: "link",
href: "#getconfirmedblockswithlimit",
label: "getConfirmedBlocksWithLimit",
},
{
type: "link",
href: "#getconfirmedsignaturesforaddress2",
label: "getConfirmedSignaturesForAddress2",
},
{
type: "link",
href: "#getconfirmedtransaction",
label: "getConfirmedTransaction",
},
{
type: "link",
href: "#getfeecalculatorforblockhash",
label: "getFeeCalculatorForBlockhash",
},
{
type: "link",
href: "#getfeerategovernor",
label: "getFeeRateGovernor",
},
{
type: "link",
href: "#getfees",
label: "getFees",
},
{
type: "link",
href: "#getrecentblockhash",
label: "getRecentBlockhash",
},
{
type: "link",
href: "#getsnapshotslot",
label: "getSnapshotSlot",
},
],
},
],
apiWebsocketMethodsSidebar: [
{
type: "link",
href: "/api",
label: "JSON RPC API",
},
{
type: "doc",
id: "api/http",
label: "HTTP Methods",
},
{
type: "category",
link: { type: "doc", id: "api/websocket" },
label: "Websocket Methods",
collapsed: false,
items: [
{
type: "link",
href: "#accountsubscribe",
label: "accountSubscribe",
},
{
type: "link",
href: "#accountunsubscribe",
label: "accountUnsubscribe",
},
{
type: "link",
href: "#logssubscribe",
label: "logsSubscribe",
},
{
type: "link",
href: "#logsunsubscribe",
label: "logsUnsubscribe",
},
{
type: "link",
href: "#programsubscribe",
label: "programSubscribe",
},
{
type: "link",
href: "#programunsubscribe",
label: "programUnsubscribe",
},
{
type: "link",
href: "#signaturesubscribe",
label: "signatureSubscribe",
},
{
type: "link",
href: "#signatureunsubscribe",
label: "signatureUnsubscribe",
},
{
type: "link",
href: "#slotsubscribe",
label: "slotSubscribe",
},
{
type: "link",
href: "#slotunsubscribe",
label: "slotUnsubscribe",
},
],
},
{
type: "category",
label: "Unstable Methods",
collapsed: false,
items: [
{
type: "link",
href: "#blocksubscribe",
label: "blockSubscribe",
},
{
type: "link",
href: "#blockunsubscribe",
label: "blockUnsubscribe",
},
{
type: "link",
href: "#slotsupdatessubscribe",
label: "slotsUpdatesSubscribe",
},
{
type: "link",
href: "#slotsupdatesunsubscribe",
label: "slotsUpdatesUnsubscribe",
},
{
type: "link",
href: "#votesubscribe",
label: "voteSubscribe",
},
{
type: "link",
href: "#voteunsubscribe",
label: "voteUnsubscribe",
},
],
},
// {
// type: "category",
// label: "Deprecated Methods",
// collapsed: true,
// items: [
// {
// type: "link",
// href: "#getconfirmedblock",
// label: "getConfirmedBlock",
// },
// ],
// },
],
};

View File

@ -0,0 +1,169 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## 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
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"u64"} required={true}>
slot number, as u64 integer
</Parameter>
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
defaultValue="finalized"
optional={true}
href="/api/http#configuring-state-commitment"
></Field>
<Field
name="transactionDetails"
type="string"
defaultValue="full"
optional={true}
>
level of transaction detail to return, either "full", "signatures", or "none"
</Field>
<Field name="rewards" type="bool" defaultValue={true} optional={true}>
whether to populate the `rewards` array.
</Field>
<Field name="encoding" type="string" defaultValue="json" optional={true} href="/api/http#parsed-responses">
Encoding format for Account data
<Values values={["json", "base58", "base64", "jsonParsed"]} />
<details>
- `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).
</details>
</Field>
</Parameter>
### Result:
The result field will be an object with the following fields:
- `<null>` - if specified block is not confirmed
- `<object>` - if block is confirmed, an object with the following fields:
- `blockhash: <string>` - the blockhash of this block, as base-58 encoded string
- `previousBlockhash: <string>` - 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: <u64>` - the slot index of this block's parent
- `transactions: <array>` - present if "full" transaction details are requested; an array of JSON objects containing:
- `transaction: <object|[string,encoding]>` - [Transaction](#transaction-structure) object, either in JSON format or encoded binary data, depending on encoding parameter
- `meta: <object>` - transaction status metadata object, containing `null` or:
- `err: <object|null>` - 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: <u64>` - fee this transaction was charged, as u64 integer
- `preBalances: <array>` - array of u64 account balances from before the transaction was processed
- `postBalances: <array>` - array of u64 account balances after the transaction was processed
- `innerInstructions: <array|null>` - List of [inner instructions](#inner-instructions-structure) or `null` if inner instruction recording was not enabled during this transaction
- `preTokenBalances: <array|undefined>` - 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: <array|undefined>` - 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|null>` - array of string log messages or `null` if log message recording was not enabled during this transaction
- DEPRECATED: `status: <object>` - Transaction status
- `"Ok": <null>` - Transaction was successful
- `"Err": <ERR>` - Transaction failed with TransactionError
- `signatures: <array>` - present if "signatures" are requested for transaction details; an array of signatures strings, corresponding to the transaction order in the block
- `rewards: <array>` - present if rewards are requested; an array of JSON objects containing:
- `pubkey: <string>` - The public key, as base-58 encoded string, of the account that received the reward
- `lamports: <i64>`- number of reward lamports credited or debited by the account, as a i64
- `postBalance: <u64>` - account balance in lamports after the reward was applied
- `rewardType: <string|undefined>` - type of reward: "fee", "rent", "voting", "staking"
- `commission: <u8|undefined>` - vote account commission when the reward was credited, only present for voting and staking rewards
- `blockTime: <i64|null>` - 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)
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,71 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## 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
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"u64"} required={true}>
start_slot, as u64 integer
</Parameter>
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
optional={true}
href="/api/http#configuring-state-commitment"
></Field>
</Parameter>
### 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.
</CodeParams>
<CodeSnippets>
### 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 }
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,78 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## 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
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"u64"} required={true}>
start_slot, as u64 integer
</Parameter>
<Parameter type={"u64"} required={true}>
limit, as u64 integer
</Parameter>
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
optional={true}
href="/api/http#configuring-state-commitment"
></Field>
</Parameter>
### Result:
The result field will be an array of u64 integers listing confirmed blocks
starting at `start_slot` for up to `limit` blocks, inclusive.
</CodeParams>
<CodeSnippets>
### 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 }
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,114 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## 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
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"string"} required={true}>
account address, as base-58 encoded string
</Parameter>
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
defaultValue="finalized"
optional={true}
href="/api/http#configuring-state-commitment"
></Field>
<Field name="limit" type="number" optional={true}>
maximum transaction signatures to return (between 1 and 1,000, default:
1,000).
</Field>
<Field name="before" type="string" optional={true}>
start searching backwards from this transaction signature. (If not provided
the search starts from the top of the highest max confirmed block.)
</Field>
<Field name="until" type="string" optional={true}>
search until this transaction signature, if found before limit reached.
</Field>
</Parameter>
### Result:
The result field will be an array of `<object>`, ordered
from newest to oldest transaction, containing transaction signature information with the following fields:
- `signature: <string>` - transaction signature as base-58 encoded string
- `slot: <u64>` - The slot that contains the block with the transaction
- `err: <object|null>` - 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: <string|null>` - Memo associated with the transaction, null if no memo is present
- `blockTime: <i64|null>` - estimated production time, as Unix timestamp (seconds since the Unix epoch) of when transaction was processed. null if not available.
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,133 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## 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
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"string"} required={true}>
transaction signature, as base-58 encoded string
</Parameter>
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
optional={true}
href="/api/http#configuring-state-commitment"
></Field>
<Field name="encoding" defaultValue="json" type="string" optional={true} href="/api/http#parsed-responses">
Encoding format for Account data
<Values values={["json", "base58", "base64", "jsonParsed"]} />
<details>
- `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).
</details>
</Field>
</Parameter>
### Result:
- `<null>` - if transaction is not found or not confirmed
- `<object>` - if transaction is confirmed, an object with the following fields:
- `slot: <u64>` - the slot this transaction was processed in
- `transaction: <object|[string,encoding]>` - [Transaction](#transaction-structure) object, either in JSON format or encoded binary data, depending on encoding parameter
- `blockTime: <i64|null>` - estimated production time, as Unix timestamp (seconds since the Unix epoch) of when the transaction was processed. null if not available
- `meta: <object|null>` - transaction status metadata object:
- `err: <object|null>` - 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: <u64>` - fee this transaction was charged, as u64 integer
- `preBalances: <array>` - array of u64 account balances from before the transaction was processed
- `postBalances: <array>` - array of u64 account balances after the transaction was processed
- `innerInstructions: <array|null>` - List of [inner instructions](#inner-instructions-structure) or `null` if inner instruction recording was not enabled during this transaction
- `preTokenBalances: <array|undefined>` - 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: <array|undefined>` - 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|null>` - array of string log messages or `null` if log message recording was not enabled during this transaction
- DEPRECATED: `status: <object>` - Transaction status
- `"Ok": <null>` - Transaction was successful
- `"Err": <ERR>` - Transaction failed with TransactionError
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,97 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## 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
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"string"} required={true}>
query blockhash, as a base-58 encoded string
</Parameter>
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
optional={true}
href="/api/http#configuring-state-commitment"
></Field>
<Field name="minContextSlot" type="number" optional={true}>
The minimum slot that the request can be evaluated at
</Field>
</Parameter>
### Result:
The result will be an RpcResponse JSON object with `value` equal to:
- `<null>` - if the query blockhash has expired; or
- `<object>` - otherwise, a JSON object containing:
- `feeCalculator: <object>` - `FeeCalculator` object describing the cluster fee rate at the queried blockhash
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,76 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## 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
<DocSideBySide>
<CodeParams>
### Parameters:
**None**
### Result:
The result will be an RpcResponse JSON object with `value` equal to an `object` with the following fields:
- `burnPercent: <u8>` - Percentage of fees collected to be destroyed
- `maxLamportsPerSignature: <u64>` - Largest value `lamportsPerSignature` can attain for the next slot
- `minLamportsPerSignature: <u64>` - Smallest value `lamportsPerSignature` can attain for the next slot
- `targetLamportsPerSignature: <u64>` - Desired fee rate for the cluster
- `targetSignaturesPerSlot: <u64>` - Desired signature rate for the cluster
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,92 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## 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.
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"string"} required={true}>
Pubkey of account to query, as base-58 encoded string
</Parameter>
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
optional={true}
href="/api/http#configuring-state-commitment"
></Field>
</Parameter>
### Result:
The result will be an RpcResponse JSON object with `value` set to a JSON object with the following fields:
- `blockhash: <string>` - a Hash as base-58 encoded string
- `feeCalculator: <object>` - FeeCalculator object, the fee schedule for this block hash
- `lastValidSlot: <u64>` - DEPRECATED - this value is inaccurate and should not be relied upon
- `lastValidBlockHeight: <u64>` - last [block height](../../terminology.md#block-height) at which the blockhash will be valid
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,87 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## 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.
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"string"} required={true}>
Pubkey of account to query, as base-58 encoded string
</Parameter>
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
optional={true}
href="/api/http#configuring-state-commitment"
></Field>
</Parameter>
### Result:
An RpcResponse containing a JSON object consisting of a string blockhash and FeeCalculator JSON object.
- `RpcResponse<object>` - RpcResponse JSON object with `value` field set to a JSON object including:
- `blockhash: <string>` - a Hash as base-58 encoded string
- `feeCalculator: <object>` - FeeCalculator object, the fee schedule for this block hash
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,64 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## 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
<DocSideBySide>
<CodeParams>
### Parameters:
**None**
### Result:
`<u64>` - Snapshot slot
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

419
docs/src/api/http.md Normal file
View File

@ -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: <string>` - set to `"2.0"`
- `id: <number>` - a unique client-generated identifying integer
- `method: <string>` - a string containing the method to be invoked
- `params: <array>` - 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: <string>` - matching the request specification
- `id: <number>` - matching the request identifier
- `result: <array|number|object|string>` - 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.<br />
**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"
<GetAccountInfo />
import GetBalance from "./methods/\_getBalance.mdx"
<GetBalance />
import GetBlock from "./methods/\_getBlock.mdx"
<GetBlock />
import GetBlockHeight from "./methods/\_getBlockHeight.mdx"
<GetBlockHeight />
import GetBlockProduction from "./methods/\_getBlockProduction.mdx"
<GetBlockProduction />
import GetBlockCommitment from "./methods/\_getBlockCommitment.mdx"
<GetBlockCommitment />
import GetBlocks from "./methods/\_getBlocks.mdx"
<GetBlocks />
import GetBlocksWithLimit from "./methods/\_getBlocksWithLimit.mdx"
<GetBlocksWithLimit />
import GetBlockTime from "./methods/\_getBlockTime.mdx"
<GetBlockTime />
import GetClusterNodes from "./methods/\_getClusterNodes.mdx"
<GetClusterNodes />
import GetEpochInfo from "./methods/\_getEpochInfo.mdx"
<GetEpochInfo />
import GetEpochSchedule from "./methods/\_getEpochSchedule.mdx"
<GetEpochSchedule />
import GetFeeForMessage from "./methods/\_getFeeForMessage.mdx"
<GetFeeForMessage />
import GetFirstAvailableBlock from "./methods/\_getFirstAvailableBlock.mdx"
<GetFirstAvailableBlock />
import GetGenesisHash from "./methods/\_getGenesisHash.mdx"
<GetGenesisHash />
import GetHealth from "./methods/\_getHealth.mdx"
<GetHealth />
import GetHighestSnapshotSlot from "./methods/\_getHighestSnapshotSlot.mdx"
<GetHighestSnapshotSlot />
import GetIdentity from "./methods/\_getIdentity.mdx"
<GetIdentity />
import GetInflationGovernor from "./methods/\_getInflationGovernor.mdx"
<GetInflationGovernor />
import GetInflationRate from "./methods/\_getInflationRate.mdx"
<GetInflationRate />
import GetInflationReward from "./methods/\_getInflationReward.mdx"
<GetInflationReward />
import GetLargestAccounts from "./methods/\_getLargestAccounts.mdx"
<GetLargestAccounts />
import GetLatestBlockhash from "./methods/\_getLatestBlockhash.mdx"
<GetLatestBlockhash />
import GetLeaderSchedule from "./methods/\_getLeaderSchedule.mdx"
<GetLeaderSchedule />
import GetMaxRetransmitSlot from "./methods/\_getMaxRetransmitSlot.mdx"
<GetMaxRetransmitSlot />
import GetMaxShredInsertSlot from "./methods/\_getMaxShredInsertSlot.mdx"
<GetMaxShredInsertSlot />
import GetMinimumBalanceForRentExemption from "./methods/\_getMinimumBalanceForRentExemption.mdx"
<GetMinimumBalanceForRentExemption />
import GetMultipleAccounts from "./methods/\_getMultipleAccounts.mdx"
<GetMultipleAccounts />
import GetProgramAccounts from "./methods/\_getProgramAccounts.mdx"
<GetProgramAccounts />
import GetRecentPerformanceSamples from "./methods/\_getRecentPerformanceSamples.mdx"
<GetRecentPerformanceSamples />
import GetRecentPrioritizationFees from "./methods/\_getRecentPrioritizationFees.mdx"
<GetRecentPrioritizationFees />
import GetSignaturesForAddress from "./methods/\_getSignaturesForAddress.mdx"
<GetSignaturesForAddress />
import GetSignatureStatuses from "./methods/\_getSignatureStatuses.mdx"
<GetSignatureStatuses />
import GetSlot from "./methods/\_getSlot.mdx"
<GetSlot />
import GetSlotLeader from "./methods/\_getSlotLeader.mdx"
<GetSlotLeader />
import GetSlotLeaders from "./methods/\_getSlotLeaders.mdx"
<GetSlotLeaders />
import GetStakeActivation from "./methods/\_getStakeActivation.mdx"
<GetStakeActivation />
import GetStakeMinimumDelegation from "./methods/\_getStakeMinimumDelegation.mdx"
<GetStakeMinimumDelegation />
import GetSupply from "./methods/\_getSupply.mdx"
<GetSupply />
import GetTokenAccountBalance from "./methods/\_getTokenAccountBalance.mdx"
<GetTokenAccountBalance />
import GetTokenAccountsByDelegate from "./methods/\_getTokenAccountsByDelegate.mdx"
<GetTokenAccountsByDelegate />
import GetTokenAccountsByOwner from "./methods/\_getTokenAccountsByOwner.mdx"
<GetTokenAccountsByOwner />
import GetTokenLargestAccounts from "./methods/\_getTokenLargestAccounts.mdx"
<GetTokenLargestAccounts />
import GetTokenSupply from "./methods/\_getTokenSupply.mdx"
<GetTokenSupply />
import GetTransaction from "./methods/\_getTransaction.mdx"
<GetTransaction />
import GetTransactionCount from "./methods/\_getTransactionCount.mdx"
<GetTransactionCount />
import GetVersion from "./methods/\_getVersion.mdx"
<GetVersion />
import GetVoteAccounts from "./methods/\_getVoteAccounts.mdx"
<GetVoteAccounts />
import IsBlockhashValid from "./methods/\_isBlockhashValid.mdx"
<IsBlockhashValid />
import MinimumLedgerSlot from "./methods/\_minimumLedgerSlot.mdx"
<MinimumLedgerSlot />
import RequestAirdrop from "./methods/\_requestAirdrop.mdx"
<RequestAirdrop />
import SendTransaction from "./methods/\_sendTransaction.mdx"
<SendTransaction />
import SimulateTransaction from "./methods/\_simulateTransaction.mdx"
<SimulateTransaction />
## JSON RPC API Deprecated Methods
import GetConfirmedBlock from "./deprecated/\_getConfirmedBlock.mdx"
<GetConfirmedBlock />
import GetConfirmedBlocks from "./deprecated/\_getConfirmedBlocks.mdx"
<GetConfirmedBlocks />
import GetConfirmedBlocksWithLimit from "./deprecated/\_getConfirmedBlocksWithLimit.mdx"
<GetConfirmedBlocksWithLimit />
import GetConfirmedSignaturesForAddress2 from "./deprecated/\_getConfirmedSignaturesForAddress2.mdx"
<GetConfirmedSignaturesForAddress2 />
import GetConfirmedTransaction from "./deprecated/\_getConfirmedTransaction.mdx"
<GetConfirmedTransaction />
import GetFeeCalculatorForBlockhash from "./deprecated/\_getFeeCalculatorForBlockhash.mdx"
<GetFeeCalculatorForBlockhash />
import GetFeeRateGovernor from "./deprecated/\_getFeeRateGovernor.mdx"
<GetFeeRateGovernor />
import GetFees from "./deprecated/\_getFees.mdx"
<GetFees />
import GetRecentBlockhash from "./deprecated/\_getRecentBlockhash.mdx"
<GetRecentBlockhash />
import GetSnapshotSlot from "./deprecated/\_getSnapshotSlot.mdx"
<GetSnapshotSlot />

View File

@ -0,0 +1,136 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## getAccountInfo
Returns all information associated with the account of provided Pubkey
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"string"} required={true}>
Pubkey of account to query, as base-58 encoded string
</Parameter>
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
optional={true}
href="/api/http#configuring-state-commitment"
></Field>
<Field name="encoding" type="string" optional={true} href="/api/http#parsed-responses">
Encoding format for Account data
<Values values={["base58", "base64", "base64+zstd", "jsonParsed"]} />
<details>
- `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`.
</details>
</Field>
<Field name="dataSlice" type="string" optional={true}>
limit the returned account data using the provided "offset: &lt;usize&gt;" and
"length: &lt;usize&gt;" fields
<li>
only available for <code>base58</code>, <code>base64</code> or{" "}
<code>base64+zstd</code> encodings.
</li>
</Field>
<Field name="minContextSlot" type="number" optional={true}>
The minimum slot that the request can be evaluated at
</Field>
</Parameter>
### Result:
The result will be an RpcResponse JSON object with `value` equal to:
- `<null>` - if the requested account doesn't exist
- `<object>` - otherwise, a JSON object containing:
- `lamports: <u64>` - number of lamports assigned to this account, as a u64
- `owner: <string>` - 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 `{<program>: <state>}` - depending on encoding parameter
- `executable: <bool>` - boolean indicating if the account contains a program \(and is strictly read-only\)
- `rentEpoch: <u64>` - the epoch at which this account will next owe rent, as u64
- `size: <u64>` - the data size of the account
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,78 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## getBalance
Returns the balance of the account of provided Pubkey
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"string"} required={true}>
Pubkey of account to query, as base-58 encoded string
</Parameter>
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
optional={true}
href="/api/http#configuring-state-commitment"
></Field>
<Field name="minContextSlot" type="number" optional={true}>
The minimum slot that the request can be evaluated at
</Field>
</Parameter>
### Result:
`RpcResponse<u64>` - RpcResponse JSON object with `value` field set to the balance
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,288 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## getBlock
Returns identity and transaction information about a confirmed block in the ledger
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"u64"} required={true}>
slot number, as <code>u64</code> integer
</Parameter>
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
optional={true}
defaultValue={"finalized"}
href="/api/http#configuring-state-commitment"
>
<li>
the default is <code>finalized</code>
</li>
<li>
<code>processed</code> is not supported.
</li>
</Field>
<Field name="encoding" type="string" optional={true} defaultValue={"json"} href="/api/http#parsed-responses">
encoding format for each returned Transaction
<Values values={["json", "jsonParsed", "base58", "base64"]} />
<details>
- `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).
</details>
</Field>
<Field name="transactionDetails" type="string" optional={true} defaultValue={"full"}>
level of transaction detail to return
<Values values={["full", "accounts", "signatures", "none"]} />
<details>
- 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.
</details>
</Field>
<Field name="maxSupportedTransactionVersion" type="number" optional={true}>
the max transaction version to return in responses.
<details>
- 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.
</details>
</Field>
<Field name="rewards" type="bool" optional={true}>
whether to populate the `rewards` array. If parameter not provided, the
default includes rewards.
</Field>
</Parameter>
### Result:
The result field will be an object with the following fields:
- `<null>` - if specified block is not confirmed
- `<object>` - if block is confirmed, an object with the following fields:
- `blockhash: <string>` - the blockhash of this block, as base-58 encoded string
- `previousBlockhash: <string>` - 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: <u64>` - the slot index of this block's parent
- `transactions: <array>` - present if "full" transaction details are requested; an array of JSON objects containing:
- `transaction: <object|[string,encoding]>` - [Transaction](#transaction-structure) object, either in JSON format or encoded binary data, depending on encoding parameter
- `meta: <object>` - transaction status metadata object, containing `null` or:
- `err: <object|null>` - 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: <u64>` - fee this transaction was charged, as u64 integer
- `preBalances: <array>` - array of u64 account balances from before the transaction was processed
- `postBalances: <array>` - array of u64 account balances after the transaction was processed
- `innerInstructions: <array|null>` - List of [inner instructions](#inner-instructions-structure) or `null` if inner instruction recording was not enabled during this transaction
- `preTokenBalances: <array|undefined>` - 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: <array|undefined>` - 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|null>` - array of string log messages or `null` if log message recording was not enabled during this transaction
- `rewards: <array|null>` - transaction-level rewards, populated if rewards are requested; an array of JSON objects containing:
- `pubkey: <string>` - The public key, as base-58 encoded string, of the account that received the reward
- `lamports: <i64>`- number of reward lamports credited or debited by the account, as a i64
- `postBalance: <u64>` - account balance in lamports after the reward was applied
- `rewardType: <string|undefined>` - type of reward: "fee", "rent", "voting", "staking"
- `commission: <u8|undefined>` - vote account commission when the reward was credited, only present for voting and staking rewards
- DEPRECATED: `status: <object>` - Transaction status
- `"Ok": <null>` - Transaction was successful
- `"Err": <ERR>` - Transaction failed with TransactionError
- `loadedAddresses: <object|undefined>` - Transaction addresses loaded from address lookup tables. Undefined if `maxSupportedTransactionVersion` is not set in request params.
- `writable: <array[string]>` - Ordered list of base-58 encoded addresses for writable loaded accounts
- `readonly: <array[string]>` - Ordered list of base-58 encoded addresses for readonly loaded accounts
- `returnData: <object|undefined>` - the most-recent return data generated by an instruction in the transaction, with the following fields:
- `programId: <string>` - 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: <u64|undefined>` - 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: <array>` - present if "signatures" are requested for transaction details; an array of signatures strings, corresponding to the transaction order in the block
- `rewards: <array|undefined>` - block-level rewards, present if rewards are requested; an array of JSON objects containing:
- `pubkey: <string>` - The public key, as base-58 encoded string, of the account that received the reward
- `lamports: <i64>`- number of reward lamports credited or debited by the account, as a i64
- `postBalance: <u64>` - account balance in lamports after the reward was applied
- `rewardType: <string|undefined>` - type of reward: "fee", "rent", "voting", "staking"
- `commission: <u8|undefined>` - vote account commission when the reward was credited, only present for voting and staking rewards
- `blockTime: <i64|null>` - estimated production time, as Unix timestamp (seconds since the Unix epoch). null if not available
- `blockHeight: <u64|null>` - the number of blocks beneath this block
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
---
#### 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: <array[string]>` - 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: <object>` - Defines the content of the transaction.
- `accountKeys: <array[string]>` - 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: <object>` - Details the account types and signatures required by the transaction.
- `numRequiredSignatures: <number>` - The total number of signatures required to make the transaction valid. The signatures must match the first `numRequiredSignatures` of `message.accountKeys`.
- `numReadonlySignedAccounts: <number>` - 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: <number>` - The last `numReadonlyUnsignedAccounts` of the unsigned keys are read-only accounts.
- `recentBlockhash: <string>` - A base-58 encoded hash of a recent block in the ledger used to prevent transaction duplication and to give transactions lifetimes.
- `instructions: <array[object]>` - List of program instructions that will be executed in sequence and committed in one atomic transaction if all succeed.
- `programIdIndex: <number>` - Index into the `message.accountKeys` array indicating the program account that executes this instruction.
- `accounts: <array[number]>` - List of ordered indices into the `message.accountKeys` array indicating which accounts to pass to the program.
- `data: <string>` - The program input data encoded in a base-58 string.
- `addressTableLookups: <array[object]|undefined>` - 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: <string>` - base-58 encoded public key for an address lookup table account.
- `writableIndexes: <array[number]>` - List of indices used to load addresses of writable accounts from a lookup table.
- `readonlyIndexes: <array[number]>` - 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: <array[object]>` - Ordered list of inner program instructions that were invoked during a single transaction instruction.
- `programIdIndex: <number>` - Index into the `message.accountKeys` array indicating the program account that executes this instruction.
- `accounts: <array[number]>` - List of ordered indices into the `message.accountKeys` array indicating which accounts to pass to the program.
- `data: <string>` - 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: <number>` - Index of the account in which the token balance is provided for.
- `mint: <string>` - Pubkey of the token's mint.
- `owner: <string|undefined>` - Pubkey of token balance's owner.
- `programId: <string|undefined>` - Pubkey of the Token program that owns the account.
- `uiTokenAmount: <object>` -
- `amount: <string>` - Raw amount of tokens as a string, ignoring decimals.
- `decimals: <number>` - Number of decimals configured for token's mint.
- `uiAmount: <number|null>` - Token amount as a float, accounting for decimals. **DEPRECATED**
- `uiAmountString: <string>` - Token amount as a string, accounting for decimals.
</DocBlock>

View File

@ -0,0 +1,70 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## getBlockCommitment
Returns commitment for particular block
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"u64"} required={true}>
block number, identified by Slot
</Parameter>
### Result:
The result field will be a JSON object containing:
- `commitment` - commitment, comprising either:
- `<null>` - Unknown block
- `<array>` - 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
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,73 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## getBlockHeight
Returns the current block height of the node
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
optional={true}
href="/api/http#configuring-state-commitment"
></Field>
<Field name="minContextSlot" type="number" optional={true}>
The minimum slot that the request can be evaluated at
</Field>
</Parameter>
### Result:
- `<u64>` - Current block height
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,97 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## getBlockProduction
Returns recent block production information from the current or previous epoch.
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
optional={true}
href="/api/http#configuring-state-commitment"
></Field>
<Field name="identity" type="string" optional={true}>
Only return results for this validator identity (base-58 encoded)
</Field>
<Field name="range" type="object" optional={true}>
Slot range to return block production for. If parameter not provided, defaults to current epoch.
- `firstSlot: <u64>` - first slot to return block production information for (inclusive)
- (optional) `lastSlot: <u64>` - last slot to return block production information for (inclusive). If parameter not provided, defaults to the highest slot
</Field>
</Parameter>
### Result:
The result will be an RpcResponse JSON object with `value` equal to:
- `<object>`
- `byIdentity: <object>` - 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: <object>` - Block production slot range
- `firstSlot: <u64>` - first slot of the block production information (inclusive)
- `lastSlot: <u64>` - last slot of block production information (inclusive)
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,67 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## 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.
:::
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"u64"} required={true}>
block number, identified by Slot
</Parameter>
### Result:
- `<i64>` - estimated production time, as Unix timestamp (seconds since the Unix epoch)
- `<null>` - timestamp is not available for this block
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,86 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## getBlocks
Returns a list of confirmed blocks between two slots
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"u64"} required={true}>
end_slot, as <code>u64</code> integer
</Parameter>
<Parameter type={"u64"} optional={true}>
start_slot, as <code>u64</code> integer (must be no more than 500,000 blocks
higher than the `start_slot`)
</Parameter>
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
optional={true}
defaultValue={"finalized"}
href="/api/http#configuring-state-commitment"
>
- "processed" is not supported
</Field>
</Parameter>
### 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.
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,84 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## getBlocksWithLimit
Returns a list of confirmed blocks starting at the given slot
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"u64"} required={true}>
start_slot, as <code>u64</code> integer
</Parameter>
<Parameter type={"u64"} optional={true}>
limit, as <code>u64</code> integer (must be no more than 500,000 blocks higher
than the <code>start_slot</code>)
</Parameter>
<Parameter type={"object"} optional={true}>
Configuration object containing the following field:
<Field
name="commitment"
type="string"
optional={true}
defaultValue="finalized"
href="/api/http#configuring-state-commitment"
>
- "processed" is not supported
</Field>
</Parameter>
### Result:
The result field will be an array of u64 integers listing confirmed blocks
starting at `start_slot` for up to `limit` blocks, inclusive.
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,71 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## getClusterNodes
Returns information about all the nodes participating in the cluster
<DocSideBySide>
<CodeParams>
### Parameters:
**None**
### Result:
The result field will be an array of JSON objects, each with the following sub fields:
- `pubkey: <string>` - Node public key, as base-58 encoded string
- `gossip: <string|null>` - Gossip network address for the node
- `tpu: <string|null>` - TPU network address for the node
- `rpc: <string|null>` - JSON RPC network address for the node, or `null` if the JSON RPC service is not enabled
- `version: <string|null>` - The software version of the node, or `null` if the version information is not available
- `featureSet: <u32|null >` - The unique identifier of the node's feature set
- `shredVersion: <u16|null>` - The shred version the node has been configured to use
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,85 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## getEpochInfo
Returns information about the current epoch
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"string"} required={true}>
Pubkey of account to query, as base-58 encoded string
</Parameter>
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
optional={true}
href="/api/http#configuring-state-commitment"
></Field>
<Field name="minContextSlot" type="number" optional={true}>
The minimum slot that the request can be evaluated at
</Field>
</Parameter>
### Result:
The result field will be an object with the following fields:
- `absoluteSlot: <u64>` - the current slot
- `blockHeight: <u64>` - the current block height
- `epoch: <u64>` - the current epoch
- `slotIndex: <u64>` - the current slot relative to the start of the current epoch
- `slotsInEpoch: <u64>` - the number of slots in this epoch
- `transactionCount: <u64|null>` - total number of transactions processed without error since genesis
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,67 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## getEpochSchedule
Returns the epoch schedule information from this cluster's genesis config
<DocSideBySide>
<CodeParams>
### Parameters:
**None**
### Result:
The result field will be an object with the following fields:
- `slotsPerEpoch: <u64>` - the maximum number of slots in each epoch
- `leaderScheduleSlotOffset: <u64>` - the number of slots before beginning of an epoch to calculate a leader schedule for that epoch
- `warmup: <bool>` - whether epochs start short and grow
- `firstNormalEpoch: <u64>` - first normal-length epoch, log2(slotsPerEpoch) - log2(MINIMUM_SLOTS_PER_EPOCH)
- `firstNormalSlot: <u64>` - MINIMUM_SLOTS_PER_EPOCH \* (2.pow(firstNormalEpoch) - 1)
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,86 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## 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**
:::
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"string"} required={true}>
Base-64 encoded Message
</Parameter>
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
optional={true}
href="/api/http#configuring-state-commitment"
></Field>
<Field name="minContextSlot" type="number" optional={true}>
The minimum slot that the request can be evaluated at
</Field>
</Parameter>
### Result:
- `<u64|null>` - Fee corresponding to the message at the specified blockhash
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,50 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## getFirstAvailableBlock
Returns the slot of the lowest confirmed block that has not been purged from the ledger
<DocSideBySide>
<CodeParams>
### Parameters:
**None**
### Result:
- `<u64>` - Slot
</CodeParams>
<CodeSnippets>
### 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 }
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,51 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## getGenesisHash
Returns the genesis hash
<DocSideBySide>
<CodeParams>
### Parameters:
**None**
### Result:
- `<string>` - a Hash as base-58 encoded string
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,88 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## 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.
:::
<DocSideBySide>
<CodeParams>
### 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
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,78 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## 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
:::
<DocSideBySide>
<CodeParams>
### Parameters:
**None**
### Result:
When the node has a snapshot, this returns a JSON object with the following fields:
- `full: <u64>` - Highest full snapshot slot
- `incremental: <u64|undefined>` - Highest incremental snapshot slot _based on_ `full`
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,55 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## getIdentity
Returns the identity pubkey for the current node
<DocSideBySide>
<CodeParams>
### 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\)
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,75 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## getInflationGovernor
Returns the current inflation governor
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
optional={true}
href="/api/http#configuring-state-commitment"
></Field>
</Parameter>
### Result:
The result field will be a JSON object with the following fields:
- `initial: <f64>` - the initial inflation percentage from time 0
- `terminal: <f64>` - terminal inflation percentage
- `taper: <f64>` - rate per year at which inflation is lowered. (Rate reduction is derived using the target slot time in genesis config)
- `foundation: <f64>` - percentage of total inflation allocated to the foundation
- `foundationTerm: <f64>` - duration of foundation pool inflation in years
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,62 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## getInflationRate
Returns the specific inflation values for the current epoch
<DocSideBySide>
<CodeParams>
### Parameters:
**None**
### Result:
The result field will be a JSON object with the following fields:
- `total: <f64>` - total inflation
- `validator: <f64>` -inflation allocated to validators
- `foundation: <f64>` - inflation allocated to the foundation
- `epoch: <u64>` - epoch for which these values are valid
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,101 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## getInflationReward
Returns the inflation / staking reward for a list of addresses for an epoch
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"array"} optional={true}>
An array of addresses to query, as base-58 encoded strings
</Parameter>
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
optional={true}
href="/api/http#configuring-state-commitment"
></Field>
<Field name="epoch" type="u64" optional={true}>
An epoch for which the reward occurs. If omitted, the previous epoch will be
used
</Field>
<Field name="minContextSlot" type="number" optional={true}>
The minimum slot that the request can be evaluated at
</Field>
</Parameter>
### Result:
The result field will be a JSON array with the following fields:
- `epoch: <u64>` - epoch for which reward occured
- `effectiveSlot: <u64>` - the slot in which the rewards are effective
- `amount: <u64>` - reward amount in lamports
- `postBalance: <u64>` - post balance of the account in lamports
- `commission: <u8|undefined>` - vote account commission when the reward was credited
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,150 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## getLargestAccounts
Returns the 20 largest accounts, by lamport balance (results may be cached up to two hours)
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
optional={true}
href="/api/http#configuring-state-commitment"
></Field>
<Field name="filter" type="string" optional={true}>
filter results by account type
<Values values={["circulating", "nonCirculating"]} />
</Field>
</Parameter>
### Result:
The result will be an RpcResponse JSON object with `value` equal to an array of `<object>` containing:
- `address: <string>` - base-58 encoded address of the account
- `lamports: <u64>` - number of lamports in the account, as a u64
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,92 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## 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
:::
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
optional={true}
href="/api/http#configuring-state-commitment"
></Field>
<Field name="minContextSlot" type="number" optional={true}>
The minimum slot that the request can be evaluated at
</Field>
</Parameter>
### Result:
`RpcResponse<object>` - RpcResponse JSON object with `value` field set to a JSON object including:
- `blockhash: <string>` - a Hash as base-58 encoded string
- `lastValidBlockHeight: <u64>` - last [block height](../../terminology.md#block-height) at which the blockhash will be valid
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,96 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## getLeaderSchedule
Returns the leader schedule for an epoch
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"u64"} optional={true}>
Fetch the leader schedule for the epoch that corresponds to the provided slot.
<li>If unspecified, the leader schedule for the current epoch is fetched</li>
</Parameter>
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
optional={true}
href="/api/http#configuring-state-commitment"
></Field>
<Field name="identity" type="string" optional={true}>
Only return results for this validator identity (base-58 encoded)
</Field>
</Parameter>
### Result:
Returns a result with one of the two following values:
- `<null>` - if requested epoch is not found, or
- `<object>` - 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)
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,48 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## getMaxRetransmitSlot
Get the max slot seen from retransmit stage.
<DocSideBySide>
<CodeParams>
### Parameters:
**None**
### Result:
`<u64>` - Slot number
</CodeParams>
<CodeSnippets>
### 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 }
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,48 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## getMaxShredInsertSlot
Get the max slot seen from after shred insert.
<DocSideBySide>
<CodeParams>
### Parameters:
**None**
### Result:
`<u64>` - Slot number
</CodeParams>
<CodeSnippets>
### 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 }
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,67 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## getMinimumBalanceForRentExemption
Returns minimum balance required to make account rent exempt.
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"usize"} optional={true}>
the Account's data length
</Parameter>
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
optional={true}
href="/api/http#configuring-state-commitment"
></Field>
</Parameter>
### Result:
`<u64>` - minimum lamports required in the Account to remain rent free
</CodeParams>
<CodeSnippets>
### 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 }
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,143 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## getMultipleAccounts
Returns the account information for a list of Pubkeys.
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"array"} optional={true}>
An array of Pubkeys to query, as base-58 encoded strings (up to a maximum of
100)
</Parameter>
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
optional={true}
href="/api/http#configuring-state-commitment"
></Field>
<Field name="minContextSlot" type="number" optional={true}>
The minimum slot that the request can be evaluated at
</Field>
<Field name="dataSlice" type="object" optional={true}>
limit the returned account data using the provided `offset: <usize>` and `length: <usize>` fields; only available for "base58", "base64" or "base64+zstd" encodings.
</Field>
<Field name="encoding" type="string" optional={true} defaultValue={"json"} href="/api/http#parsed-responses">
encoding format for the returned Account data
<Values values={["jsonParsed", "base58", "base64", "base64+zstd"]} />
<details>
- `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 `<string>`.
</details>
</Field>
</Parameter>
### Result:
The result will be a JSON object with `value` equal to an array of:
- `<null>` - if the account at that Pubkey doesn't exist, or
- `<object>` - a JSON object containing:
- `lamports: <u64>` - number of lamports assigned to this account, as a u64
- `owner: <string>` - 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 `{<program>: <state>}` - depending on encoding parameter
- `executable: <bool>` - boolean indicating if the account contains a program \(and is strictly read-only\)
- `rentEpoch: <u64>` - the epoch at which this account will next owe rent, as u64
- `size: <u64>` - the data size of the account
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,160 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## getProgramAccounts
Returns all accounts owned by the provided program Pubkey
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"string"} required={true}>
Pubkey of program, as base-58 encoded string
</Parameter>
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
optional={true}
href="/api/http#configuring-state-commitment"
></Field>
<Field name="minContextSlot" type="number" optional={true}>
The minimum slot that the request can be evaluated at
</Field>
<Field name="withContext" type="bool" optional={true}>
wrap the result in an RpcResponse JSON object
</Field>
<Field name="encoding" type="string" optional={true} defaultValue={"json"} href="/api/http#parsed-responses">
encoding format for the returned Account data
<Values values={["jsonParsed", "base58", "base64", "base64+zstd"]} />
<details>
- `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 `<string>`.
</details>
</Field>
<Field name="dataSlice" type="object" optional={true}>
limit the returned account data using the provided `offset: usize` and `length: usize` fields;
- only available for "base58", "base64" or "base64+zstd" encodings.
</Field>
<Field name="filters" type="array" optional={true} href={"/api/http#filter-criteria"}>
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
:::
</Field>
</Parameter>
### 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: <string>` - the account Pubkey as base-58 encoded string
- `account: <object>` - a JSON object, with the following sub fields:
- `lamports: <u64>` - number of lamports assigned to this account, as a u64
- `owner: <string>` - 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 `{<program>: <state>}` - depending on encoding parameter
- `executable: <bool>` - boolean indicating if the account contains a program \(and is strictly read-only\)
- `rentEpoch: <u64>` - the epoch at which this account will next owe rent, as u64
- `size: <u64>` - the data size of the account
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,103 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## 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.
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter name="limit" type={"usize"} optional={true}>
number of samples to return (maximum 720)
</Parameter>
### Result:
An array of `RpcPerfSample<object>` with the following fields:
- `slot: <u64>` - Slot in which sample was taken at
- `numTransactions: <u64>` - Number of transactions in sample
- `numSlots: <u64>` - Number of slots in sample
- `samplePeriodSecs: <u16>` - Number of seconds in a sample window
- `numNonVoteTransaction: <u64>` - Number of non-vote transactions in
sample.
:::info
`numNonVoteTransaction` is present starting with v1.15.
To get a number of voting transactions compute:<br />
`numTransactions - numNonVoteTransaction`
:::
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,95 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## 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.
:::
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"array"} optional={true}>
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.
:::
</Parameter>
### Result:
An array of `RpcPrioritizationFee<object>` with the following fields:
- `slot: <u64>` - slot in which the fee was observed
- `prioritizationFee: <u64>` - the per-compute-unit fee paid by at least
one successfully landed transaction, specified in increments of 0.000001 lamports
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,114 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## 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.
:::
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"array"} optional={true}>
An array of transaction signatures to confirm, as base-58 encoded strings (up
to a maximum of 256)
</Parameter>
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field name="searchTransactionHistory" type="bool" optional={true}>
if `true` - a Solana node will search its ledger cache for any signatures not
found in the recent status cache
</Field>
</Parameter>
### Result:
An array of `RpcResponse<object>` consisting of either:
- `<null>` - Unknown transaction, or
- `<object>`
- `slot: <u64>` - The slot the transaction was processed
- `confirmations: <usize|null>` - Number of blocks since signature confirmation, null if rooted, as well as finalized by a supermajority of the cluster
- `err: <object|null>` - 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: <string|null>` - 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: <object>` - Transaction status
- `"Ok": <null>` - Transaction was successful
- `"Err": <ERR>` - Transaction failed with TransactionError
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,117 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## 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
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"string"} required={true}>
Account address as base-58 encoded string
</Parameter>
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
optional={true}
href="/api/http#configuring-state-commitment"
></Field>
<Field name="minContextSlot" type="number" optional={true}>
The minimum slot that the request can be evaluated at
</Field>
<Field name="limit" type="number" optional={true} defaultValue={"1000"}>
maximum transaction signatures to return (between 1 and 1,000).
</Field>
<Field name="before" type="string" optional={true}>
start searching backwards from this transaction signature. If not provided the
search starts from the top of the highest max confirmed block.
</Field>
<Field name="until" type="string" optional={true}>
search until this transaction signature, if found before limit reached
</Field>
</Parameter>
### Result:
An array of `<object>`, ordered from **newest** to **oldest** transaction, containing transaction
signature information with the following fields:
- `signature: <string>` - transaction signature as base-58 encoded string
- `slot: <u64>` - The slot that contains the block with the transaction
- `err: <object|null>` - 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: <string|null>` - Memo associated with the transaction, null if no memo is present
- `blockTime: <i64|null>` - estimated production time, as Unix timestamp (seconds since the Unix epoch)
of when transaction was processed. null if not available.
- `confirmationStatus: <string|null>` - The transaction's cluster confirmation status;
Either `processed`, `confirmed`, or `finalized`. See [Commitment](/api/http#configuring-state-commitment)
for more on optimistic confirmation.
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,63 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## getSlot
Returns the slot that has reached the [given or default commitment level](/api/http#configuring-state-commitment)
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
optional={true}
href="/api/http#configuring-state-commitment"
></Field>
<Field name="minContextSlot" type="number" optional={true}>
The minimum slot that the request can be evaluated at
</Field>
</Parameter>
### Result:
`<u64>` - Current slot
</CodeParams>
<CodeSnippets>
### 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 }
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,67 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## getSlotLeader
Returns the current slot leader
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
optional={true}
href="/api/http#configuring-state-commitment"
></Field>
<Field name="minContextSlot" type="number" optional={true}>
The minimum slot that the request can be evaluated at
</Field>
</Parameter>
### Result:
`<string>` - Node identity Pubkey as base-58 encoded string
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,77 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## getSlotLeaders
Returns the slot leaders for a given slot range
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"u64"} optional={true}>
Start slot, as u64 integer
</Parameter>
<Parameter type={"u64"} optional={true}>
Limit, as u64 integer (between 1 and 5,000)
</Parameter>
### Result:
`<array[string]>` - array of Node identity public keys as base-58 encoded strings
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,95 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## getStakeActivation
Returns epoch activation information for a stake account
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"string"} required={true}>
Pubkey of stake Account to query, as base-58 encoded string
</Parameter>
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
optional={true}
href="/api/http#configuring-state-commitment"
></Field>
<Field name="minContextSlot" type="number" optional={true}>
The minimum slot that the request can be evaluated at
</Field>
<Field name="epoch" type="u64" optional={true}>
epoch for which to calculate activation details. If parameter not provided,
defaults to current epoch.
</Field>
</Parameter>
### Result:
The result will be a JSON object with the following fields:
- `state: <string>` - the stake account's activation state,
either: `active`, `inactive`, `activating`, or `deactivating`
- `active: <u64>` - stake active during the epoch
- `inactive: <u64>` - stake inactive during the epoch
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,73 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## getStakeMinimumDelegation
Returns the stake minimum delegation, in lamports.
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
optional={true}
href="/api/http#configuring-state-commitment"
></Field>
</Parameter>
### Result:
The result will be an RpcResponse JSON object with `value` equal to:
- `<u64>` - The stake minimum delegation, in lamports
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,87 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## getSupply
Returns information about the current supply.
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
optional={true}
href="/api/http#configuring-state-commitment"
></Field>
<Field name="excludeNonCirculatingAccountsList" type="bool" optional={true}>
exclude non circulating accounts list from response
</Field>
</Parameter>
### Result:
The result will be an RpcResponse JSON object with `value` equal to a JSON object containing:
- `total: <u64>` - Total supply in lamports
- `circulating: <u64>` - Circulating supply in lamports
- `nonCirculating: <u64>` - Non-circulating supply in lamports
- `nonCirculatingAccounts: <array>` - an array of account addresses of non-circulating accounts, as strings. If `excludeNonCirculatingAccountsList` is enabled, the returned array will be empty.
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,91 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## getTokenAccountBalance
Returns the token balance of an SPL Token account.
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"string"} required={true}>
Pubkey of Token account to query, as base-58 encoded string
</Parameter>
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
optional={true}
href="/api/http#configuring-state-commitment"
></Field>
</Parameter>
### Result:
The result will be an RpcResponse JSON object with `value` equal to a JSON object containing:
- `amount: <string>` - the raw balance without decimals, a string representation of u64
- `decimals: <u8>` - number of base 10 digits to the right of the decimal place
- `uiAmount: <number|null>` - the balance, using mint-prescribed decimals **DEPRECATED**
- `uiAmountString: <string>` - 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.
</CodeParams>
<CodeSnippets>
### 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
}
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,177 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## getTokenAccountsByDelegate
Returns all SPL Token accounts by approved Delegate.
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"string"} required={true}>
Pubkey of account delegate to query, as base-58 encoded string
</Parameter>
<Parameter type={"object"} optional={true}>
A JSON object with one of the following fields:
- `mint: <string>` - Pubkey of the specific token Mint to limit accounts to, as base-58 encoded string; or
- `programId: <string>` - Pubkey of the Token program that owns the accounts, as base-58 encoded string
</Parameter>
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
optional={true}
href="/api/http#configuring-state-commitment"
></Field>
<Field name="minContextSlot" type="number" optional={true}>
The minimum slot that the request can be evaluated at
</Field>
<Field name="dataSlice" type="object" optional={true}>
limit the returned account data using the provided `offset: <usize>`
and `length: <usize>` fields; only available for `base58`,
`base64` or `base64+zstd` encodings.
</Field>
<Field name="encoding" type="string" optional={true} href="/api/http#parsed-responses">
Encoding format for Account data
<Values values={["base58", "base64", "base64+zstd", "jsonParsed"]} />
<details>
- `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`.
</details>
</Field>
</Parameter>
### Result:
The result will be an RpcResponse JSON object with `value` equal to an array of JSON objects, which will contain:
- `pubkey: <string>` - the account Pubkey as base-58 encoded string
- `account: <object>` - a JSON object, with the following sub fields:
- `lamports: <u64>` - number of lamports assigned to this account, as a u64
- `owner: <string>` - base-58 encoded Pubkey of the program this account has been assigned to
- `data: <object>` - Token state data associated with the account, either as encoded binary data or in JSON format `{<program>: <state>}`
- `executable: <bool>` - boolean indicating if the account contains a program (and is strictly read-only\)
- `rentEpoch: <u64>` - the epoch at which this account will next owe rent, as u64
- `size: <u64>` - 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.
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,176 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## getTokenAccountsByOwner
Returns all SPL Token accounts by token owner.
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"string"} required={true}>
Pubkey of account delegate to query, as base-58 encoded string
</Parameter>
<Parameter type={"object"} optional={true}>
A JSON object with one of the following fields:
- `mint: <string>` - Pubkey of the specific token Mint to limit accounts to, as base-58 encoded string; or
- `programId: <string>` - Pubkey of the Token program that owns the accounts, as base-58 encoded string
</Parameter>
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
optional={true}
href="/api/http#configuring-state-commitment"
></Field>
<Field name="minContextSlot" type="number" optional={true}>
The minimum slot that the request can be evaluated at
</Field>
<Field name="dataSlice" type="object" optional={true}>
limit the returned account data using the provided `offset: <usize>`
and `length: <usize>` fields; only available for
`base58`, `base64`, or `base64+zstd` encodings.
</Field>
<Field name="encoding" type="string" optional={true} href="/api/http#parsed-responses">
Encoding format for Account data
<Values values={["base58", "base64", "base64+zstd", "jsonParsed"]} />
<details>
- `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`.
</details>
</Field>
</Parameter>
### Result:
The result will be an RpcResponse JSON object with `value` equal to an array of JSON objects, which will contain:
- `pubkey: <string>` - the account Pubkey as base-58 encoded string
- `account: <object>` - a JSON object, with the following sub fields:
- `lamports: <u64>` - number of lamports assigned to this account, as a u64
- `owner: <string>` - base-58 encoded Pubkey of the program this account has been assigned to
- `data: <object>` - Token state data associated with the account, either as encoded binary data or in JSON format `{<program>: <state>}`
- `executable: <bool>` - boolean indicating if the account contains a program \(and is strictly read-only\)
- `rentEpoch: <u64>` - the epoch at which this account will next owe rent, as u64
- `size: <u64>` - 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.
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,99 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## getTokenLargestAccounts
Returns the 20 largest accounts of a particular SPL Token type.
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"string"} required={true}>
Pubkey of the token Mint to query, as base-58 encoded string
</Parameter>
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
optional={true}
href="/api/http#configuring-state-commitment"
></Field>
</Parameter>
### Result:
The result will be an RpcResponse JSON object with `value` equal to an array of JSON objects containing:
- `address: <string>` - the address of the token account
- `amount: <string>` - the raw token account balance without decimals, a string representation of u64
- `decimals: <u8>` - number of base 10 digits to the right of the decimal place
- `uiAmount: <number|null>` - the token account balance, using mint-prescribed decimals **DEPRECATED**
- `uiAmountString: <string>` - the token account balance as a string, using mint-prescribed decimals
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,88 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## getTokenSupply
Returns the total supply of an SPL Token type.
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"string"} required={true}>
Pubkey of the token Mint to query, as base-58 encoded string
</Parameter>
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
optional={true}
href="/api/http#configuring-state-commitment"
></Field>
</Parameter>
### Result:
The result will be an RpcResponse JSON object with `value` equal to a JSON object containing:
- `amount: <string>` - the raw total token supply without decimals, a string representation of u64
- `decimals: <u8>` - number of base 10 digits to the right of the decimal place
- `uiAmount: <number|null>` - the total token supply, using mint-prescribed decimals **DEPRECATED**
- `uiAmountString: <string>` - the total token supply as a string, using mint-prescribed decimals
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,172 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## getTransaction
Returns transaction details for a confirmed transaction
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"string"} required={true}>
Transaction signature, as base-58 encoded string
</Parameter>
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
optional={true}
href="/api/http#configuring-state-commitment"
></Field>
<Field name="maxSupportedTransactionVersion" type="number" optional={true}>
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.
</Field>
<Field name="encoding" type="string" defaultValue="json" optional={true} href="/api/http#parsed-responses">
Encoding for the returned Transaction
<Values values={["json", "jsonParsed", "base64", "base58"]} />
<details>
- `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).
</details>
</Field>
</Parameter>
### Result:
- `<null>` - if transaction is not found or not confirmed
- `<object>` - if transaction is confirmed, an object with the following fields:
- `slot: <u64>` - the slot this transaction was processed in
- `transaction: <object|[string,encoding]>` - [Transaction](#transaction-structure) object, either in JSON format or encoded binary data, depending on encoding parameter
- `blockTime: <i64|null>` - estimated production time, as Unix timestamp (seconds since the Unix epoch) of when the transaction was processed. null if not available
- `meta: <object|null>` - transaction status metadata object:
- `err: <object|null>` - 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: <u64>` - fee this transaction was charged, as u64 integer
- `preBalances: <array>` - array of u64 account balances from before the transaction was processed
- `postBalances: <array>` - array of u64 account balances after the transaction was processed
- `innerInstructions: <array|null>` - List of [inner instructions](#inner-instructions-structure) or `null` if inner instruction recording was not enabled during this transaction
- `preTokenBalances: <array|undefined>` - 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: <array|undefined>` - 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|null>` - array of string log messages or `null` if log message recording was not enabled during this transaction
- DEPRECATED: `status: <object>` - Transaction status
- `"Ok": <null>` - Transaction was successful
- `"Err": <ERR>` - Transaction failed with TransactionError
- `rewards: <array|null>` - transaction-level rewards, populated if rewards are requested; an array of JSON objects containing:
- `pubkey: <string>` - The public key, as base-58 encoded string, of the account that received the reward
- `lamports: <i64>`- number of reward lamports credited or debited by the account, as a i64
- `postBalance: <u64>` - account balance in lamports after the reward was applied
- `rewardType: <string>` - type of reward: currently only "rent", other types may be added in the future
- `commission: <u8|undefined>` - vote account commission when the reward was credited, only present for voting and staking rewards
- `loadedAddresses: <object|undefined>` - Transaction addresses loaded from address lookup tables. Undefined if `maxSupportedTransactionVersion` is not set in request params.
- `writable: <array[string]>` - Ordered list of base-58 encoded addresses for writable loaded accounts
- `readonly: <array[string]>` - Ordered list of base-58 encoded addresses for readonly loaded accounts
- `returnData: <object|undefined>` - the most-recent return data generated by an instruction in the transaction, with the following fields:
- `programId: <string>` - 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: <u64|undefined>` - 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.
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,63 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## getTransactionCount
Returns the current Transaction count from the ledger
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
optional={true}
href="/api/http#configuring-state-commitment"
></Field>
<Field name="minContextSlot" type="number" optional={true}>
The minimum slot that the request can be evaluated at
</Field>
</Parameter>
### Result:
`<u64>` - the current Transaction count from the ledger
</CodeParams>
<CodeSnippets>
### 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 }
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,51 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## getVersion
Returns the current Solana version running on the node
<DocSideBySide>
<CodeParams>
### 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
</CodeParams>
<CodeSnippets>
### 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 }
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,114 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## getVoteAccounts
Returns the account info and associated stake for all the voting accounts in the current bank.
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
optional={true}
href="/api/http#configuring-state-commitment"
></Field>
<Field name="votePubkey" type="string" optional={true}>
Only return results for this validator vote address (base-58 encoded)
</Field>
<Field name="keepUnstakedDelinquents" type="bool" optional={true}>
Do not filter out delinquent validators with no stake
</Field>
<Field name="delinquentSlotDistance" type="u64" optional={true}>
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._
</Field>
</Parameter>
### 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: <string>` - Vote account address, as base-58 encoded string
- `nodePubkey: <string>` - Validator identity, as base-58 encoded string
- `activatedStake: <u64>` - the stake, in lamports, delegated to this vote account and active in this epoch
- `epochVoteAccount: <bool>` - bool, whether the vote account is staked for this epoch
- `commission: <number>` - percentage (0-100) of rewards payout owed to the vote account
- `lastVote: <u64>` - Most recent slot voted on by this vote account
- `epochCredits: <array>` - Latest history of earned credits for up to five epochs, as an array of arrays containing: `[epoch, credits, previousCredits]`.
- `rootSlot: <u64>` - Current root slot for this vote account
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,89 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## 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
:::
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"string"} required={true}>
the blockhash of the block to evauluate, as base-58 encoded string
</Parameter>
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
optional={true}
href="/api/http#configuring-state-commitment"
></Field>
<Field name="minContextSlot" type="number" optional={true}>
The minimum slot that the request can be evaluated at
</Field>
</Parameter>
### Result:
`<bool>` - `true` if the blockhash is still valid
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,52 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## 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
:::
<DocSideBySide>
<CodeParams>
### Parameters:
**None**
### Result:
`u64` - Minimum ledger slot number
</CodeParams>
<CodeSnippets>
### 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 }
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,78 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## requestAirdrop
Requests an airdrop of lamports to a Pubkey
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"string"} required={true}>
Pubkey of account to receive lamports, as a base-58 encoded string
</Parameter>
<Parameter type={"integer"} required={true}>
lamports to airdrop, as a "u64"
</Parameter>
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
optional={true}
href="/api/http#configuring-state-commitment"
></Field>
</Parameter>
### Result:
`<string>` - Transaction Signature of the airdrop, as a base-58 encoded string
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,124 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## 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.
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"string"} required={true}>
Fully-signed Transaction, as encoded string.
</Parameter>
<Parameter type={"object"} optional={true}>
Configuration object containing the following optional fields:
<Field name="encoding" type="string" defaultValue="base58" href="/api/http#parsed-responses">
Encoding used for the transaction data.
Values: `base58` (_slow_, **DEPRECATED**), or `base64`.
</Field>
<Field name="skipPreflight" type="bool" defaultValue="false">
if "true", skip the preflight transaction checks
</Field>
<Field
name="preflightCommitment"
type="string"
href="/api/http#configuring-state-commitment"
defaultValue="finalized"
>
Commitment level to use for preflight.
</Field>
<Field name="maxRetries" type="usize">
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.
</Field>
<Field name="minContextSlot" type="number">
set the minimum slot at which to perform preflight transaction checks
</Field>
</Parameter>
### Result:
`<string>` - First Transaction Signature embedded in the transaction, as base-58 encoded string ([transaction id](../../terminology.md#transaction-id))
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,174 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## simulateTransaction
Simulate sending a transaction
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"string"} required={true}>
Transaction, as an encoded string.
:::note
The transaction must have a valid blockhash, but is not required to be signed.
:::
</Parameter>
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
defaultValue="finalized"
optional={true}
href="/api/http#configuring-state-commitment"
>
Commitment level to simulate the transaction at
</Field>
<Field name="sigVerify" type="bool" optional={true} defaultValue={false}>
if `true` the transaction signatures will be verified (conflicts with
`replaceRecentBlockhash`)
</Field>
<Field
name="replaceRecentBlockhash"
type="bool"
optional={true}
defaultValue={false}
>
if `true` the transaction recent blockhash will be replaced with the most
recent blockhash. (conflicts with `sigVerify`)
</Field>
<Field name="minContextSlot" type="number" optional={true}>
the minimum slot that the request can be evaluated at
</Field>
<Field name="encoding" type="string" defaultValue="base58" optional={true}>
Encoding used for the transaction data.
Values: `base58` (_slow_, **DEPRECATED**), or `base64`.
</Field>
<Field name="accounts" type={"object"} optional={true}>
Accounts configuration object containing the following fields:
<Field name="addresses" type="array">
An `array` of accounts to return, as base-58 encoded strings
</Field>
<Field name="encoding" type="string" defaultValue="base64">
encoding for returned Account data
<Values values={["base64", "base58", "base64+zstd", "jsonParsed"]} />
<details>
- `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`.
</details>
</Field>
</Field>
</Parameter>
### Result:
The result will be an RpcResponse JSON object with `value` set to a JSON object with the following fields:
- `err: <object|string|null>` - 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|null>` - 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|null>` - array of accounts with the same length as the `accounts.addresses` array in the request
- `<null>` - if the account doesn't exist or if `err` is not null
- `<object>` - otherwise, a JSON object containing:
- `lamports: <u64>` - number of lamports assigned to this account, as a u64
- `owner: <string>` - 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 `{<program>: <state>}` - depending on encoding parameter
- `executable: <bool>` - boolean indicating if the account contains a program \(and is strictly read-only\)
- `rentEpoch: <u64>` - the epoch at which this account will next owe rent, as u64
- `unitsConsumed: <u64|undefined>` - The number of compute budget units consumed during the processing of this transaction
- `returnData: <object|null>` - the most-recent return data generated by an instruction in the transaction, with the following fields:
- `programId: <string>` - 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
</CodeParams>
<CodeSnippets>
### 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
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

91
docs/src/api/websocket.md Normal file
View File

@ -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://<ADDRESS>/`:
- 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"
<AccountSubscribe />
import AccountUnsubscribe from "./websocket/\_accountUnsubscribe.mdx"
<AccountUnsubscribe />
import BlockSubscribe from "./websocket/\_blockSubscribe.mdx"
<BlockSubscribe />
import BlockUnsubscribe from "./websocket/\_blockUnsubscribe.mdx"
<BlockUnsubscribe />
import LogsSubscribe from "./websocket/\_logsSubscribe.mdx"
<LogsSubscribe />
import LogsUnsubscribe from "./websocket/\_logsUnsubscribe.mdx"
<LogsUnsubscribe />
import ProgramSubscribe from "./websocket/\_programSubscribe.mdx"
<ProgramSubscribe />
import ProgramUnsubscribe from "./websocket/\_programUnsubscribe.mdx"
<ProgramUnsubscribe />
import SignatureSubscribe from "./websocket/\_signatureSubscribe.mdx"
<SignatureSubscribe />
import SignatureUnsubscribe from "./websocket/\_signatureUnsubscribe.mdx"
<SignatureUnsubscribe />
import SlotSubscribe from "./websocket/\_slotSubscribe.mdx"
<SlotSubscribe />
import SlotUnsubscribe from "./websocket/\_slotUnsubscribe.mdx"
<SlotUnsubscribe />
import SlotsUpdatesSubscribe from "./websocket/\_slotsUpdatesSubscribe.mdx"
<SlotsUpdatesSubscribe />
import SlotsUpdatesUnsubscribe from "./websocket/\_slotsUpdatesUnsubscribe.mdx"
<SlotsUpdatesUnsubscribe />
import RootSubscribe from "./websocket/\_rootSubscribe.mdx"
<RootSubscribe />
import RootUnsubscribe from "./websocket/\_rootUnsubscribe.mdx"
<RootUnsubscribe />
import VoteSubscribe from "./websocket/\_voteSubscribe.mdx"
<VoteSubscribe />
import VoteUnsubscribe from "./websocket/\_voteUnsubscribe.mdx"
<VoteUnsubscribe />

View File

@ -0,0 +1,160 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## accountSubscribe
Subscribe to an account to receive notifications when the lamports or data for a given account public key changes
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"string"} required={true}>
Account Pubkey, as base-58 encoded string
</Parameter>
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
optional={true}
href="/api/http#configuring-state-commitment"
></Field>
<Field name="encoding" type="string" optional={true} href="/api/http#parsed-responses">
Encoding format for Account data
<Values values={["base58", "base64", "base64+zstd", "jsonParsed"]} />
<details>
- `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`.
</details>
</Field>
</Parameter>
### Result:
`<number>` - Subscription id \(needed to unsubscribe\)
</CodeParams>
<CodeSnippets>
### 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 }
```
</CodeSnippets>
</DocSideBySide>
#### 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
}
}
```
</DocBlock>

View File

@ -0,0 +1,53 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## accountUnsubscribe
Unsubscribe from account change notifications
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"number"} required={true}>
id of the account Subscription to cancel
</Parameter>
### Result:
`<bool>` - unsubscribe success message
</CodeParams>
<CodeSnippets>
### Code sample:
```json
{
"jsonrpc": "2.0",
"id": 1,
"method": "accountUnsubscribe",
"params": [0]
}
```
### Response:
```json
{ "jsonrpc": "2.0", "result": true, "id": 1 }
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,342 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## 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**
:::
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter name="filter" type={"string | object"} optional={true}>
filter criteria for the logs to receive results by account type; currently supported:
<Field type="string" value="all">
<code>all</code> - include all transactions in block
</Field>
<Field type="object">
A JSON object with the following field:
- `mentionsAccountOrProgram: <string>` - 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.
</Field>
</Parameter>
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
optional={true}
href="/api/http#configuring-state-commitment"
></Field>
<Field name="transactionDetails" default="full" type="string" optional={true}>
level of transaction detail to return, either "full", "signatures", or "none".
</Field>
<Field name="showRewards" type="bool" defaultValue="true" optional={true}>
whether to populate the `rewards` array.
</Field>
<Field name="encoding" type="string" defaultValue="base64" optional={true} href="/api/http#parsed-responses">
Encoding format for Account data
<Values values={["base58", "base64", "base64+zstd", "jsonParsed"]} />
<details>
- `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`.
</details>
</Field>
</Parameter>
### Result:
`integer` - subscription id \(needed to unsubscribe\)
</CodeParams>
<CodeSnippets>
### 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 }
```
</CodeSnippets>
</DocSideBySide>
#### Notification Format:
The notification will be an object with the following fields:
- `slot: <u64>` - The corresponding slot.
- `err: <object|null>` - Error if something went wrong publishing the notification otherwise null.
- `block: <object|null>` - 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
}
}
```
</DocBlock>

View File

@ -0,0 +1,53 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## blockUnsubscribe
Unsubscribe from block notifications
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"integer"} required={true}>
subscription id to cancel
</Parameter>
### Result:
`<bool>` - unsubscribe success message
</CodeParams>
<CodeSnippets>
### Code sample:
```json
{
"jsonrpc": "2.0",
"id": 1,
"method": "blockUnsubscribe",
"params": [0]
}
```
### Response:
```json
{ "jsonrpc": "2.0", "result": true, "id": 1 }
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,130 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## logsSubscribe
Subscribe to transaction logging
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter name="filter" type={"string | object"} required={true}>
filter criteria for the logs to receive results by account type. The following filters types are currently supported:
<Field type="string">
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
</Field>
<Field type="object">
An object with the following field:
- `mentions: [ <string> ]` - array of Pubkeys (as base-58 encoded strings) to listen for being mentioned in any transaction
</Field>
</Parameter>
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
optional={true}
href="/api/http#configuring-state-commitment"
></Field>
</Parameter>
### Result:
`<integer>` - Subscription id \(needed to unsubscribe\)
</CodeParams>
<CodeSnippets>
### 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 }
```
</CodeSnippets>
</DocSideBySide>
#### Notification Format:
The notification will be an RpcResponse JSON object with value equal to:
- `signature: <string>` - The transaction signature base58 encoded.
- `err: <object|null>` - 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|null>` - 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
}
}
```
</DocBlock>

View File

@ -0,0 +1,53 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## logsUnsubscribe
Unsubscribe from transaction logging
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"integer"} required={true}>
subscription id to cancel
</Parameter>
### Result:
`<bool>` - unsubscribe success message
</CodeParams>
<CodeSnippets>
### Code sample:
```json
{
"jsonrpc": "2.0",
"id": 1,
"method": "logsUnsubscribe",
"params": [0]
}
```
### Response:
```json
{ "jsonrpc": "2.0", "result": true, "id": 1 }
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,205 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## programSubscribe
Subscribe to a program to receive notifications when the lamports or data for an account owned by the given program changes
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"string"} required={true}>
Pubkey of the `program_id`, as base-58 encoded string
</Parameter>
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
optional={true}
href="/api/http#configuring-state-commitment"
></Field>
<Field name="filters" type="array" optional={true} href={"/api/http#filter-criteria"}>
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
:::
</Field>
<Field name="encoding" type="string" optional={true} href="/api/http#parsed-responses">
Encoding format for Account data
<Values values={["base58", "base64", "base64+zstd", "jsonParsed"]} />
<details>
- `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`.
</details>
</Field>
</Parameter>
### Result:
`<integer>` - Subscription id \(needed to unsubscribe\)
</CodeParams>
<CodeSnippets>
### 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 }
```
</CodeSnippets>
</DocSideBySide>
#### Notification format
The notification format is a <b>single</b> 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
}
}
```
</DocBlock>

View File

@ -0,0 +1,53 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## programUnsubscribe
Unsubscribe from program-owned account change notifications
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"number"} required={true}>
id of account Subscription to cancel
</Parameter>
### Result:
`<bool>` - unsubscribe success message
</CodeParams>
<CodeSnippets>
### Code sample:
```json
{
"jsonrpc": "2.0",
"id": 1,
"method": "programUnsubscribe",
"params": [0]
}
```
### Response:
```json
{ "jsonrpc": "2.0", "result": true, "id": 1 }
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,62 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## rootSubscribe
Subscribe to receive notification anytime a new root is set by the validator.
<DocSideBySide>
<CodeParams>
### Parameters:
**None**
### Result:
`integer` - subscription id \(needed to unsubscribe\)
</CodeParams>
<CodeSnippets>
### Code sample:
```json
{ "jsonrpc": "2.0", "id": 1, "method": "rootSubscribe" }
```
### Response:
```json
{ "jsonrpc": "2.0", "result": 0, "id": 1 }
```
</CodeSnippets>
</DocSideBySide>
#### Notification Format:
The result is the latest root slot number.
```json
{
"jsonrpc": "2.0",
"method": "rootNotification",
"params": {
"result": 42,
"subscription": 0
}
}
```
</DocBlock>

View File

@ -0,0 +1,53 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## rootUnsubscribe
Unsubscribe from root notifications
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"number"} required={true}>
subscription id to cancel
</Parameter>
### Result:
`<bool>` - unsubscribe success message
</CodeParams>
<CodeSnippets>
### Code sample:
```json
{
"jsonrpc": "2.0",
"id": 1,
"method": "rootUnsubscribe",
"params": [0]
}
```
### Response:
```json
{ "jsonrpc": "2.0", "result": true, "id": 1 }
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,98 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## signatureSubscribe
Subscribe to a transaction signature to receive notification when a given transaction is committed. On `signatureNotification` - the subscription is automatically cancelled.
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"string"} required={true}>
Transaction Signature, as base-58 encoded string
</Parameter>
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
optional={true}
href="/api/http#configuring-state-commitment"
></Field>
</Parameter>
### Result:
`<integer>` - subscription id (needed to unsubscribe)
</CodeParams>
<CodeSnippets>
### Code sample:
```json
{
"jsonrpc": "2.0",
"id": 1,
"method": "signatureSubscribe",
"params": [
"2EBVM6cB8vAAD93Ktr6Vd8p67XPbQzCJX47MpReuiCXJAtcjaxpvWpcg9Ege1Nr5Tk3a2GFrByT7WPBjdsTycY9b",
{
"commitment": "finalized"
}
]
}
```
### Response:
```json
{ "jsonrpc": "2.0", "result": 0, "id": 1 }
```
</CodeSnippets>
</DocSideBySide>
#### Notification Format:
The notification will be an RpcResponse JSON object with value containing an object with:
- `err: <object|null>` - 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
}
}
```
</DocBlock>

View File

@ -0,0 +1,53 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## signatureUnsubscribe
Unsubscribe from signature confirmation notification
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"number"} required={true}>
subscription id to cancel
</Parameter>
### Result:
`<bool>` - unsubscribe success message
</CodeParams>
<CodeSnippets>
### Code sample:
```json
{
"jsonrpc": "2.0",
"id": 1,
"method": "signatureUnsubscribe",
"params": [0]
}
```
### Response:
```json
{ "jsonrpc": "2.0", "result": true, "id": 1 }
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,72 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## slotSubscribe
Subscribe to receive notification anytime a slot is processed by the validator
<DocSideBySide>
<CodeParams>
### Parameters:
**None**
### Result:
`<integer>` - Subscription id \(needed to unsubscribe\)
</CodeParams>
<CodeSnippets>
### Code sample:
```json
{ "jsonrpc": "2.0", "id": 1, "method": "slotSubscribe" }
```
### Response:
```json
{ "jsonrpc": "2.0", "result": 0, "id": 1 }
```
</CodeSnippets>
</DocSideBySide>
#### Notification Format:
The notification will be an object with the following fields:
- `parent: <u64>` - The parent slot
- `root: <u64>` - The current root slot
- `slot: <u64>` - The newly set slot value
Example:
```json
{
"jsonrpc": "2.0",
"method": "slotNotification",
"params": {
"result": {
"parent": 75,
"root": 44,
"slot": 76
},
"subscription": 0
}
}
```
</DocBlock>

View File

@ -0,0 +1,53 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## slotUnsubscribe
Unsubscribe from slot notifications
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"integer"} required={true}>
subscription id to cancel
</Parameter>
### Result:
`<bool>` - unsubscribe success message
</CodeParams>
<CodeSnippets>
### Code sample:
```json
{
"jsonrpc": "2.0",
"id": 1,
"method": "slotUnsubscribe",
"params": [0]
}
```
### Response:
```json
{ "jsonrpc": "2.0", "result": true, "id": 1 }
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,86 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## 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**
:::
<DocSideBySide>
<CodeParams>
### Parameters:
**None**
### Result:
`<integer>` - Subscription id (needed to unsubscribe)
</CodeParams>
<CodeSnippets>
### Code sample:
```json
{ "jsonrpc": "2.0", "id": 1, "method": "slotsUpdatesSubscribe" }
```
### Response:
```json
{ "jsonrpc": "2.0", "result": 0, "id": 1 }
```
</CodeSnippets>
</DocSideBySide>
#### Notification Format:
The notification will be an object with the following fields:
- `parent: <u64>` - The parent slot
- `slot: <u64>` - The newly updated slot
- `timestamp: <i64>` - The Unix timestamp of the update
- `type: <string>` - 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
}
}
```
</DocBlock>

View File

@ -0,0 +1,53 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## slotsUpdatesUnsubscribe
Unsubscribe from slot-update notifications
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"number"} required={true}>
subscription id to cancel
</Parameter>
### Result:
`<bool>` - unsubscribe success message
</CodeParams>
<CodeSnippets>
### Code sample:
```json
{
"jsonrpc": "2.0",
"id": 1,
"method": "slotsUpdatesUnsubscribe",
"params": [0]
}
```
### Response:
```json
{ "jsonrpc": "2.0", "result": true, "id": 1 }
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -0,0 +1,79 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## 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
:::
<DocSideBySide>
<CodeParams>
### Parameters:
**None**
### Result:
`<integer>` - subscription id (needed to unsubscribe)
</CodeParams>
<CodeSnippets>
### Code sample:
```json
{ "jsonrpc": "2.0", "id": 1, "method": "voteSubscribe" }
```
### Response:
```json
{ "jsonrpc": "2.0", "result": 0, "id": 1 }
```
</CodeSnippets>
</DocSideBySide>
#### Notification Format:
The notification will be an object with the following fields:
- `hash: <string>` - The vote hash
- `slots: <array>` - The slots covered by the vote, as an array of u64 integers
- `timestamp: <i64|null>` - The timestamp of the vote
- `signature: <string>` - 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
}
}
```
</DocBlock>

View File

@ -0,0 +1,53 @@
import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## voteUnsubscribe
Unsubscribe from vote notifications
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"integer"} required={true}>
subscription id to cancel
</Parameter>
### Result:
`<bool>` - unsubscribe success message
</CodeParams>
<CodeSnippets>
### Code sample:
```json
{
"jsonrpc": "2.0",
"id": 1,
"method": "voteUnsubscribe",
"params": [0]
}
```
### Response:
```json
{ "jsonrpc": "2.0", "result": true, "id": 1 }
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>

View File

@ -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.

View File

@ -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/).

View File

@ -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.

File diff suppressed because it is too large Load Diff

View File

@ -19,7 +19,7 @@ Some important crates:
that do not run on-chain will import this.
- [`solana-client`] &mdash; For interacting with a Solana node via the
[JSON RPC API](jsonrpc-api).
[JSON RPC API](/api).
- [`solana-cli-config`] &mdash; Loading and saving the Solana CLI configuration
file.

View File

@ -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.

View File

@ -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.

View File

@ -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:

View File

@ -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 <FEATURE_PUBKEY_1> --deactivate-feature <FEATURE_PUBKEY_2>
```
```

View File

@ -114,7 +114,7 @@ One minute is not a lot of time considering that a client needs to fetch a recen
Given the short expiration time frame, its 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`](./clients/jsonrpc-api#getlatestblockhash). By default, this API uses the `"finalized"` commitment level to return the most recently finalized blocks blockhash. However, you can override this behavior by [setting the `commitment` parameter](./clients/jsonrpc-api#configuring-state-commitment) to a different commitment level.
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 blocks blockhash. However, you can override this behavior by [setting the `commitment` parameter](/api/http#configuring-state-commitment) to a different commitment level.
**Recommendation**
@ -145,7 +145,7 @@ When your application uses an RPC pool service or when the RPC endpoint differs
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 transactions expiration properly.
For `simulateTransaction` requests, clients should use the [`replaceRecentBlockhash`](./clients/jsonrpc-api#simulatetransaction) parameter to tell the RPC node to replace the simulated transactions blockhash with a blockhash that will always be valid for simulation.
For `simulateTransaction` requests, clients should use the [`replaceRecentBlockhash`](/api/http#simulatetransaction) parameter to tell the RPC node to replace the simulated transactions blockhash with a blockhash that will always be valid for simulation.
### Avoid reusing stale blockhashes
@ -169,16 +169,16 @@ Lagging RPC nodes can therefore respond to blockhash requests with blockhashes t
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 nodes highest processed slot by using the [`getSlot`](./clients/jsonrpc-api#getslot) RPC API with the `"processed"` commitment level and then call the [`getMaxShredInsertSlot](./clients/jsonrpc-api#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](./clients/jsonrpc-api#rpcresponse-structure).
1. Fetch your RPC nodes 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`](./clients/jsonrpc-api#getlatestblockhash) RPC API to get a recent blockhash for your transaction, take note of the `"lastValidBlockHeight"` in the response.
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`](./clients/jsonrpc-api#getblockheight) RPC API with the “confirmed” commitment level until it returns a block height greater than the previously returned last valid block height.
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

View File

@ -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)

View File

@ -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

View File

@ -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:

Some files were not shown because too many files have changed in this diff Show More