getBlocks RPC Method
Please note: For this RPC method, the block range defined by the start and end slots is limited to a maximum of 5 slots for a free trial account and 1,005 slots for paid accounts.
參數
start_slot
字串
必填
載入中...
end_slot
字串
載入中...
物件
物件
載入中...
commitment
字串
載入中...
finalized
字串
載入中...
confirmed
字串
載入中...
退貨
結果
載入中...
請求
1curl https://docs-demo.solana-mainnet.quiknode.pro/ \2-X POST \3-H "Content-Type: application/json" \4-d '{5"jsonrpc": "2.0",6"id":1,7"method":"getBlocks",8"params":[335819351, 335819361]9}'
1curl https://docs-demo.solana-mainnet.quiknode.pro/ \2-X POST \3-H "Content-Type: application/json" \4-d '{5"jsonrpc": "2.0",6"id":1,7"method":"getBlocks",8"params":[335819351, 335819361]9}'
1需要 "uri"2require "json"3需要 "net/http"45url = URI("https://docs-demo.solana-mainnet.quiknode.pro/")67https = 網::HTTP.new(url.主機, url.port)8https.use_ssl = true910請求 = 淨::HTTP::POST.new(網址)11請求["Content-Type"] = "application/json"12請求。正文 = JSON.dump({13"jsonrpc": "2.0",14"id": 1,15"method": "getBlocks",16"params": [175,181019]20})2122回應 = https.請求(請求)23將回應。read_body24
1需要 "uri"2require "json"3需要 "net/http"45url = URI("https://docs-demo.solana-mainnet.quiknode.pro/")67https = 網::HTTP.new(url.主機, url.port)8https.use_ssl = true910請求 = 淨::HTTP::POST.new(網址)11請求["Content-Type"] = "application/json"12請求。正文 = JSON.dump({13"jsonrpc": "2.0",14"id": 1,15"method": "getBlocks",16"params": [175,181019]20})2122回應 = https.請求(請求)23將回應。read_body24
1import { createSolanaRpc } from "@solana/kit";23(async () => {4const solanaRpc = createSolanaRpc("https://docs-demo.solana-mainnet.quiknode.pro/");56試試看 {7const blocks = await solanaRpc.getBlocks(BigInt(5), BigInt(10)).send();8console.log("Blocks:", blocks);9} catch (錯誤) {10console.error("Error fetching blocks:", error);11}12})();
1import { createSolanaRpc } from "@solana/kit";23(async () => {4const solanaRpc = createSolanaRpc("https://docs-demo.solana-mainnet.quiknode.pro/");56試試看 {7const blocks = await solanaRpc.getBlocks(BigInt(5), BigInt(10)).send();8console.log("Blocks:", blocks);9} catch (錯誤) {10console.error("Error fetching blocks:", error);11}12})();
1const web3 = require("@solana/web3.js");2(async () => {3const solana = new web3.Connection("https://docs-demo.solana-mainnet.quiknode.pro/");4console.log(await solana.getBlocks(5, 10));5})();6
1const web3 = require("@solana/web3.js");2(async () => {3const solana = new web3.Connection("https://docs-demo.solana-mainnet.quiknode.pro/");4console.log(await solana.getBlocks(5, 10));5})();6
1from solana.rpc.api import Client2solana_client = Client("https://docs-demo.solana-mainnet.quiknode.pro/")3print(solana_client.get_blocks(5, 10))
1from solana.rpc.api import Client2solana_client = Client("https://docs-demo.solana-mainnet.quiknode.pro/")3print(solana_client.get_blocks(5, 10))
1use reqwest::header;2use reqwest::Client;3use std::error::Error;45#[tokio::main]6async fn main() -> Result<(), Box<dyn Error>> {7let mut headers = header::HeaderMap::new();8headers.insert("Content-Type", "application/json".parse().unwrap());910let client = Client::new();11let json_data = r#"12{13"jsonrpc": "2.0",14"id": 1,15"method": "getBlocks",16"params": [175,181019]20}21"#;22let response = client23.post("https://docs-demo.solana-mainnet.quiknode.pro/")24.headers(headers)25.body(json_data)26.send()27.await?;2829let body = response.text().await?;30println!("{}", body);3132好(())33}34
1use reqwest::header;2use reqwest::Client;3use std::error::Error;45#[tokio::main]6async fn main() -> Result<(), Box<dyn Error>> {7let mut headers = header::HeaderMap::new();8headers.insert("Content-Type", "application/json".parse().unwrap());910let client = Client::new();11let json_data = r#"12{13"jsonrpc": "2.0",14"id": 1,15"method": "getBlocks",16"params": [175,181019]20}21"#;22let response = client23.post("https://docs-demo.solana-mainnet.quiknode.pro/")24.headers(headers)25.body(json_data)26.send()27.await?;2829let body = response.text().await?;30println!("{}", body);3132好(())33}34
回應
1{2"jsonrpc": "2.0",3「結果」: [45,56,67,78,89,91010],11"id": 112}
1{2"jsonrpc": "2.0",3「結果」: [45,56,67,78,89,91010],11"id": 112}