listLatestBlocks Query
Parameters
block
integer
REQUIRED
Loading...
Returns
data
object
Loading...
blocks
object
Loading...
nodes
array
Loading...
id
string
Loading...
transactions
array
Loading...
id
string
Loading...
inputAssetIds
array
Loading...
inputs
array
Loading...
__typename
string
Loading...
owner
string
Loading...
utxoId
string
Loading...
amount
string
Loading...
assetId
string
Loading...
outputs
array
Loading...
__typename
string
Loading...
inputIndex
string
Loading...
balanceRoot
string
Loading...
stateRoot
string
Loading...
to
string
Loading...
amount
string
Loading...
assetId
string
Loading...
Request
curl --location 'https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql' \ --header 'Accept: application/json' \ --header 'Content-Type: application/json' \ --data '{ "query": "query LatestBlocks { blocks(last: 5) { nodes { id transactions { id inputAssetIds inputs { __typename ... on InputCoin { owner utxoId amount assetId } ... on InputContract { utxoId contractId } ... on InputMessage { sender recipient amount data } } outputs { __typename ... on CoinOutput { to amount assetId } ... on ContractOutput { inputIndex balanceRoot stateRoot } ... on ChangeOutput { to amount assetId } ... on VariableOutput { to amount assetId } ... on ContractCreated { contract stateRoot } } } } } }" }'
const LATEST_BLOCKS_QUERY = ` query LatestBlocks { blocks(last: 5) { nodes { id transactions { id inputAssetIds inputs { __typename ... on InputCoin { owner utxoId amount assetId } ... on InputContract { utxoId contractId } ... on InputMessage { sender recipient amount data } } outputs { __typename ... on CoinOutput { to amount assetId } ... on ContractOutput { inputIndex balanceRoot stateRoot } ... on ChangeOutput { to amount assetId } ... on VariableOutput { to amount assetId } ... on ContractCreated { contract stateRoot } } } } } } `; const fetchLatestBlocks = async () => { try { const response = await fetch('https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql', { method: 'POST', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', }, body: JSON.stringify({ query: LATEST_BLOCKS_QUERY, }), }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const result = await response.json(); console.log('Latest Blocks:', result.data.blocks.nodes); } catch (error) { console.error('Error fetching latest blocks:', error); } }; fetchLatestBlocks();
const myHeaders = new Headers(); myHeaders.append("Accept", "application/json"); myHeaders.append("Content-Type", "application/json"); const raw = JSON.stringify({ "query": "query LatestBlocks { blocks(last: 5) { nodes { id transactions { id inputAssetIds inputs { __typename ... on InputCoin { owner utxoId amount assetId } ... on InputContract { utxoId contractId } ... on InputMessage { sender recipient amount data } } outputs { __typename ... on CoinOutput { to amount assetId } ... on ContractOutput { inputIndex balanceRoot stateRoot } ... on ChangeOutput { to amount assetId } ... on VariableOutput { to amount assetId } ... on ContractCreated { contract stateRoot } } } } } }" }); const requestOptions = { method: "POST", headers: myHeaders, body: raw, redirect: "follow" }; fetch("https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql", requestOptions) .then((response) => response.text()) .then((result) => console.log(result)) .catch((error) => console.error(error));
const { ApolloClient, InMemoryCache, gql } = require('@apollo/client/core'); const fetch = require('cross-fetch'); const client = new ApolloClient({ uri: 'https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql', cache: new InMemoryCache(), fetch: fetch, headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' } }); const LATEST_BLOCKS_QUERY = gql` query LatestBlocks { blocks(last: 5) { nodes { id transactions { id inputAssetIds inputs { __typename ... on InputCoin { owner utxoId amount assetId } ... on InputContract { utxoId contractId } ... on InputMessage { sender recipient amount data } } outputs { __typename ... on CoinOutput { to amount assetId } ... on ContractOutput { inputIndex balanceRoot stateRoot } ... on ChangeOutput { to amount assetId } ... on VariableOutput { to amount assetId } ... on ContractCreated { contract stateRoot } } } } } } `; client.query({ query: LATEST_BLOCKS_QUERY }) .then(result => { console.log('Latest Blocks:', JSON.stringify(result.data, null, 2)); }) .catch(error => console.error('Error:', error));
import requests import json url = "https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql" payload = json.dumps({ "query": "query LatestBlocks { blocks(last: 5) { nodes { id transactions { id inputAssetIds inputs { __typename ... on InputCoin { owner utxoId amount assetId } ... on InputContract { utxoId contractId } ... on InputMessage { sender recipient amount data } } outputs { __typename ... on CoinOutput { to amount assetId } ... on ContractOutput { inputIndex balanceRoot stateRoot } ... on ChangeOutput { to amount assetId } ... on VariableOutput { to amount assetId } ... on ContractCreated { contract stateRoot } } } } } }" }) headers = { 'Accept': 'application/json', 'Content-Type': 'application/json' } response = requests.request("POST", url, headers=headers, data=payload) print(response.text)
require "uri" require "json" require "net/http" url = URI("https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Post.new(url) request["Accept"] = "application/json" request["Content-Type"] = "application/json" request.body = JSON.dump({ "query": "query LatestBlocks { blocks(last: 5) { nodes { id transactions { id inputAssetIds inputs { __typename ... on InputCoin { owner utxoId amount assetId } ... on InputContract { utxoId contractId } ... on InputMessage { sender recipient amount data } } outputs { __typename ... on CoinOutput { to amount assetId } ... on ContractOutput { inputIndex balanceRoot stateRoot } ... on ChangeOutput { to amount assetId } ... on VariableOutput { to amount assetId } ... on ContractCreated { contract stateRoot } } } } } }" }) response = https.request(request) puts response.read_body
Don't have an account yet?
Create your QuickNode endpoint in seconds and start building
Get started for free