Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

[docs] new JSON RPC API docs format #29772

Merged
merged 28 commits into from
Jan 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
5e9f064
feat: added api page
nickfrosty Jan 18, 2023
5814b53
fix: api redirects
nickfrosty Jan 18, 2023
83cba29
feat: websocket page and partials
nickfrosty Jan 18, 2023
edba51e
feat: deprectated partials
nickfrosty Jan 18, 2023
4f1b1a2
feat: http method partials
nickfrosty Jan 18, 2023
51855f3
fix: more deprecated partials
nickfrosty Jan 18, 2023
1e4d613
feat: codeblock component and styles
nickfrosty Jan 18, 2023
6a796bf
feat: api http methods page
nickfrosty Jan 18, 2023
d79916e
feat: sidebar
nickfrosty Jan 18, 2023
54ba3dc
refactor: proposal api links
nickfrosty Jan 18, 2023
b122c22
refactor: internal linking
nickfrosty Jan 18, 2023
12fdc5e
refactor: more internal links
nickfrosty Jan 19, 2023
8c68391
refactor: internal link and note cards
nickfrosty Jan 19, 2023
010bd0e
refactor: local links
nickfrosty Jan 19, 2023
a2737e0
refactor: local links and auto save prettier
nickfrosty Jan 19, 2023
461cb58
feat: added numNonVoteTransaction data details
nickfrosty Jan 19, 2023
28d57b1
fix: updated getRecentPrioritizationFees
nickfrosty Jan 19, 2023
be42a34
fix: corrected wording
nickfrosty Jan 19, 2023
ee27822
fix: version typo
nickfrosty Jan 19, 2023
a980a4f
fix: commitment links
nickfrosty Jan 20, 2023
9cee329
fix: parsed response links
nickfrosty Jan 20, 2023
a48d69c
fix: dangling links
nickfrosty Jan 20, 2023
f0aa669
refactor: filter criteria
nickfrosty Jan 20, 2023
0694934
docs: removed jsonrpc-api.md file
nickfrosty Jan 20, 2023
4ea088e
fix: dangling links
nickfrosty Jan 20, 2023
8f2c048
style: removed whitespaces for CI
nickfrosty Jan 24, 2023
ae21cd1
style: removed whitespace
nickfrosty Jan 25, 2023
09e48e9
style: fixed whitespaces
nickfrosty Jan 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: more deprecated partials
  • Loading branch information
nickfrosty committed Jan 18, 2023
commit 51855f3bb2dcdc90e7c84d5b77a7395ca6ce2589
168 changes: 168 additions & 0 deletions docs/src/api/deprecated/_getConfirmedBlock.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
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#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#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>
86 changes: 86 additions & 0 deletions docs/src/api/deprecated/_getRecentBlockhash.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
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#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>