From 37afa00ffbe7b36088fedac3a151f45cc1fc7b77 Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Tue, 13 Apr 2021 01:50:15 -0600 Subject: [PATCH] Rpc: deprecate getConfirmed endpoints (#16502) * Deprecate getConfirmed methods in rpc * Add new methods to docs * Move deprecated rpc methods to separate docs section * Add note to docs about removal timing --- core/src/rpc.rs | 269 +++-- core/src/rpc_service.rs | 3 +- docs/src/developing/clients/jsonrpc-api.md | 1167 ++++++++++++++------ 3 files changed, 1039 insertions(+), 400 deletions(-) diff --git a/core/src/rpc.rs b/core/src/rpc.rs index ca930e5f75..1298e3e716 100644 --- a/core/src/rpc.rs +++ b/core/src/rpc.rs @@ -415,17 +415,16 @@ impl JsonRpcRequestProcessor { } let first_confirmed_block_in_epoch = *self - .get_confirmed_blocks_with_limit(first_slot_in_epoch, 1, config.commitment)? + .get_blocks_with_limit(first_slot_in_epoch, 1, config.commitment)? .get(0) .ok_or(RpcCustomError::BlockNotAvailable { slot: first_slot_in_epoch, })?; - let first_confirmed_block = if let Ok(Some(first_confirmed_block)) = self - .get_confirmed_block( - first_confirmed_block_in_epoch, - Some(RpcConfirmedBlockConfig::rewards_with_commitment(config.commitment).into()), - ) { + let first_confirmed_block = if let Ok(Some(first_confirmed_block)) = self.get_block( + first_confirmed_block_in_epoch, + Some(RpcConfirmedBlockConfig::rewards_with_commitment(config.commitment).into()), + ) { first_confirmed_block } else { return Err(RpcCustomError::BlockNotAvailable { @@ -815,7 +814,7 @@ impl JsonRpcRequestProcessor { Ok(()) } - pub fn get_confirmed_block( + pub fn get_block( &self, slot: Slot, config: Option>, @@ -874,7 +873,7 @@ impl JsonRpcRequestProcessor { Err(RpcCustomError::BlockNotAvailable { slot }.into()) } - pub fn get_confirmed_blocks( + pub fn get_blocks( &self, start_slot: Slot, end_slot: Option, @@ -955,7 +954,7 @@ impl JsonRpcRequestProcessor { Ok(blocks) } - pub fn get_confirmed_blocks_with_limit( + pub fn get_blocks_with_limit( &self, start_slot: Slot, limit: usize, @@ -1169,7 +1168,7 @@ impl JsonRpcRequestProcessor { }) } - pub fn get_confirmed_transaction( + pub fn get_transaction( &self, signature: Signature, config: Option>, @@ -1253,7 +1252,7 @@ impl JsonRpcRequestProcessor { } } - pub fn get_confirmed_signatures_for_address2( + pub fn get_signatures_for_address( &self, address: Pubkey, mut before: Option, @@ -2393,8 +2392,8 @@ pub mod rpc_full { #[rpc(meta, name = "minimumLedgerSlot")] fn minimum_ledger_slot(&self, meta: Self::Metadata) -> Result; - #[rpc(meta, name = "getConfirmedBlock")] - fn get_confirmed_block( + #[rpc(meta, name = "getBlock")] + fn get_block( &self, meta: Self::Metadata, slot: Slot, @@ -2405,8 +2404,8 @@ pub mod rpc_full { fn get_block_time(&self, meta: Self::Metadata, slot: Slot) -> Result>; - #[rpc(meta, name = "getConfirmedBlocks")] - fn get_confirmed_blocks( + #[rpc(meta, name = "getBlocks")] + fn get_blocks( &self, meta: Self::Metadata, start_slot: Slot, @@ -2414,8 +2413,8 @@ pub mod rpc_full { commitment: Option, ) -> Result>; - #[rpc(meta, name = "getConfirmedBlocksWithLimit")] - fn get_confirmed_blocks_with_limit( + #[rpc(meta, name = "getBlocksWithLimit")] + fn get_blocks_with_limit( &self, meta: Self::Metadata, start_slot: Slot, @@ -2423,16 +2422,16 @@ pub mod rpc_full { commitment: Option, ) -> Result>; - #[rpc(meta, name = "getConfirmedTransaction")] - fn get_confirmed_transaction( + #[rpc(meta, name = "getTransaction")] + fn get_transaction( &self, meta: Self::Metadata, signature_str: String, config: Option>, ) -> Result>; - #[rpc(meta, name = "getConfirmedSignaturesForAddress2")] - fn get_confirmed_signatures_for_address2( + #[rpc(meta, name = "getSignaturesForAddress")] + fn get_signatures_for_address( &self, meta: Self::Metadata, address: String, @@ -2997,17 +2996,17 @@ pub mod rpc_full { meta.minimum_ledger_slot() } - fn get_confirmed_block( + fn get_block( &self, meta: Self::Metadata, slot: Slot, config: Option>, ) -> Result> { - debug!("get_confirmed_block rpc request received: {:?}", slot); - meta.get_confirmed_block(slot, config) + debug!("get_block rpc request received: {:?}", slot); + meta.get_block(slot, config) } - fn get_confirmed_blocks( + fn get_blocks( &self, meta: Self::Metadata, start_slot: Slot, @@ -3017,13 +3016,13 @@ pub mod rpc_full { let (end_slot, maybe_commitment) = config.map(|config| config.unzip()).unwrap_or_default(); debug!( - "get_confirmed_blocks rpc request received: {}-{:?}", + "get_blocks rpc request received: {}-{:?}", start_slot, end_slot ); - meta.get_confirmed_blocks(start_slot, end_slot, commitment.or(maybe_commitment)) + meta.get_blocks(start_slot, end_slot, commitment.or(maybe_commitment)) } - fn get_confirmed_blocks_with_limit( + fn get_blocks_with_limit( &self, meta: Self::Metadata, start_slot: Slot, @@ -3031,10 +3030,10 @@ pub mod rpc_full { commitment: Option, ) -> Result> { debug!( - "get_confirmed_blocks_with_limit rpc request received: {}-{}", + "get_blocks_with_limit rpc request received: {}-{}", start_slot, limit, ); - meta.get_confirmed_blocks_with_limit(start_slot, limit, commitment) + meta.get_blocks_with_limit(start_slot, limit, commitment) } fn get_block_time( @@ -3045,21 +3044,18 @@ pub mod rpc_full { meta.get_block_time(slot) } - fn get_confirmed_transaction( + fn get_transaction( &self, meta: Self::Metadata, signature_str: String, config: Option>, ) -> Result> { - debug!( - "get_confirmed_transaction rpc request received: {:?}", - signature_str - ); + debug!("get_transaction rpc request received: {:?}", signature_str); let signature = verify_signature(&signature_str)?; - meta.get_confirmed_transaction(signature, config) + meta.get_transaction(signature, config) } - fn get_confirmed_signatures_for_address2( + fn get_signatures_for_address( &self, meta: Self::Metadata, address: String, @@ -3087,13 +3083,7 @@ pub mod rpc_full { ))); } - meta.get_confirmed_signatures_for_address2( - address, - before, - until, - limit, - config.commitment, - ) + meta.get_signatures_for_address(address, before, until, limit, config.commitment) } fn get_first_available_block(&self, meta: Self::Metadata) -> Result { @@ -3207,6 +3197,152 @@ pub mod rpc_full { } } +// Deprecated RPC methods, collected for easy deactivation and removal in v1.8 +pub mod rpc_deprecated_v1_7 { + use super::*; + #[rpc] + pub trait DeprecatedV1_7 { + type Metadata; + + // DEPRECATED + #[rpc(meta, name = "getConfirmedBlock")] + fn get_confirmed_block( + &self, + meta: Self::Metadata, + slot: Slot, + config: Option>, + ) -> Result>; + + // DEPRECATED + #[rpc(meta, name = "getConfirmedBlocks")] + fn get_confirmed_blocks( + &self, + meta: Self::Metadata, + start_slot: Slot, + config: Option, + commitment: Option, + ) -> Result>; + + // DEPRECATED + #[rpc(meta, name = "getConfirmedBlocksWithLimit")] + fn get_confirmed_blocks_with_limit( + &self, + meta: Self::Metadata, + start_slot: Slot, + limit: usize, + commitment: Option, + ) -> Result>; + + // DEPRECATED + #[rpc(meta, name = "getConfirmedTransaction")] + fn get_confirmed_transaction( + &self, + meta: Self::Metadata, + signature_str: String, + config: Option>, + ) -> Result>; + + // DEPRECATED + #[rpc(meta, name = "getConfirmedSignaturesForAddress2")] + fn get_confirmed_signatures_for_address2( + &self, + meta: Self::Metadata, + address: String, + config: Option, + ) -> Result>; + } + + pub struct DeprecatedV1_7Impl; + impl DeprecatedV1_7 for DeprecatedV1_7Impl { + type Metadata = JsonRpcRequestProcessor; + + fn get_confirmed_block( + &self, + meta: Self::Metadata, + slot: Slot, + config: Option>, + ) -> Result> { + debug!("get_confirmed_block rpc request received: {:?}", slot); + meta.get_block(slot, config) + } + + fn get_confirmed_blocks( + &self, + meta: Self::Metadata, + start_slot: Slot, + config: Option, + commitment: Option, + ) -> Result> { + let (end_slot, maybe_commitment) = + config.map(|config| config.unzip()).unwrap_or_default(); + debug!( + "get_confirmed_blocks rpc request received: {}-{:?}", + start_slot, end_slot + ); + meta.get_blocks(start_slot, end_slot, commitment.or(maybe_commitment)) + } + + fn get_confirmed_blocks_with_limit( + &self, + meta: Self::Metadata, + start_slot: Slot, + limit: usize, + commitment: Option, + ) -> Result> { + debug!( + "get_confirmed_blocks_with_limit rpc request received: {}-{}", + start_slot, limit, + ); + meta.get_blocks_with_limit(start_slot, limit, commitment) + } + + fn get_confirmed_transaction( + &self, + meta: Self::Metadata, + signature_str: String, + config: Option>, + ) -> Result> { + debug!( + "get_confirmed_transaction rpc request received: {:?}", + signature_str + ); + let signature = verify_signature(&signature_str)?; + meta.get_transaction(signature, config) + } + + fn get_confirmed_signatures_for_address2( + &self, + meta: Self::Metadata, + address: String, + config: Option, + ) -> Result> { + let address = verify_pubkey(address)?; + + let config = config.unwrap_or_default(); + let before = config + .before + .map(|ref before| verify_signature(before)) + .transpose()?; + let until = config + .until + .map(|ref until| verify_signature(until)) + .transpose()?; + let limit = config + .limit + .unwrap_or(MAX_GET_CONFIRMED_SIGNATURES_FOR_ADDRESS2_LIMIT); + + if limit == 0 || limit > MAX_GET_CONFIRMED_SIGNATURES_FOR_ADDRESS2_LIMIT { + return Err(Error::invalid_params(format!( + "Invalid limit; max {}", + MAX_GET_CONFIRMED_SIGNATURES_FOR_ADDRESS2_LIMIT + ))); + } + + meta.get_signatures_for_address(address, before, until, limit, config.commitment) + } + } +} + // Obsolete RPC methods, collected for easy deactivation and removal pub mod rpc_obsolete_v1_7 { use super::*; @@ -5340,7 +5476,7 @@ pub mod tests { } #[test] - fn test_get_confirmed_block() { + fn test_get_block() { let bob_pubkey = solana_sdk::pubkey::new_rand(); let RpcHandler { io, @@ -5350,7 +5486,7 @@ pub mod tests { .. } = start_rpc_handler_with_tx(&bob_pubkey); - let req = r#"{"jsonrpc":"2.0","id":1,"method":"getConfirmedBlock","params":[0]}"#; + let req = r#"{"jsonrpc":"2.0","id":1,"method":"getBlock","params":[0]}"#; let res = io.handle_request_sync(&req, meta.clone()); let result: Value = serde_json::from_str(&res.expect("actual response")) .expect("actual response deserialization"); @@ -5395,7 +5531,7 @@ pub mod tests { } } - let req = r#"{"jsonrpc":"2.0","id":1,"method":"getConfirmedBlock","params":[0,"binary"]}"#; + let req = r#"{"jsonrpc":"2.0","id":1,"method":"getBlock","params":[0,"binary"]}"#; let res = io.handle_request_sync(&req, meta); let result: Value = serde_json::from_str(&res.expect("actual response")) .expect("actual response deserialization"); @@ -5440,7 +5576,7 @@ pub mod tests { } #[test] - fn test_get_confirmed_block_config() { + fn test_get_block_config() { let bob_pubkey = solana_sdk::pubkey::new_rand(); let RpcHandler { io, @@ -5450,7 +5586,7 @@ pub mod tests { } = start_rpc_handler_with_tx(&bob_pubkey); let req = format!( - r#"{{"jsonrpc":"2.0","id":1,"method":"getConfirmedBlock","params":[0,{}]}}"#, + r#"{{"jsonrpc":"2.0","id":1,"method":"getBlock","params":[0,{}]}}"#, json!(RpcConfirmedBlockConfig { encoding: None, transaction_details: Some(TransactionDetails::Signatures), @@ -5471,7 +5607,7 @@ pub mod tests { } let req = format!( - r#"{{"jsonrpc":"2.0","id":1,"method":"getConfirmedBlock","params":[0,{}]}}"#, + r#"{{"jsonrpc":"2.0","id":1,"method":"getBlock","params":[0,{}]}}"#, json!(RpcConfirmedBlockConfig { encoding: None, transaction_details: Some(TransactionDetails::None), @@ -5491,7 +5627,7 @@ pub mod tests { } #[test] - fn test_get_confirmed_blocks() { + fn test_get_blocks() { let bob_pubkey = solana_sdk::pubkey::new_rand(); let roots = vec![0, 1, 3, 4, 8]; let RpcHandler { @@ -5505,35 +5641,35 @@ pub mod tests { .unwrap() .set_highest_confirmed_root(8); - let req = r#"{"jsonrpc":"2.0","id":1,"method":"getConfirmedBlocks","params":[0]}"#; + let req = r#"{"jsonrpc":"2.0","id":1,"method":"getBlocks","params":[0]}"#; let res = io.handle_request_sync(&req, meta.clone()); let result: Value = serde_json::from_str(&res.expect("actual response")) .expect("actual response deserialization"); let confirmed_blocks: Vec = serde_json::from_value(result["result"].clone()).unwrap(); assert_eq!(confirmed_blocks, roots[1..].to_vec()); - let req = r#"{"jsonrpc":"2.0","id":1,"method":"getConfirmedBlocks","params":[2]}"#; + let req = r#"{"jsonrpc":"2.0","id":1,"method":"getBlocks","params":[2]}"#; let res = io.handle_request_sync(&req, meta.clone()); let result: Value = serde_json::from_str(&res.expect("actual response")) .expect("actual response deserialization"); let confirmed_blocks: Vec = serde_json::from_value(result["result"].clone()).unwrap(); assert_eq!(confirmed_blocks, vec![3, 4, 8]); - let req = r#"{"jsonrpc":"2.0","id":1,"method":"getConfirmedBlocks","params":[0,4]}"#; + let req = r#"{"jsonrpc":"2.0","id":1,"method":"getBlocks","params":[0,4]}"#; let res = io.handle_request_sync(&req, meta.clone()); let result: Value = serde_json::from_str(&res.expect("actual response")) .expect("actual response deserialization"); let confirmed_blocks: Vec = serde_json::from_value(result["result"].clone()).unwrap(); assert_eq!(confirmed_blocks, vec![1, 3, 4]); - let req = r#"{"jsonrpc":"2.0","id":1,"method":"getConfirmedBlocks","params":[0,7]}"#; + let req = r#"{"jsonrpc":"2.0","id":1,"method":"getBlocks","params":[0,7]}"#; let res = io.handle_request_sync(&req, meta.clone()); let result: Value = serde_json::from_str(&res.expect("actual response")) .expect("actual response deserialization"); let confirmed_blocks: Vec = serde_json::from_value(result["result"].clone()).unwrap(); assert_eq!(confirmed_blocks, vec![1, 3, 4]); - let req = r#"{"jsonrpc":"2.0","id":1,"method":"getConfirmedBlocks","params":[9,11]}"#; + let req = r#"{"jsonrpc":"2.0","id":1,"method":"getBlocks","params":[9,11]}"#; let res = io.handle_request_sync(&req, meta.clone()); let result: Value = serde_json::from_str(&res.expect("actual response")) .expect("actual response deserialization"); @@ -5545,7 +5681,7 @@ pub mod tests { .unwrap() .set_highest_confirmed_root(std::u64::MAX); let req = format!( - r#"{{"jsonrpc":"2.0","id":1,"method":"getConfirmedBlocks","params":[0,{}]}}"#, + r#"{{"jsonrpc":"2.0","id":1,"method":"getBlocks","params":[0,{}]}}"#, MAX_GET_CONFIRMED_BLOCKS_RANGE ); let res = io.handle_request_sync(&req, meta.clone()); @@ -5555,7 +5691,7 @@ pub mod tests { assert_eq!(confirmed_blocks, vec![1, 3, 4, 8]); let req = format!( - r#"{{"jsonrpc":"2.0","id":1,"method":"getConfirmedBlocks","params":[0,{}]}}"#, + r#"{{"jsonrpc":"2.0","id":1,"method":"getBlocks","params":[0,{}]}}"#, MAX_GET_CONFIRMED_BLOCKS_RANGE + 1 ); let res = io.handle_request_sync(&req, meta); @@ -5568,7 +5704,7 @@ pub mod tests { } #[test] - fn test_get_confirmed_blocks_with_limit() { + fn test_get_blocks_with_limit() { let bob_pubkey = solana_sdk::pubkey::new_rand(); let roots = vec![0, 1, 3, 4, 8]; let RpcHandler { @@ -5582,7 +5718,7 @@ pub mod tests { .unwrap() .set_highest_confirmed_root(8); - let req = r#"{"jsonrpc":"2.0","id":1,"method":"getConfirmedBlocksWithLimit","params":[0,500001]}"#; + let req = r#"{"jsonrpc":"2.0","id":1,"method":"getBlocksWithLimit","params":[0,500001]}"#; let res = io.handle_request_sync(&req, meta.clone()); assert_eq!( res, @@ -5591,38 +5727,35 @@ pub mod tests { ) ); - let req = - r#"{"jsonrpc":"2.0","id":1,"method":"getConfirmedBlocksWithLimit","params":[0,0]}"#; + let req = r#"{"jsonrpc":"2.0","id":1,"method":"getBlocksWithLimit","params":[0,0]}"#; let res = io.handle_request_sync(&req, meta.clone()); let result: Value = serde_json::from_str(&res.expect("actual response")) .expect("actual response deserialization"); let confirmed_blocks: Vec = serde_json::from_value(result["result"].clone()).unwrap(); assert!(confirmed_blocks.is_empty()); - let req = - r#"{"jsonrpc":"2.0","id":1,"method":"getConfirmedBlocksWithLimit","params":[2,2]}"#; + let req = r#"{"jsonrpc":"2.0","id":1,"method":"getBlocksWithLimit","params":[2,2]}"#; let res = io.handle_request_sync(&req, meta.clone()); let result: Value = serde_json::from_str(&res.expect("actual response")) .expect("actual response deserialization"); let confirmed_blocks: Vec = serde_json::from_value(result["result"].clone()).unwrap(); assert_eq!(confirmed_blocks, vec![3, 4]); - let req = - r#"{"jsonrpc":"2.0","id":1,"method":"getConfirmedBlocksWithLimit","params":[2,3]}"#; + let req = r#"{"jsonrpc":"2.0","id":1,"method":"getBlocksWithLimit","params":[2,3]}"#; let res = io.handle_request_sync(&req, meta.clone()); let result: Value = serde_json::from_str(&res.expect("actual response")) .expect("actual response deserialization"); let confirmed_blocks: Vec = serde_json::from_value(result["result"].clone()).unwrap(); assert_eq!(confirmed_blocks, vec![3, 4, 8]); - let req = r#"{"jsonrpc":"2.0","id":1,"method":"getConfirmedBlocksWithLimit","params":[2,500000]}"#; + let req = r#"{"jsonrpc":"2.0","id":1,"method":"getBlocksWithLimit","params":[2,500000]}"#; let res = io.handle_request_sync(&req, meta.clone()); let result: Value = serde_json::from_str(&res.expect("actual response")) .expect("actual response deserialization"); let confirmed_blocks: Vec = serde_json::from_value(result["result"].clone()).unwrap(); assert_eq!(confirmed_blocks, vec![3, 4, 8]); - let req = r#"{"jsonrpc":"2.0","id":1,"method":"getConfirmedBlocksWithLimit","params":[9,500000]}"#; + let req = r#"{"jsonrpc":"2.0","id":1,"method":"getBlocksWithLimit","params":[9,500000]}"#; let res = io.handle_request_sync(&req, meta); let result: Value = serde_json::from_str(&res.expect("actual response")) .expect("actual response deserialization"); diff --git a/core/src/rpc_service.rs b/core/src/rpc_service.rs index 71729e437d..9d8932ccad 100644 --- a/core/src/rpc_service.rs +++ b/core/src/rpc_service.rs @@ -6,7 +6,7 @@ use crate::{ max_slots::MaxSlots, optimistically_confirmed_bank_tracker::OptimisticallyConfirmedBank, poh_recorder::PohRecorder, - rpc::{rpc_full::*, rpc_minimal::*, rpc_obsolete_v1_7::*, *}, + rpc::{rpc_deprecated_v1_7::*, rpc_full::*, rpc_minimal::*, rpc_obsolete_v1_7::*, *}, rpc_health::*, send_transaction_service::{LeaderInfo, SendTransactionService}, validator::ValidatorExit, @@ -403,6 +403,7 @@ impl JsonRpcService { io.extend_with(rpc_minimal::MinimalImpl.to_delegate()); if !minimal_api { io.extend_with(rpc_full::FullImpl.to_delegate()); + io.extend_with(rpc_deprecated_v1_7::DeprecatedV1_7Impl.to_delegate()); } if obsolete_v1_7_api { io.extend_with(rpc_obsolete_v1_7::ObsoleteV1_7Impl.to_delegate()); diff --git a/docs/src/developing/clients/jsonrpc-api.md b/docs/src/developing/clients/jsonrpc-api.md index 6280e891af..5886fb0107 100644 --- a/docs/src/developing/clients/jsonrpc-api.md +++ b/docs/src/developing/clients/jsonrpc-api.md @@ -20,14 +20,12 @@ gives a convenient interface for the RPC methods. - [getAccountInfo](jsonrpc-api.md#getaccountinfo) - [getBalance](jsonrpc-api.md#getbalance) +- [getBlock](jsonrpc-api.md#getblock) - [getBlockCommitment](jsonrpc-api.md#getblockcommitment) +- [getBlocks](jsonrpc-api.md#getblocks) +- [getBlocksWithLimit](jsonrpc-api.md#getblockswithlimit) - [getBlockTime](jsonrpc-api.md#getblocktime) - [getClusterNodes](jsonrpc-api.md#getclusternodes) -- [getConfirmedBlock](jsonrpc-api.md#getconfirmedblock) -- [getConfirmedBlocks](jsonrpc-api.md#getconfirmedblocks) -- [getConfirmedBlocksWithLimit](jsonrpc-api.md#getconfirmedblockswithlimit) -- [getConfirmedSignaturesForAddress2](jsonrpc-api.md#getconfirmedsignaturesforaddress2) -- [getConfirmedTransaction](jsonrpc-api.md#getconfirmedtransaction) - [getEpochInfo](jsonrpc-api.md#getepochinfo) - [getEpochSchedule](jsonrpc-api.md#getepochschedule) - [getFeeCalculatorForBlockhash](jsonrpc-api.md#getfeecalculatorforblockhash) @@ -49,6 +47,7 @@ gives a convenient interface for the RPC methods. - [getProgramAccounts](jsonrpc-api.md#getprogramaccounts) - [getRecentBlockhash](jsonrpc-api.md#getrecentblockhash) - [getRecentPerformanceSamples](jsonrpc-api.md#getrecentperformancesamples) +- [getSignaturesForAddress](jsonrpc-api.md#getsignaturesforaddress) - [getSignatureStatuses](jsonrpc-api.md#getsignaturestatuses) - [getSlot](jsonrpc-api.md#getslot) - [getSlotLeader](jsonrpc-api.md#getslotleader) @@ -60,6 +59,7 @@ gives a convenient interface for the RPC methods. - [getTokenAccountsByOwner](jsonrpc-api.md#gettokenaccountsbyowner) - [getTokenLargestAccounts](jsonrpc-api.md#gettokenlargestaccounts) - [getTokenSupply](jsonrpc-api.md#gettokensupply) +- [getTransaction](jsonrpc-api.md#gettransaction) - [getTransactionCount](jsonrpc-api.md#gettransactioncount) - [getVersion](jsonrpc-api.md#getversion) - [getVoteAccounts](jsonrpc-api.md#getvoteaccounts) @@ -79,6 +79,14 @@ gives a convenient interface for the RPC methods. - [slotSubscribe](jsonrpc-api.md#slotsubscribe) - [slotUnsubscribe](jsonrpc-api.md#slotunsubscribe) +### Deprecated Methods + +- [getConfirmedBlock](jsonrpc-api.md#getconfirmedblock) +- [getConfirmedBlocks](jsonrpc-api.md#getconfirmedblocks) +- [getConfirmedBlocksWithLimit](jsonrpc-api.md#getconfirmedblockswithlimit) +- [getConfirmedSignaturesForAddress2](jsonrpc-api.md#getconfirmedsignaturesforaddress2) +- [getConfirmedTransaction](jsonrpc-api.md#getconfirmedtransaction) + ## Request Formatting To make a JSON-RPC request, send an HTTP POST request with a `Content-Type: @@ -337,121 +345,7 @@ Result: {"jsonrpc":"2.0","result":{"context":{"slot":1},"value":0},"id":1} ``` -### getBlockCommitment - -Returns commitment for particular block - -#### Parameters: - -- `` - block, identified by Slot - -#### Results: - -The result field will be a JSON object containing: - -- `commitment` - commitment, comprising either: - - `` - Unknown block - - `` - commitment, array of u64 integers logging the amount of cluster stake in lamports that has voted on the block at each depth from 0 to `MAX_LOCKOUT_HISTORY` + 1 -- `totalStake` - total active stake, in lamports, of the current epoch - -#### Example: - -Request: -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc":"2.0","id":1, "method":"getBlockCommitment","params":[5]} -' -``` - -Result: -```json -{ - "jsonrpc":"2.0", - "result":{ - "commitment":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,32], - "totalStake": 42 - }, - "id":1 -} -``` - -### getBlockTime - -Returns the estimated production time of a block. - -Each validator reports their UTC time to the ledger on a regular interval by -intermittently adding a timestamp to a Vote for a particular block. A requested -block's time is calculated from the stake-weighted mean of the Vote timestamps -in a set of recent blocks recorded on the ledger. - -#### Parameters: - -- `` - block, identified by Slot - -#### Results: - -* `` - estimated production time, as Unix timestamp (seconds since the Unix epoch) -* `` - timestamp is not available for this block - -#### Example: - -Request: -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc":"2.0","id":1, "method":"getBlockTime","params":[5]} -' -``` - -Result: -```json -{"jsonrpc":"2.0","result":1574721591,"id":1} -``` - -### getClusterNodes - -Returns information about all the nodes participating in the cluster - -#### Parameters: - -None - -#### Results: - -The result field will be an array of JSON objects, each with the following sub fields: - -- `pubkey: ` - Node public key, as base-58 encoded string -- `gossip: ` - Gossip network address for the node -- `tpu: ` - TPU network address for the node -- `rpc: |null` - JSON RPC network address for the node, or `null` if the JSON RPC service is not enabled -- `version: |null` - The software version of the node, or `null` if the version information is not available - -#### Example: - -Request: -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc":"2.0", "id":1, "method":"getClusterNodes"} -' -``` - -Result: -```json -{ - "jsonrpc": "2.0", - "result": [ - { - "gossip": "10.239.6.48:8001", - "pubkey": "9QzsJf7LPLj8GkXbYT3LFDKqsj2hHG7TA3xinJHu8epQ", - "rpc": "10.239.6.48:8899", - "tpu": "10.239.6.48:8856", - "version": "1.0.0 c375ce1f" - } - ], - "id": 1 -} -``` - -### getConfirmedBlock +### getBlock Returns identity and transaction information about a confirmed block in the ledger @@ -501,7 +395,7 @@ The result field will be an object with the following fields: Request: ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc": "2.0","id":1,"method":"getConfirmedBlock","params":[430, {"encoding": "json","transactionDetails":"full","rewards":false}]} + {"jsonrpc": "2.0","id":1,"method":"getBlock","params":[430, {"encoding": "json","transactionDetails":"full","rewards":false}]} ' ``` @@ -584,7 +478,7 @@ Result: Request: ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc": "2.0","id":1,"method":"getConfirmedBlock","params":[430, "base64"]} + {"jsonrpc": "2.0","id":1,"method":"getBlock","params":[430, "base64"]} ' ``` @@ -679,7 +573,45 @@ The JSON structure of token balances is defined as a list of objects in the foll - `uiAmount: ` - Token amount as a float, accounting for decimals. **DEPRECATED** - `uiAmountString: ` - Token amount as a string, accounting for decimals. -### getConfirmedBlocks +### getBlockCommitment + +Returns commitment for particular block + +#### Parameters: + +- `` - block, identified by Slot + +#### Results: + +The result field will be a JSON object containing: + +- `commitment` - commitment, comprising either: + - `` - Unknown block + - `` - commitment, array of u64 integers logging the amount of cluster stake in lamports that has voted on the block at each depth from 0 to `MAX_LOCKOUT_HISTORY` + 1 +- `totalStake` - total active stake, in lamports, of the current epoch + +#### Example: + +Request: +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + {"jsonrpc":"2.0","id":1, "method":"getBlockCommitment","params":[5]} +' +``` + +Result: +```json +{ + "jsonrpc":"2.0", + "result":{ + "commitment":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,32], + "totalStake": 42 + }, + "id":1 +} +``` + +### getBlocks Returns a list of confirmed blocks between two slots @@ -701,7 +633,7 @@ inclusive. Max range allowed is 500,000 slots. Request: ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc": "2.0","id":1,"method":"getConfirmedBlocks","params":[5, 10]} + {"jsonrpc": "2.0","id":1,"method":"getBlocks","params":[5, 10]} ' ``` @@ -710,7 +642,7 @@ Result: {"jsonrpc":"2.0","result":[5,6,7,8,9,10],"id":1} ``` -### getConfirmedBlocksWithLimit +### getBlocksWithLimit Returns a list of confirmed blocks starting at the given slot @@ -730,7 +662,7 @@ starting at `start_slot` for up to `limit` blocks, inclusive. Request: ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc": "2.0","id":1,"method":"getConfirmedBlocksWithLimit","params":[5, 3]} + {"jsonrpc": "2.0","id":1,"method":"getBlocksWithLimit","params":[5, 3]} ' ``` @@ -739,45 +671,62 @@ Result: {"jsonrpc":"2.0","result":[5,6,7],"id":1} ``` -### getConfirmedSignaturesForAddress2 +### getBlockTime -Returns confirmed signatures for transactions involving an -address backwards in time from the provided signature or most recent confirmed block +Returns the estimated production time of a block. + +Each validator reports their UTC time to the ledger on a regular interval by +intermittently adding a timestamp to a Vote for a particular block. A requested +block's time is calculated from the stake-weighted mean of the Vote timestamps +in a set of recent blocks recorded on the ledger. #### Parameters: -* `` - account address as base-58 encoded string -* `` - (optional) Configuration object containing the following fields: - * `limit: ` - (optional) maximum transaction signatures to return (between 1 and 1,000, default: 1,000). - * `before: ` - (optional) start searching backwards from this transaction signature. - If not provided the search starts from the top of the highest max confirmed block. - * `until: ` - (optional) search until this transaction signature, if found before limit reached. - * (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment); "processed" is not supported. If parameter not provided, the default is "finalized". + +- `` - block, identified by Slot #### Results: -The result field will be an array of transaction signature information, ordered -from newest to oldest transaction: -* `` - * `signature: ` - transaction signature as base-58 encoded string - * `slot: ` - The slot that contains the block with the transaction - * `err: ` - Error if transaction failed, null if transaction succeeded. [TransactionError definitions](https://github.com/solana-labs/solana/blob/master/sdk/src/transaction.rs#L24) - * `memo: ` - Memo associated with the transaction, null if no memo is present - * `blockTime: ` - estimated production time, as Unix timestamp (seconds since the Unix epoch) of when transaction was processed. null if not available. + +* `` - estimated production time, as Unix timestamp (seconds since the Unix epoch) +* `` - timestamp is not available for this block #### Example: + Request: ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - { - "jsonrpc": "2.0", - "id": 1, - "method": "getConfirmedSignaturesForAddress2", - "params": [ - "Vote111111111111111111111111111111111111111", - { - "limit": 1 - } - ] - } + {"jsonrpc":"2.0","id":1, "method":"getBlockTime","params":[5]} +' +``` + +Result: +```json +{"jsonrpc":"2.0","result":1574721591,"id":1} +``` + +### getClusterNodes + +Returns information about all the nodes participating in the cluster + +#### Parameters: + +None + +#### Results: + +The result field will be an array of JSON objects, each with the following sub fields: + +- `pubkey: ` - Node public key, as base-58 encoded string +- `gossip: ` - Gossip network address for the node +- `tpu: ` - TPU network address for the node +- `rpc: |null` - JSON RPC network address for the node, or `null` if the JSON RPC service is not enabled +- `version: |null` - The software version of the node, or `null` if the version information is not available + +#### Example: + +Request: +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + {"jsonrpc":"2.0", "id":1, "method":"getClusterNodes"} ' ``` @@ -787,188 +736,17 @@ Result: "jsonrpc": "2.0", "result": [ { - "err": null, - "memo": null, - "signature": "5h6xBEauJ3PK6SWCZ1PGjBvj8vDdWG3KpwATGy1ARAXFSDwt8GFXM7W5Ncn16wmqokgpiKRLuS83KUxyZyv2sUYv", - "slot": 114, - "blockTime": null + "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 } ``` -### getConfirmedTransaction - -Returns transaction details for a confirmed transaction - -#### Parameters: - -- `` - transaction signature as base-58 encoded string -- `` - (optional) Configuration object containing the following optional fields: - - (optional) `encoding: ` - encoding for each returned Transaction, either "json", "jsonParsed", "base58" (*slow*), "base64". If parameter not provided, the default encoding is "json". - "jsonParsed" encoding attempts to use program-specific instruction parsers to return more human-readable and explicit data in the `transaction.message.instructions` list. If "jsonParsed" is requested but a parser cannot be found, the instruction falls back to regular JSON encoding (`accounts`, `data`, and `programIdIndex` fields). - - (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment); "processed" is not supported. If parameter not provided, the default is "finalized". - -#### Results: - -- `` - if transaction is not found or not confirmed -- `` - if transaction is confirmed, an object with the following fields: - - `slot: ` - the slot this transaction was processed in - - `transaction: ` - [Transaction](#transaction-structure) object, either in JSON format or encoded binary data, depending on encoding parameter - - `blockTime: ` - estimated production time, as Unix timestamp (seconds since the Unix epoch) of when the transaction was processed. null if not available - - `meta: ` - transaction status metadata object: - - `err: ` - Error if transaction failed, null if transaction succeeded. [TransactionError definitions](https://github.com/solana-labs/solana/blob/master/sdk/src/transaction.rs#L24) - - `fee: ` - fee this transaction was charged, as u64 integer - - `preBalances: ` - array of u64 account balances from before the transaction was processed - - `postBalances: ` - array of u64 account balances after the transaction was processed - - `innerInstructions: ` - List of [inner instructions](#inner-instructions-structure) or omitted if inner instruction recording was not yet enabled during this transaction - - `preTokenBalances: ` - List of [token balances](#token-balances-structure) from before the transaction was processed or omitted if token balance recording was not yet enabled during this transaction - - `postTokenBalances: ` - List of [token balances](#token-balances-structure) from after the transaction was processed or omitted if token balance recording was not yet enabled during this transaction - - `logMessages: ` - array of string log messages or omitted if log message recording was not yet enabled during this transaction - - DEPRECATED: `status: ` - Transaction status - - `"Ok": ` - Transaction was successful - - `"Err": ` - Transaction failed with TransactionError - -#### Example: -Request: -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - { - "jsonrpc": "2.0", - "id": 1, - "method": "getConfirmedTransaction", - "params": [ - "2nBhEBYYvfaAe16UMNqRHre4YNSskvuYgx3M6E4JP1oDYvZEJHvoPzyUidNgNX5r9sTyN1J9UxtbCXy2rqYcuyuv", - "json" - ] - } -' -``` - -Result: -```json -{ - "jsonrpc": "2.0", - "result": { - "meta": { - "err": null, - "fee": 5000, - "innerInstructions": [], - "postBalances": [ - 499998932500, - 26858640, - 1, - 1, - 1 - ], - "postTokenBalances": [], - "preBalances": [ - 499998937500, - 26858640, - 1, - 1, - 1 - ], - "preTokenBalances": [], - "status": { - "Ok": null - } - }, - "slot": 430, - "transaction": { - "message": { - "accountKeys": [ - "3UVYmECPPMZSCqWKfENfuoTv51fTDTWicX9xmBD2euKe", - "AjozzgE83A3x1sHNUR64hfH7zaEBWeMaFuAN9kQgujrc", - "SysvarS1otHashes111111111111111111111111111", - "SysvarC1ock11111111111111111111111111111111", - "Vote111111111111111111111111111111111111111" - ], - "header": { - "numReadonlySignedAccounts": 0, - "numReadonlyUnsignedAccounts": 3, - "numRequiredSignatures": 1 - }, - "instructions": [ - { - "accounts": [ - 1, - 2, - 3, - 0 - ], - "data": "37u9WtQpcm6ULa3WRQHmj49EPs4if7o9f1jSRVZpm2dvihR9C8jY4NqEwXUbLwx15HBSNcP1", - "programIdIndex": 4 - } - ], - "recentBlockhash": "mfcyqEXB3DnHXki6KjjmZck6YjmZLvpAByy2fj4nh6B" - }, - "signatures": [ - "2nBhEBYYvfaAe16UMNqRHre4YNSskvuYgx3M6E4JP1oDYvZEJHvoPzyUidNgNX5r9sTyN1J9UxtbCXy2rqYcuyuv" - ] - } - }, - "blockTime": null, - "id": 1 -} -``` - -#### Example: -Request: -```bash -curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - { - "jsonrpc": "2.0", - "id": 1, - "method": "getConfirmedTransaction", - "params": [ - "2nBhEBYYvfaAe16UMNqRHre4YNSskvuYgx3M6E4JP1oDYvZEJHvoPzyUidNgNX5r9sTyN1J9UxtbCXy2rqYcuyuv", - "base64" - ] - } -' -``` - -Result: -```json -{ - "jsonrpc": "2.0", - "result": { - "meta": { - "err": null, - "fee": 5000, - "innerInstructions": [], - "postBalances": [ - 499998932500, - 26858640, - 1, - 1, - 1 - ], - "postTokenBalances": [], - "preBalances": [ - 499998937500, - 26858640, - 1, - 1, - 1 - ], - "preTokenBalances": [], - "status": { - "Ok": null - } - }, - "slot": 430, - "transaction": [ - "AVj7dxHlQ9IrvdYVIjuiRFs1jLaDMHixgrv+qtHBwz51L4/ImLZhszwiyEJDIp7xeBSpm/TX5B7mYzxa+fPOMw0BAAMFJMJVqLw+hJYheizSoYlLm53KzgT82cDVmazarqQKG2GQsLgiqktA+a+FDR4/7xnDX7rsusMwryYVUdixfz1B1Qan1RcZLwqvxvJl4/t3zHragsUp0L47E24tAFUgAAAABqfVFxjHdMkoVmOYaR1etoteuKObS21cc1VbIQAAAAAHYUgdNXR0u3xNdiTr072z2DVec9EQQ/wNo1OAAAAAAAtxOUhPBp2WSjUNJEgfvy70BbxI00fZyEPvFHNfxrtEAQQEAQIDADUCAAAAAQAAAAAAAACtAQAAAAAAAAdUE18R96XTJCe+YfRfUp6WP+YKCy/72ucOL8AoBFSpAA==", - "base64" - ] - }, - "id": 1 -} -``` - ### getEpochInfo Returns information about the current epoch @@ -2086,6 +1864,65 @@ Result when the node has no snapshot: {"jsonrpc":"2.0","error":{"code":-32008,"message":"No snapshot"},"id":1} ``` +### getSignaturesForAddress + +Returns confirmed signatures for transactions involving an +address backwards in time from the provided signature or most recent confirmed block + +#### Parameters: +* `` - account address as base-58 encoded string +* `` - (optional) Configuration object containing the following fields: + * `limit: ` - (optional) maximum transaction signatures to return (between 1 and 1,000, default: 1,000). + * `before: ` - (optional) start searching backwards from this transaction signature. + If not provided the search starts from the top of the highest max confirmed block. + * `until: ` - (optional) search until this transaction signature, if found before limit reached. + * (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment); "processed" is not supported. If parameter not provided, the default is "finalized". + +#### Results: +The result field will be an array of transaction signature information, ordered +from newest to oldest transaction: +* `` + * `signature: ` - transaction signature as base-58 encoded string + * `slot: ` - The slot that contains the block with the transaction + * `err: ` - Error if transaction failed, null if transaction succeeded. [TransactionError definitions](https://github.com/solana-labs/solana/blob/master/sdk/src/transaction.rs#L24) + * `memo: ` - Memo associated with the transaction, null if no memo is present + * `blockTime: ` - estimated production time, as Unix timestamp (seconds since the Unix epoch) of when transaction was processed. null if not available. + +#### Example: +Request: +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc": "2.0", + "id": 1, + "method": "getSignaturesForAddress", + "params": [ + "Vote111111111111111111111111111111111111111", + { + "limit": 1 + } + ] + } +' +``` + +Result: +```json +{ + "jsonrpc": "2.0", + "result": [ + { + "err": null, + "memo": null, + "signature": "5h6xBEauJ3PK6SWCZ1PGjBvj8vDdWG3KpwATGy1ARAXFSDwt8GFXM7W5Ncn16wmqokgpiKRLuS83KUxyZyv2sUYv", + "slot": 114, + "blockTime": null + } + ], + "id": 1 +} +``` + ### getSignatureStatuses Returns the statuses of a list of signatures. Unless the @@ -2745,6 +2582,177 @@ Result: } ``` +### getTransaction + +Returns transaction details for a confirmed transaction + +#### Parameters: + +- `` - transaction signature as base-58 encoded string +- `` - (optional) Configuration object containing the following optional fields: + - (optional) `encoding: ` - encoding for each returned Transaction, either "json", "jsonParsed", "base58" (*slow*), "base64". If parameter not provided, the default encoding is "json". + "jsonParsed" encoding attempts to use program-specific instruction parsers to return more human-readable and explicit data in the `transaction.message.instructions` list. If "jsonParsed" is requested but a parser cannot be found, the instruction falls back to regular JSON encoding (`accounts`, `data`, and `programIdIndex` fields). + - (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment); "processed" is not supported. If parameter not provided, the default is "finalized". + +#### Results: + +- `` - if transaction is not found or not confirmed +- `` - if transaction is confirmed, an object with the following fields: + - `slot: ` - the slot this transaction was processed in + - `transaction: ` - [Transaction](#transaction-structure) object, either in JSON format or encoded binary data, depending on encoding parameter + - `blockTime: ` - estimated production time, as Unix timestamp (seconds since the Unix epoch) of when the transaction was processed. null if not available + - `meta: ` - transaction status metadata object: + - `err: ` - Error if transaction failed, null if transaction succeeded. [TransactionError definitions](https://github.com/solana-labs/solana/blob/master/sdk/src/transaction.rs#L24) + - `fee: ` - fee this transaction was charged, as u64 integer + - `preBalances: ` - array of u64 account balances from before the transaction was processed + - `postBalances: ` - array of u64 account balances after the transaction was processed + - `innerInstructions: ` - List of [inner instructions](#inner-instructions-structure) or omitted if inner instruction recording was not yet enabled during this transaction + - `preTokenBalances: ` - List of [token balances](#token-balances-structure) from before the transaction was processed or omitted if token balance recording was not yet enabled during this transaction + - `postTokenBalances: ` - List of [token balances](#token-balances-structure) from after the transaction was processed or omitted if token balance recording was not yet enabled during this transaction + - `logMessages: ` - array of string log messages or omitted if log message recording was not yet enabled during this transaction + - DEPRECATED: `status: ` - Transaction status + - `"Ok": ` - Transaction was successful + - `"Err": ` - Transaction failed with TransactionError + +#### Example: +Request: +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc": "2.0", + "id": 1, + "method": "getTransaction", + "params": [ + "2nBhEBYYvfaAe16UMNqRHre4YNSskvuYgx3M6E4JP1oDYvZEJHvoPzyUidNgNX5r9sTyN1J9UxtbCXy2rqYcuyuv", + "json" + ] + } +' +``` + +Result: +```json +{ + "jsonrpc": "2.0", + "result": { + "meta": { + "err": null, + "fee": 5000, + "innerInstructions": [], + "postBalances": [ + 499998932500, + 26858640, + 1, + 1, + 1 + ], + "postTokenBalances": [], + "preBalances": [ + 499998937500, + 26858640, + 1, + 1, + 1 + ], + "preTokenBalances": [], + "status": { + "Ok": null + } + }, + "slot": 430, + "transaction": { + "message": { + "accountKeys": [ + "3UVYmECPPMZSCqWKfENfuoTv51fTDTWicX9xmBD2euKe", + "AjozzgE83A3x1sHNUR64hfH7zaEBWeMaFuAN9kQgujrc", + "SysvarS1otHashes111111111111111111111111111", + "SysvarC1ock11111111111111111111111111111111", + "Vote111111111111111111111111111111111111111" + ], + "header": { + "numReadonlySignedAccounts": 0, + "numReadonlyUnsignedAccounts": 3, + "numRequiredSignatures": 1 + }, + "instructions": [ + { + "accounts": [ + 1, + 2, + 3, + 0 + ], + "data": "37u9WtQpcm6ULa3WRQHmj49EPs4if7o9f1jSRVZpm2dvihR9C8jY4NqEwXUbLwx15HBSNcP1", + "programIdIndex": 4 + } + ], + "recentBlockhash": "mfcyqEXB3DnHXki6KjjmZck6YjmZLvpAByy2fj4nh6B" + }, + "signatures": [ + "2nBhEBYYvfaAe16UMNqRHre4YNSskvuYgx3M6E4JP1oDYvZEJHvoPzyUidNgNX5r9sTyN1J9UxtbCXy2rqYcuyuv" + ] + } + }, + "blockTime": null, + "id": 1 +} +``` + +#### Example: +Request: +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc": "2.0", + "id": 1, + "method": "getTransaction", + "params": [ + "2nBhEBYYvfaAe16UMNqRHre4YNSskvuYgx3M6E4JP1oDYvZEJHvoPzyUidNgNX5r9sTyN1J9UxtbCXy2rqYcuyuv", + "base64" + ] + } +' +``` + +Result: +```json +{ + "jsonrpc": "2.0", + "result": { + "meta": { + "err": null, + "fee": 5000, + "innerInstructions": [], + "postBalances": [ + 499998932500, + 26858640, + 1, + 1, + 1 + ], + "postTokenBalances": [], + "preBalances": [ + 499998937500, + 26858640, + 1, + 1, + 1 + ], + "preTokenBalances": [], + "status": { + "Ok": null + } + }, + "slot": 430, + "transaction": [ + "AVj7dxHlQ9IrvdYVIjuiRFs1jLaDMHixgrv+qtHBwz51L4/ImLZhszwiyEJDIp7xeBSpm/TX5B7mYzxa+fPOMw0BAAMFJMJVqLw+hJYheizSoYlLm53KzgT82cDVmazarqQKG2GQsLgiqktA+a+FDR4/7xnDX7rsusMwryYVUdixfz1B1Qan1RcZLwqvxvJl4/t3zHragsUp0L47E24tAFUgAAAABqfVFxjHdMkoVmOYaR1etoteuKObS21cc1VbIQAAAAAHYUgdNXR0u3xNdiTr072z2DVec9EQQ/wNo1OAAAAAAAtxOUhPBp2WSjUNJEgfvy70BbxI00fZyEPvFHNfxrtEAQQEAQIDADUCAAAAAQAAAAAAAACtAQAAAAAAAAdUE18R96XTJCe+YfRfUp6WP+YKCy/72ucOL8AoBFSpAA==", + "base64" + ] + }, + "id": 1 +} +``` + ### getTransactionCount Returns the current Transaction count from the ledger @@ -3727,3 +3735,500 @@ Response: ```json {"jsonrpc": "2.0","result": true,"id": 1} ``` + +## JSON RPC API Deprecated Methods + +### getConfirmedBlock + +**DEPRECATED: Please use [getBlock](jsonrpc-api.md#getblock) instead** +This method is expected to be removed in solana-core v1.8 + +Returns identity and transaction information about a confirmed block in the ledger + +#### Parameters: + +- `` - slot, as u64 integer +- `` - (optional) Configuration object containing the following optional fields: + - (optional) `encoding: ` - encoding for each returned Transaction, either "json", "jsonParsed", "base58" (*slow*), "base64". If parameter not provided, the default encoding is "json". + "jsonParsed" encoding attempts to use program-specific instruction parsers to return more human-readable and explicit data in the `transaction.message.instructions` list. If "jsonParsed" is requested but a parser cannot be found, the instruction falls back to regular JSON encoding (`accounts`, `data`, and `programIdIndex` fields). + - (optional) `transactionDetails: ` - level of transaction detail to return, either "full", "signatures", or "none". If parameter not provided, the default detail level is "full". + - (optional) `rewards: bool` - whether to populate the `rewards` array. If parameter not provided, the default includes rewards. + - (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment); "processed" is not supported. If parameter not provided, the default is "finalized". + +#### Results: + +The result field will be an object with the following fields: + +- `` - if specified block is not confirmed +- `` - if block is confirmed, an object with the following fields: + - `blockhash: ` - the blockhash of this block, as base-58 encoded string + - `previousBlockhash: ` - the blockhash of this block's parent, as base-58 encoded string; if the parent block is not available due to ledger cleanup, this field will return "11111111111111111111111111111111" + - `parentSlot: ` - the slot index of this block's parent + - `transactions: ` - present if "full" transaction details are requested; an array of JSON objects containing: + - `transaction: ` - [Transaction](#transaction-structure) object, either in JSON format or encoded binary data, depending on encoding parameter + - `meta: ` - transaction status metadata object, containing `null` or: + - `err: ` - Error if transaction failed, null if transaction succeeded. [TransactionError definitions](https://github.com/solana-labs/solana/blob/master/sdk/src/transaction.rs#L24) + - `fee: ` - fee this transaction was charged, as u64 integer + - `preBalances: ` - array of u64 account balances from before the transaction was processed + - `postBalances: ` - array of u64 account balances after the transaction was processed + - `innerInstructions: ` - List of [inner instructions](#inner-instructions-structure) or omitted if inner instruction recording was not yet enabled during this transaction + - `preTokenBalances: ` - List of [token balances](#token-balances-structure) from before the transaction was processed or omitted if token balance recording was not yet enabled during this transaction + - `postTokenBalances: ` - List of [token balances](#token-balances-structure) from after the transaction was processed or omitted if token balance recording was not yet enabled during this transaction + - `logMessages: ` - array of string log messages or omitted if log message recording was not yet enabled during this transaction + - DEPRECATED: `status: ` - Transaction status + - `"Ok": ` - Transaction was successful + - `"Err": ` - Transaction failed with TransactionError + - `signatures: ` - present if "signatures" are requested for transaction details; an array of signatures strings, corresponding to the transaction order in the block + - `rewards: ` - present if rewards are requested; an array of JSON objects containing: + - `pubkey: ` - The public key, as base-58 encoded string, of the account that received the reward + - `lamports: `- number of reward lamports credited or debited by the account, as a i64 + - `postBalance: ` - account balance in lamports after the reward was applied + - `rewardType: ` - type of reward: "fee", "rent", "voting", "staking" + - `blockTime: ` - estimated production time, as Unix timestamp (seconds since the Unix epoch). null if not available + +#### Example: + +Request: +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + {"jsonrpc": "2.0","id":1,"method":"getConfirmedBlock","params":[430, {"encoding": "json","transactionDetails":"full","rewards":false}]} +' +``` + +Result: +```json +{ + "jsonrpc": "2.0", + "result": { + "blockTime": null, + "blockhash": "3Eq21vXNB5s86c62bVuUfTeaMif1N2kUqRPBmGRJhyTA", + "parentSlot": 429, + "previousBlockhash": "mfcyqEXB3DnHXki6KjjmZck6YjmZLvpAByy2fj4nh6B", + "transactions": [ + { + "meta": { + "err": null, + "fee": 5000, + "innerInstructions": [], + "logMessages": [], + "postBalances": [ + 499998932500, + 26858640, + 1, + 1, + 1 + ], + "postTokenBalances": [], + "preBalances": [ + 499998937500, + 26858640, + 1, + 1, + 1 + ], + "preTokenBalances": [], + "status": { + "Ok": null + } + }, + "transaction": { + "message": { + "accountKeys": [ + "3UVYmECPPMZSCqWKfENfuoTv51fTDTWicX9xmBD2euKe", + "AjozzgE83A3x1sHNUR64hfH7zaEBWeMaFuAN9kQgujrc", + "SysvarS1otHashes111111111111111111111111111", + "SysvarC1ock11111111111111111111111111111111", + "Vote111111111111111111111111111111111111111" + ], + "header": { + "numReadonlySignedAccounts": 0, + "numReadonlyUnsignedAccounts": 3, + "numRequiredSignatures": 1 + }, + "instructions": [ + { + "accounts": [ + 1, + 2, + 3, + 0 + ], + "data": "37u9WtQpcm6ULa3WRQHmj49EPs4if7o9f1jSRVZpm2dvihR9C8jY4NqEwXUbLwx15HBSNcP1", + "programIdIndex": 4 + } + ], + "recentBlockhash": "mfcyqEXB3DnHXki6KjjmZck6YjmZLvpAByy2fj4nh6B" + }, + "signatures": [ + "2nBhEBYYvfaAe16UMNqRHre4YNSskvuYgx3M6E4JP1oDYvZEJHvoPzyUidNgNX5r9sTyN1J9UxtbCXy2rqYcuyuv" + ] + } + } + ] + }, + "id": 1 +} +``` + +#### Example: +Request: +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + {"jsonrpc": "2.0","id":1,"method":"getConfirmedBlock","params":[430, "base64"]} +' +``` + +Result: +```json +{ + "jsonrpc": "2.0", + "result": { + "blockTime": null, + "blockhash": "3Eq21vXNB5s86c62bVuUfTeaMif1N2kUqRPBmGRJhyTA", + "parentSlot": 429, + "previousBlockhash": "mfcyqEXB3DnHXki6KjjmZck6YjmZLvpAByy2fj4nh6B", + "rewards": [], + "transactions": [ + { + "meta": { + "err": null, + "fee": 5000, + "innerInstructions": [], + "logMessages": [], + "postBalances": [ + 499998932500, + 26858640, + 1, + 1, + 1 + ], + "postTokenBalances": [], + "preBalances": [ + 499998937500, + 26858640, + 1, + 1, + 1 + ], + "preTokenBalances": [], + "status": { + "Ok": null + } + }, + "transaction": [ + "AVj7dxHlQ9IrvdYVIjuiRFs1jLaDMHixgrv+qtHBwz51L4/ImLZhszwiyEJDIp7xeBSpm/TX5B7mYzxa+fPOMw0BAAMFJMJVqLw+hJYheizSoYlLm53KzgT82cDVmazarqQKG2GQsLgiqktA+a+FDR4/7xnDX7rsusMwryYVUdixfz1B1Qan1RcZLwqvxvJl4/t3zHragsUp0L47E24tAFUgAAAABqfVFxjHdMkoVmOYaR1etoteuKObS21cc1VbIQAAAAAHYUgdNXR0u3xNdiTr072z2DVec9EQQ/wNo1OAAAAAAAtxOUhPBp2WSjUNJEgfvy70BbxI00fZyEPvFHNfxrtEAQQEAQIDADUCAAAAAQAAAAAAAACtAQAAAAAAAAdUE18R96XTJCe+YfRfUp6WP+YKCy/72ucOL8AoBFSpAA==", + "base64" + ] + } + ] + }, + "id": 1 +} +``` + +For more details on returned data: +[Transaction Structure](jsonrpc-api.md#transactionstructure) +[Inner Instructions Structure](jsonrpc-api.md#innerinstructionsstructure) +[Token Balances Structure](jsonrpc-api.md#tokenbalancesstructure) + +### getConfirmedBlocks + +**DEPRECATED: Please use [getBlocks](jsonrpc-api.md#getblocks) instead** +This method is expected to be removed in solana-core v1.8 + +Returns a list of confirmed blocks between two slots + +#### Parameters: + +- `` - start_slot, as u64 integer +- `` - (optional) end_slot, as u64 integer +- (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment); "processed" is not supported. If parameter not provided, the default is "finalized". + +#### Results: + +The result field will be an array of u64 integers listing confirmed blocks +between `start_slot` and either `end_slot`, if provided, or latest confirmed block, +inclusive. Max range allowed is 500,000 slots. + + +#### Example: + +Request: +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + {"jsonrpc": "2.0","id":1,"method":"getConfirmedBlocks","params":[5, 10]} +' +``` + +Result: +```json +{"jsonrpc":"2.0","result":[5,6,7,8,9,10],"id":1} +``` + +### getConfirmedBlocksWithLimit + +**DEPRECATED: Please use [getBlocksWithLimit](jsonrpc-api.md#getblockswithlimit) instead** +This method is expected to be removed in solana-core v1.8 + +Returns a list of confirmed blocks starting at the given slot + +#### Parameters: + +- `` - start_slot, as u64 integer +- `` - limit, as u64 integer +- (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment); "processed" is not supported. If parameter not provided, the default is "finalized". + +#### Results: + +The result field will be an array of u64 integers listing confirmed blocks +starting at `start_slot` for up to `limit` blocks, inclusive. + +#### Example: + +Request: +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + {"jsonrpc": "2.0","id":1,"method":"getConfirmedBlocksWithLimit","params":[5, 3]} +' +``` + +Result: +```json +{"jsonrpc":"2.0","result":[5,6,7],"id":1} +``` + +### getConfirmedSignaturesForAddress2 + +**DEPRECATED: Please use [getSignaturesForAddress](jsonrpc-api.md#getsignaturesforaddress) instead** +This method is expected to be removed in solana-core v1.8 + +Returns confirmed signatures for transactions involving an +address backwards in time from the provided signature or most recent confirmed block + +#### Parameters: +* `` - account address as base-58 encoded string +* `` - (optional) Configuration object containing the following fields: + * `limit: ` - (optional) maximum transaction signatures to return (between 1 and 1,000, default: 1,000). + * `before: ` - (optional) start searching backwards from this transaction signature. + If not provided the search starts from the top of the highest max confirmed block. + * `until: ` - (optional) search until this transaction signature, if found before limit reached. + * (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment); "processed" is not supported. If parameter not provided, the default is "finalized". + +#### Results: +The result field will be an array of transaction signature information, ordered +from newest to oldest transaction: +* `` + * `signature: ` - transaction signature as base-58 encoded string + * `slot: ` - The slot that contains the block with the transaction + * `err: ` - Error if transaction failed, null if transaction succeeded. [TransactionError definitions](https://github.com/solana-labs/solana/blob/master/sdk/src/transaction.rs#L24) + * `memo: ` - Memo associated with the transaction, null if no memo is present + * `blockTime: ` - estimated production time, as Unix timestamp (seconds since the Unix epoch) of when transaction was processed. null if not available. + +#### Example: +Request: +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc": "2.0", + "id": 1, + "method": "getConfirmedSignaturesForAddress2", + "params": [ + "Vote111111111111111111111111111111111111111", + { + "limit": 1 + } + ] + } +' +``` + +Result: +```json +{ + "jsonrpc": "2.0", + "result": [ + { + "err": null, + "memo": null, + "signature": "5h6xBEauJ3PK6SWCZ1PGjBvj8vDdWG3KpwATGy1ARAXFSDwt8GFXM7W5Ncn16wmqokgpiKRLuS83KUxyZyv2sUYv", + "slot": 114, + "blockTime": null + } + ], + "id": 1 +} +``` + +### getConfirmedTransaction + +**DEPRECATED: Please use [getTransaction](jsonrpc-api.md#gettransaction) instead** +This method is expected to be removed in solana-core v1.8 + +Returns transaction details for a confirmed transaction + +#### Parameters: + +- `` - transaction signature as base-58 encoded string +- `` - (optional) Configuration object containing the following optional fields: + - (optional) `encoding: ` - encoding for each returned Transaction, either "json", "jsonParsed", "base58" (*slow*), "base64". If parameter not provided, the default encoding is "json". + "jsonParsed" encoding attempts to use program-specific instruction parsers to return more human-readable and explicit data in the `transaction.message.instructions` list. If "jsonParsed" is requested but a parser cannot be found, the instruction falls back to regular JSON encoding (`accounts`, `data`, and `programIdIndex` fields). + - (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment); "processed" is not supported. If parameter not provided, the default is "finalized". + +#### Results: + +- `` - if transaction is not found or not confirmed +- `` - if transaction is confirmed, an object with the following fields: + - `slot: ` - the slot this transaction was processed in + - `transaction: ` - [Transaction](#transaction-structure) object, either in JSON format or encoded binary data, depending on encoding parameter + - `blockTime: ` - estimated production time, as Unix timestamp (seconds since the Unix epoch) of when the transaction was processed. null if not available + - `meta: ` - transaction status metadata object: + - `err: ` - Error if transaction failed, null if transaction succeeded. [TransactionError definitions](https://github.com/solana-labs/solana/blob/master/sdk/src/transaction.rs#L24) + - `fee: ` - fee this transaction was charged, as u64 integer + - `preBalances: ` - array of u64 account balances from before the transaction was processed + - `postBalances: ` - array of u64 account balances after the transaction was processed + - `innerInstructions: ` - List of [inner instructions](#inner-instructions-structure) or omitted if inner instruction recording was not yet enabled during this transaction + - `preTokenBalances: ` - List of [token balances](#token-balances-structure) from before the transaction was processed or omitted if token balance recording was not yet enabled during this transaction + - `postTokenBalances: ` - List of [token balances](#token-balances-structure) from after the transaction was processed or omitted if token balance recording was not yet enabled during this transaction + - `logMessages: ` - array of string log messages or omitted if log message recording was not yet enabled during this transaction + - DEPRECATED: `status: ` - Transaction status + - `"Ok": ` - Transaction was successful + - `"Err": ` - Transaction failed with TransactionError + +#### Example: +Request: +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc": "2.0", + "id": 1, + "method": "getConfirmedTransaction", + "params": [ + "2nBhEBYYvfaAe16UMNqRHre4YNSskvuYgx3M6E4JP1oDYvZEJHvoPzyUidNgNX5r9sTyN1J9UxtbCXy2rqYcuyuv", + "json" + ] + } +' +``` + +Result: +```json +{ + "jsonrpc": "2.0", + "result": { + "meta": { + "err": null, + "fee": 5000, + "innerInstructions": [], + "postBalances": [ + 499998932500, + 26858640, + 1, + 1, + 1 + ], + "postTokenBalances": [], + "preBalances": [ + 499998937500, + 26858640, + 1, + 1, + 1 + ], + "preTokenBalances": [], + "status": { + "Ok": null + } + }, + "slot": 430, + "transaction": { + "message": { + "accountKeys": [ + "3UVYmECPPMZSCqWKfENfuoTv51fTDTWicX9xmBD2euKe", + "AjozzgE83A3x1sHNUR64hfH7zaEBWeMaFuAN9kQgujrc", + "SysvarS1otHashes111111111111111111111111111", + "SysvarC1ock11111111111111111111111111111111", + "Vote111111111111111111111111111111111111111" + ], + "header": { + "numReadonlySignedAccounts": 0, + "numReadonlyUnsignedAccounts": 3, + "numRequiredSignatures": 1 + }, + "instructions": [ + { + "accounts": [ + 1, + 2, + 3, + 0 + ], + "data": "37u9WtQpcm6ULa3WRQHmj49EPs4if7o9f1jSRVZpm2dvihR9C8jY4NqEwXUbLwx15HBSNcP1", + "programIdIndex": 4 + } + ], + "recentBlockhash": "mfcyqEXB3DnHXki6KjjmZck6YjmZLvpAByy2fj4nh6B" + }, + "signatures": [ + "2nBhEBYYvfaAe16UMNqRHre4YNSskvuYgx3M6E4JP1oDYvZEJHvoPzyUidNgNX5r9sTyN1J9UxtbCXy2rqYcuyuv" + ] + } + }, + "blockTime": null, + "id": 1 +} +``` + +#### Example: +Request: +```bash +curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' + { + "jsonrpc": "2.0", + "id": 1, + "method": "getConfirmedTransaction", + "params": [ + "2nBhEBYYvfaAe16UMNqRHre4YNSskvuYgx3M6E4JP1oDYvZEJHvoPzyUidNgNX5r9sTyN1J9UxtbCXy2rqYcuyuv", + "base64" + ] + } +' +``` + +Result: +```json +{ + "jsonrpc": "2.0", + "result": { + "meta": { + "err": null, + "fee": 5000, + "innerInstructions": [], + "postBalances": [ + 499998932500, + 26858640, + 1, + 1, + 1 + ], + "postTokenBalances": [], + "preBalances": [ + 499998937500, + 26858640, + 1, + 1, + 1 + ], + "preTokenBalances": [], + "status": { + "Ok": null + } + }, + "slot": 430, + "transaction": [ + "AVj7dxHlQ9IrvdYVIjuiRFs1jLaDMHixgrv+qtHBwz51L4/ImLZhszwiyEJDIp7xeBSpm/TX5B7mYzxa+fPOMw0BAAMFJMJVqLw+hJYheizSoYlLm53KzgT82cDVmazarqQKG2GQsLgiqktA+a+FDR4/7xnDX7rsusMwryYVUdixfz1B1Qan1RcZLwqvxvJl4/t3zHragsUp0L47E24tAFUgAAAABqfVFxjHdMkoVmOYaR1etoteuKObS21cc1VbIQAAAAAHYUgdNXR0u3xNdiTr072z2DVec9EQQ/wNo1OAAAAAAAtxOUhPBp2WSjUNJEgfvy70BbxI00fZyEPvFHNfxrtEAQQEAQIDADUCAAAAAQAAAAAAAACtAQAAAAAAAAdUE18R96XTJCe+YfRfUp6WP+YKCy/72ucOL8AoBFSpAA==", + "base64" + ] + }, + "id": 1 +} +```