getSlot gRPC Method - Solana gRPC
Solana gRPC está incluido en los planes Scale y Business. En los planes Build y Accelerate, sigue estando disponible a través del complemento Solana gRPC.
Parámetros
Este método no admite ningún parámetro
Devoluciones
ranura
cadena
Cargando...
Solicitud
1paquete principal23import (4«contexto»5«crypto/tls»6«fmt»7«registro»8«tiempo»910pb «yellowstone/proto»111213"google.golang.org/grpc"14"google.golang.org/grpc/credentials"15"google.golang.org/grpc/encoding/gzip"16"google.golang.org/grpc/keepalive"17)1819// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token20// For eg: QN Endpoint: https://docs-demo.solana-mainnet.quiknode.pro/abcde12345678921// endpoint will be: docs-demo.solana-mainnet.quiknode.pro:10000 {10000 is the port number for gRPC}22// token will be : abcde1234567892324var (25punto final = "TU_QN_ENDPOINT:10000"26token = "TU_NÚMERO_DE_TOKEN"27)2829func main() {30opts := []grpc.DialOption{31grpc.WithTransportCredentials(credenciales.NewTLS(&tls.Config{})),32grpc.WithKeepaliveParams(kacp),33grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(1024*1024*1024), grpc.UseCompressor(gzip.Nombre)),34grpc.WithPerRPCCredentials(tokenAuth{token: token}),35}3637conn, err := grpc.NewClient(punto de conexión, opts...)38si err != nil {39registro.Fatalf(«Error al conectarse: %v», err)40}41aplazar conn.Cerrar()4243cliente := pb.NewGeyserClient(conn)4445ctx, cancel := contexto.WithTimeout(contexto.Background(), 10*vez.Segundo)46aplazar cancelar()4748getSlot, err := client.GetSlot(ctx, &pb.GetSlotRequest{})49si err != nil {50log.Fatalf("Failed to get slot: %v", err)51}52fmt.Printf(" Get Slot: %+v\n", getSlot)5354}
1paquete principal23import (4«contexto»5«crypto/tls»6«fmt»7«registro»8«tiempo»910pb «yellowstone/proto»111213"google.golang.org/grpc"14"google.golang.org/grpc/credentials"15"google.golang.org/grpc/encoding/gzip"16"google.golang.org/grpc/keepalive"17)1819// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token20// For eg: QN Endpoint: https://docs-demo.solana-mainnet.quiknode.pro/abcde12345678921// endpoint will be: docs-demo.solana-mainnet.quiknode.pro:10000 {10000 is the port number for gRPC}22// token will be : abcde1234567892324var (25punto final = "TU_QN_ENDPOINT:10000"26token = "TU_NÚMERO_DE_TOKEN"27)2829func main() {30opts := []grpc.DialOption{31grpc.WithTransportCredentials(credenciales.NewTLS(&tls.Config{})),32grpc.WithKeepaliveParams(kacp),33grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(1024*1024*1024), grpc.UseCompressor(gzip.Nombre)),34grpc.WithPerRPCCredentials(tokenAuth{token: token}),35}3637conn, err := grpc.NewClient(punto de conexión, opts...)38si err != nil {39registro.Fatalf(«Error al conectarse: %v», err)40}41aplazar conn.Cerrar()4243cliente := pb.NewGeyserClient(conn)4445ctx, cancel := contexto.WithTimeout(contexto.Background(), 10*vez.Segundo)46aplazar cancelar()4748getSlot, err := client.GetSlot(ctx, &pb.GetSlotRequest{})49si err != nil {50log.Fatalf("Failed to get slot: %v", err)51}52fmt.Printf(" Get Slot: %+v\n", getSlot)5354}
1import Client, { CommitmentLevel } from "@triton-one/yellowstone-grpc";23// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token4// For eg: QN Endpoint: https://docs-demo.solana-mainnet.quiknode.pro/abcde1234567895// endpoint will be: docs-demo.solana-mainnet.quiknode.pro:10000 {10000 is the port number for gRPC}6// token will be : abcde12345678978const PUNTO FINAL = "TU_QN_ENDPOINT:10000";9const TOKEN = "TU_NÚMERO_DE_TOKEN";1011asíncrono función main() {12const client = new Client(ENDPOINT, TOKEN, {});1314const compromiso = NivelDeCompromiso.CONFIRMADO;1516prueba {17const slot = await client.getSlot(commitment);18console.log(`Slot Number: ${JSON.stringify(slot, null, 2)}`);1920} catch (error) {21console.error("Error fetching current slot:", error);22}23}2425principal()26.captura((err) => {27consola.error(«Error no gestionado:», err);28proceso.salir(1);29});
1import Client, { CommitmentLevel } from "@triton-one/yellowstone-grpc";23// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token4// For eg: QN Endpoint: https://docs-demo.solana-mainnet.quiknode.pro/abcde1234567895// endpoint will be: docs-demo.solana-mainnet.quiknode.pro:10000 {10000 is the port number for gRPC}6// token will be : abcde12345678978const PUNTO FINAL = "TU_QN_ENDPOINT:10000";9const TOKEN = "TU_NÚMERO_DE_TOKEN";1011asíncrono función main() {12const client = new Client(ENDPOINT, TOKEN, {});1314const compromiso = NivelDeCompromiso.CONFIRMADO;1516prueba {17const slot = await client.getSlot(commitment);18console.log(`Slot Number: ${JSON.stringify(slot, null, 2)}`);1920} catch (error) {21console.error("Error fetching current slot:", error);22}23}2425principal()26.captura((err) => {27consola.error(«Error no gestionado:», err);28proceso.salir(1);29});
¿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