getLastBlock Query
Paramètres
Cette méthode n'accepte aucun paramètre
Retours
données
objet
Chargement en cours...
chaîne
objet
Chargement en cours...
latestBlock
objet
Chargement en cours...
id
chaîne de caractères
Chargement en cours...
hauteur
chaîne de caractères
Chargement en cours...
Demande
1curl --location 'https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql' \2--header 'Accept: application/json' \3--en-tête 'Content-Type: application/json' \4--données '{5"query": "{ chain { latestBlock { id height } } }"6}'
1curl --location 'https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql' \2--header 'Accept: application/json' \3--en-tête 'Content-Type: application/json' \4--données '{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', {15method: 'POST',16headers: {17'Accept': 'application/json',18'Content-Type': 'application/json',19},20body: JSON.stringify({21query: LATEST_BLOCK_QUERY,22}),23});2425if (!response.ok) {26throw new Error(`HTTP error! status: ${response.status}`);27}2829const result = 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', {15method: 'POST',16headers: {17'Accept': 'application/json',18'Content-Type': 'application/json',19},20body: JSON.stringify({21query: LATEST_BLOCK_QUERY,22}),23});2425if (!response.ok) {26throw new Error(`HTTP error! status: ${response.status}`);27}2829const result = 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");3myHeaders.ajouter(« Content-Type », « application/json »);45const brut = JSON.stringify({6"query": "{ chain { latestBlock { id height } } }"7});89const requestOptions = {10méthode: « POST »,11en-têtes: myHeaders,12corps: brut,13redirection: « suivre »14};1516fetch("https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql", requestOptions)17.puis((réponse) => réponse.texte())18.puis((résultat) => console.log(résultat))19.catch((erreur) => console.erreur(erreur));
1const myHeaders = new Headers();2myHeaders.append("Accept", "application/json");3myHeaders.ajouter(« Content-Type », « application/json »);45const brut = JSON.stringify({6"query": "{ chain { latestBlock { id height } } }"7});89const requestOptions = {10méthode: « POST »,11en-têtes: myHeaders,12corps: brut,13redirection: « suivre »14};1516fetch("https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql", requestOptions)17.puis((réponse) => réponse.texte())18.puis((résultat) => console.log(résultat))19.catch((erreur) => console.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(),7fetch: fetch,8headers: {9'Accept': 'application/json',10'Content-Type': 'application/json'11}12});1314const LATEST_BLOCK_QUERY = gql`15{16chain {17latestBlock {18id19hauteur20}21}22}23`;2425client.query({26query: LATEST_BLOCK_QUERY27})28.then(result => {29const latestBlock = result.data.chain.latestBlock;30console.log('Latest Block Information:');31console.log(`ID: ${latestBlock.id}`);32console.log(`Height: ${latestBlock.height}`);33})34.catch(error => console.error('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(),7fetch: fetch,8headers: {9'Accept': 'application/json',10'Content-Type': 'application/json'11}12});1314const LATEST_BLOCK_QUERY = gql`15{16chain {17latestBlock {18id19hauteur20}21}22}23`;2425client.query({26query: LATEST_BLOCK_QUERY27})28.then(result => {29const latestBlock = result.data.chain.latestBlock;30console.log('Latest Block Information:');31console.log(`ID: ${latestBlock.id}`);32console.log(`Height: ${latestBlock.height}`);33})34.catch(error => console.error('Error:', error));
1import demandes2import json34url = "https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql"56charge utile = json.dumps({7"query": "{ chain { latestBlock { id height } } }"8})9en-têtes = {10'Accept': 'application/json',11« Content-Type »: 'application/json'12}1314réponse = demandes.demande(« POST », url, en-têtes=en-têtes, données=charge utile)1516imprimer(réponse.texte)17
1import demandes2import json34url = "https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql"56charge utile = json.dumps({7"query": "{ chain { latestBlock { id height } } }"8})9en-têtes = {10'Accept': 'application/json',11« Content-Type »: 'application/json'12}1314réponse = demandes.demande(« POST », url, en-têtes=en-têtes, données=charge utile)1516imprimer(réponse.texte)17
1nécessite « uri »2require « json »3nécessite « net/http »45url = URI("https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql")67https = Net::HTTP.new(url.serveur, url.port)8https.use_ssl = true910demande = Net::HTTP::POST.nouveau(URL)11demande[« Accepter »] = « application/json »12demande[« Content-Type »] = « application/json »13demande.corps = JSON.dump({14"query": "{ chain { latestBlock { id height } } }"15})1617réponse = https.requête(requête)18affiche la réponse.read_body19
1nécessite « uri »2require « json »3nécessite « net/http »45url = URI("https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql")67https = Net::HTTP.new(url.serveur, url.port)8https.use_ssl = true910demande = Net::HTTP::POST.nouveau(URL)11demande[« Accepter »] = « application/json »12demande[« Content-Type »] = « application/json »13demande.corps = JSON.dump({14"query": "{ chain { latestBlock { id height } } }"15})1617réponse = https.requête(requête)18affiche la réponse.read_body19
Vous n'avez pas encore de compte ?
Créez votreendpoint Quicknode endpoint quelques secondes et commencez à développer
Commencez gratuitement