getLastBlock Query
Paramètres
Cette méthode n'accepte aucun paramètre
Renvoie
données
objet
Chargement...
chaîne
objet
Chargement...
latestBlock
objet
Chargement...
ID
chaîne de caractères
Chargement...
Hauteur
chaîne de caractères
Chargement...
Requête
1curl --location 'https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql' \2--en-tête 'Accept: application/json' \3--header 'Content-Type: application/json' \4--data '{5"query": "{ chain { latestBlock { id height } } }"6}'
1curl --location 'https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql' \2--en-tête 'Accept: application/json' \3--header 'Content-Type: application/json' \4--data '{5"query": "{ chain { latestBlock { id height } } }"6}'
1const LATEST_BLOCK_QUERY = `2query {3chain {4latestBlock {5ID6Hauteur7}8}9}10`;1112const fetchLatestBlock = async (): Promise<void> => {13essayer {14const response = await fetch('https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql', {15méthode: « POST »,16headers: {17« Accepter »: 'application/json',18« Content-Type »: 'application/json',19},20body: JSON.stringify({21query: LATEST_BLOCK_QUERY,22}),23});2425si (!réponse.ok) {26throw new Error(`HTTP error! status: ${response.status}`);27}2829const résultat = await response.json();30console.log('Latest Block ID:', result.data.chain.latestBlock.id);31console.log('Latest Block Height:', result.data.chain.latestBlock.height);32} catch (erreur) {33console.error('Error fetching latest block:', error);34}35};3637fetchLatestBlock();38
1const LATEST_BLOCK_QUERY = `2query {3chain {4latestBlock {5ID6Hauteur7}8}9}10`;1112const fetchLatestBlock = async (): Promise<void> => {13essayer {14const response = await fetch('https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql', {15méthode: « POST »,16headers: {17« Accepter »: 'application/json',18« Content-Type »: 'application/json',19},20body: JSON.stringify({21query: LATEST_BLOCK_QUERY,22}),23});2425si (!réponse.ok) {26throw new Error(`HTTP error! status: ${response.status}`);27}2829const résultat = await response.json();30console.log('Latest Block ID:', result.data.chain.latestBlock.id);31console.log('Latest Block Height:', result.data.chain.latestBlock.height);32} catch (erreur) {33console.error('Error fetching latest block:', error);34}35};3637fetchLatestBlock();38
1const myHeaders = new Headers();2myHeaders.append("Accept", "application/json");3mesEnTêtes.ajouter("Content-Type", "application/json");45const brut = JSON.stringify({6"query": "{ chain { latestBlock { id height } } }"7});89const requestOptions = {10méthode: « POST »,11headers: myHeaders,12body: raw,13redirect: "follow"14};1516récupérer(« https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql », requestOptions)17.then((response) => response.text())18.then((result) => console.log(result))19.catch((error) => console.error(error));
1const myHeaders = new Headers();2myHeaders.append("Accept", "application/json");3mesEnTêtes.ajouter("Content-Type", "application/json");45const brut = JSON.stringify({6"query": "{ chain { latestBlock { id height } } }"7});89const requestOptions = {10méthode: « POST »,11headers: myHeaders,12body: raw,13redirect: "follow"14};1516récupérer(« https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql », requestOptions)17.then((response) => response.text())18.then((result) => console.log(result))19.catch((error) => console.error(error));
1const { ApolloClient, InMemoryCache, gql } = require('@apollo/client/core');2const fetch = require('cross-fetch');34const client = new ApolloClient({5uri: « https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql »,6cache: new InMemoryCache(),7récupérer: récupérer,8headers: {9« Accepter »: 'application/json',10« Content-Type »: 'application/json'11}12});1314const LATEST_BLOCK_QUERY = gql`15{16chain {17latestBlock {18ID19Hauteur20}21}22}23`;2425client.requête({26query: LATEST_BLOCK_QUERY27})28.puis(résultat => {29const latestBlock = result.data.chain.latestBlock;30console.log('Latest Block Information:');31console.log(`ID: ${latestBlock.id}`);32console.log(`Height: ${latestBlock.height}`);33})34.catch(erreur => console.erreur('Erreur :', erreur));
1const { ApolloClient, InMemoryCache, gql } = require('@apollo/client/core');2const fetch = require('cross-fetch');34const client = new ApolloClient({5uri: « https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql »,6cache: new InMemoryCache(),7récupérer: récupérer,8headers: {9« Accepter »: 'application/json',10« Content-Type »: 'application/json'11}12});1314const LATEST_BLOCK_QUERY = gql`15{16chain {17latestBlock {18ID19Hauteur20}21}22}23`;2425client.requête({26query: LATEST_BLOCK_QUERY27})28.puis(résultat => {29const latestBlock = result.data.chain.latestBlock;30console.log('Latest Block Information:');31console.log(`ID: ${latestBlock.id}`);32console.log(`Height: ${latestBlock.height}`);33})34.catch(erreur => console.erreur('Erreur :', erreur));
1import requests2import json34url = « https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql »56payload = json.dumps({7"query": "{ chain { latestBlock { id height } } }"8})9headers = {10'Accept': 'application/json',11'Content-Type': 'application/json'12}1314response = requests.request("POST", url, headers=headers, data=payload)1516print(response.text)17
1import requests2import json34url = « https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql »56payload = json.dumps({7"query": "{ chain { latestBlock { id height } } }"8})9headers = {10'Accept': 'application/json',11'Content-Type': 'application/json'12}1314response = requests.request("POST", url, headers=headers, data=payload)1516print(response.text)17
1require "uri"2require "json"3require "net/http"45url = URI(« https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql »)67https = Net::HTTP.new(url.host, url.port)8https.use_ssl = true910request = Net::HTTP::Post.new(url)11request["Accept"] = "application/json"12request["Content-Type"] = "application/json"13request.body = JSON.dump({14"query": "{ chain { latestBlock { id height } } }"15})1617response = https.request(request)18puts response.read_body19
1require "uri"2require "json"3require "net/http"45url = URI(« https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql »)67https = Net::HTTP.new(url.host, url.port)8https.use_ssl = true910request = Net::HTTP::Post.new(url)11request["Accept"] = "application/json"12request["Content-Type"] = "application/json"13request.body = JSON.dump({14"query": "{ chain { latestBlock { id height } } }"15})1617response = https.request(request)18puts response.read_body19
Vous n'avez pas encore de compte ?
Créez votre endpoint Quicknode en quelques secondes et commencez à développer
Commencez gratuitement