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
字符串
正在加载...
对象
对象
正在加载...
承诺
字符串
正在加载...
已最终确定
字符串
正在加载...
已确认
字符串
正在加载...
退货
结果
正在加载...
请求
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}'
1require "uri"2require "json"3require "net/http"45url = URI("https://docs-demo.solana-mainnet.quiknode.pro/")67https = Net::HTTP.new(url.主机, url.端口)8https.use_ssl = true910请求 = Net::HTTP::POST.new(url)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
1require "uri"2require "json"3require "net/http"45url = URI("https://docs-demo.solana-mainnet.quiknode.pro/")67https = Net::HTTP.new(url.主机, url.端口)8https.use_ssl = true910请求 = Net::HTTP::POST.new(url)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 (error) {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 (error) {10console.error("Error fetching blocks:", error);11}12})();
1const web3 = require("@solana/web3.js");2(async () => {3const solana = new web3.连接(“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.连接(“https://docs-demo.solana-mainnet.quiknode.pro/”);4console.log(await solana.getBlocks(5, 10));5})();6
1from solana.rpc.api import Client2solana_client = 客户端(“https://docs-demo.solana-mainnet.quiknode.pro/”)3print(solana_client.get_blocks(5, 10))
1from solana.rpc.api import Client2solana_client = 客户端(“https://docs-demo.solana-mainnet.quiknode.pro/”)3print(solana_client.get_blocks(5, 10))
1使用 reqwest::header;2使用 reqwest::客户端;3使用 std::error::错误;45#[tokio::main]6async fn main() -> Result<(), Box<dyn Error>> {7let mut 头文件 = header::HeaderMap::new();8标题.插入("Content-Type", "application/json".parse().unwrap());910let 客户端 = Client::new();11let json_data = r#"12{13"jsonrpc": "2.0",14"id": 1,15"method": "getBlocks",16"params": [175,181019]20}21"#;22let 响应 = 客户端23.帖子(“https://docs-demo.solana-mainnet.quiknode.pro/”)24.标题(标题))25.正文(json_data)26.发送()27.await?;2829let 正文 = 响应.text().await?;30println!("{}", body);3132好的(())33}34
1使用 reqwest::header;2使用 reqwest::客户端;3使用 std::error::错误;45#[tokio::main]6async fn main() -> Result<(), Box<dyn Error>> {7let mut 头文件 = header::HeaderMap::new();8标题.插入("Content-Type", "application/json".parse().unwrap());910let 客户端 = Client::new();11let json_data = r#"12{13"jsonrpc": "2.0",14"id": 1,15"method": "getBlocks",16"params": [175,181019]20}21"#;22let 响应 = 客户端23.帖子(“https://docs-demo.solana-mainnet.quiknode.pro/”)24.标题(标题))25.正文(json_data)26.发送()27.await?;2829let 正文 = 响应.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}