getLastBlock Query
Parámetros
Este método no admite ningún parámetro
Devoluciones
datos
objeto
Cargando...
cadena
objeto
Cargando...
latestBlock
objeto
Cargando...
id
cadena
Cargando...
altura
cadena
Cargando...
Solicitud
1curl --location 'https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql' \2--header 'Accept: application/json' \3--encabezado 'Content-Type: application/json' \4--datos '{5"query": "{ chain { latestBlock { id height } } }"6}'
1curl --location 'https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql' \2--header 'Accept: application/json' \3--encabezado 'Content-Type: application/json' \4--datos '{5"query": "{ chain { latestBlock { id height } } }"6}'
1const LATEST_BLOCK_QUERY = `2query {3chain {4latestBlock {5id6altura7}8}9}10`;1112const fetchLatestBlock = async (): Promise<void> => {13prueba {14const response = await fetch('https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql', {15método: «POST»,16headers: {17«Aceptar»: 'application/json',18«Content-Type»: 'application/json',19},20body: JSON.stringify({21query: LATEST_BLOCK_QUERY,22}),23});2425si (!respuesta.ok) {26throw new Error(`HTTP error! status: ${response.status}`);27}2829const resultado = await respuesta.json();30console.log('Latest Block ID:', result.data.chain.latestBlock.id);31console.log('Latest Block Height:', result.data.chain.latestBlock.height);32} catch (error) {33console.error('Error fetching latest block:', error);34}35};3637fetchLatestBlock();38
1const LATEST_BLOCK_QUERY = `2query {3chain {4latestBlock {5id6altura7}8}9}10`;1112const fetchLatestBlock = async (): Promise<void> => {13prueba {14const response = await fetch('https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql', {15método: «POST»,16headers: {17«Aceptar»: 'application/json',18«Content-Type»: 'application/json',19},20body: JSON.stringify({21query: LATEST_BLOCK_QUERY,22}),23});2425si (!respuesta.ok) {26throw new Error(`HTTP error! status: ${response.status}`);27}2829const resultado = await respuesta.json();30console.log('Latest Block ID:', result.data.chain.latestBlock.id);31console.log('Latest Block Height:', result.data.chain.latestBlock.height);32} catch (error) {33console.error('Error fetching latest block:', error);34}35};3637fetchLatestBlock();38
1const myHeaders = new Headers();2myHeaders.añadir(«Accept», "application/json");3myHeaders.añadir(«Content-Type», "application/json");45const sin procesar = JSON.convertir a cadena({6"query": "{ chain { latestBlock { id height } } }"7});89const requestOptions = {10método: «POST»,11encabezados: myHeaders,12cuerpo: sin procesar,13redirigir: «seguir»14};1516recoger(«https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql», requestOptions)17.entonces((respuesta) => respuesta.texto())18.entonces((resultado) => consola.log(resultado))19.captura((error) => console.error(error));
1const myHeaders = new Headers();2myHeaders.añadir(«Accept», "application/json");3myHeaders.añadir(«Content-Type», "application/json");45const sin procesar = JSON.convertir a cadena({6"query": "{ chain { latestBlock { id height } } }"7});89const requestOptions = {10método: «POST»,11encabezados: myHeaders,12cuerpo: sin procesar,13redirigir: «seguir»14};1516recoger(«https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql», requestOptions)17.entonces((respuesta) => respuesta.texto())18.entonces((resultado) => consola.log(resultado))19.captura((error) => console.error(error));
1const { ApolloClient, InMemoryCache, gql } = require('@apollo/client/core');2const fetch = require('cross-fetch');34const cliente = new ApolloClient({5uri: «https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql»,6caché: nuevo InMemoryCache)(),7recoger: fetch,8headers: {9«Aceptar»: 'application/json',10«Content-Type»: 'application/json'11}12});1314const LATEST_BLOCK_QUERY = gql`15{16chain {17latestBlock {18id19altura20}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.captura(error => console.error('Error:', error));
1const { ApolloClient, InMemoryCache, gql } = require('@apollo/client/core');2const fetch = require('cross-fetch');34const cliente = new ApolloClient({5uri: «https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql»,6caché: nuevo InMemoryCache)(),7recoger: fetch,8headers: {9«Aceptar»: 'application/json',10«Content-Type»: 'application/json'11}12});1314const LATEST_BLOCK_QUERY = gql`15{16chain {17latestBlock {18id19altura20}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.captura(error => console.error('Error:', error));
1import solicitudes2import json34url = "https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql"56carga útil = json.dumps({7"query": "{ chain { latestBlock { id height } } }"8})9encabezados = {10«Aceptar»: 'application/json',11«Content-Type»: 'application/json'12}1314respuesta = solicitudes.solicitud(«POST», url, encabezados=encabezados, datos=carga útil)1516imprimir(respuesta.texto)17
1import solicitudes2import json34url = "https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql"56carga útil = json.dumps({7"query": "{ chain { latestBlock { id height } } }"8})9encabezados = {10«Aceptar»: 'application/json',11«Content-Type»: 'application/json'12}1314respuesta = solicitudes.solicitud(«POST», url, encabezados=encabezados, datos=carga útil)1516imprimir(respuesta.texto)17
1requiere «uri»2require "json"3require «net/http»45url = URI(«https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql»)67https = Net::HTTP.nuevo(url.host, url.puerto)8https.use_ssl = true910solicitud = Net::HTTP::POST.nuevo(URL)11solicitud[«Aceptar»] = «application/json»12solicitud[«Content-Type»] = "application/json"13solicitud.cuerpo = JSON.dump({14"query": "{ chain { latestBlock { id height } } }"15})1617respuesta = https.solicitud(solicitud)18inserta la respuesta.read_body19
1requiere «uri»2require "json"3require «net/http»45url = URI(«https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql»)67https = Net::HTTP.nuevo(url.host, url.puerto)8https.use_ssl = true910solicitud = Net::HTTP::POST.nuevo(URL)11solicitud[«Aceptar»] = «application/json»12solicitud[«Content-Type»] = "application/json"13solicitud.cuerpo = JSON.dump({14"query": "{ chain { latestBlock { id height } } }"15})1617respuesta = https.solicitud(solicitud)18inserta la respuesta.read_body19
¿Aún no tienes una cuenta?
Crea tu punto de conexión de Quicknode en cuestión de segundos y empieza a desarrollar
Empieza gratis