getSlot gRPC Method - Solana gRPC
Solana gRPC is included with Scale and Business plans. On Build and Accelerate plans, it remains available via the Solana gRPC add-on.
パラメータ
このメソッドはパラメータを受け付けません
返品
スロット
文字列
読み込み中...
リクエスト
1パッケージ main23import (4「文脈」5"crypto/tls"6"fmt"7「log」8"time"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 (25endpoint = "YOUR_QN_ENDPOINT:10000"26token = "YOUR_TOKEN_NUMBER"27)2829func main() {30opts := []grpc.DialOption{31grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{})),32grpc.WithKeepaliveParams(kacp),33grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(1024*1024*1024), grpc.UseCompressor(gzip.Name)),34grpc.WithPerRPCCredentials(tokenAuth{token: token}),35}3637conn, err := grpc.NewClient(endpoint, opts...)38もし err != nil {39log.Fatalf("Failed to connect: %v", err)40}41defer conn.Close()4243client := pb.NewGeyserClient(conn)4445ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)46defer cancel()4748getSlot, err := client.GetSlot(ctx, &pb.GetSlotRequest{})49もし err != nil {50log.Fatalf("Failed to get slot: %v", err)51}52fmt.Printf(" Get Slot: %+v\n", getSlot)5354}
1パッケージ main23import (4「文脈」5"crypto/tls"6"fmt"7「log」8"time"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 (25endpoint = "YOUR_QN_ENDPOINT:10000"26token = "YOUR_TOKEN_NUMBER"27)2829func main() {30opts := []grpc.DialOption{31grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{})),32grpc.WithKeepaliveParams(kacp),33grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(1024*1024*1024), grpc.UseCompressor(gzip.Name)),34grpc.WithPerRPCCredentials(tokenAuth{token: token}),35}3637conn, err := grpc.NewClient(endpoint, opts...)38もし err != nil {39log.Fatalf("Failed to connect: %v", err)40}41defer conn.Close()4243client := pb.NewGeyserClient(conn)4445ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)46defer cancel()4748getSlot, err := client.GetSlot(ctx, &pb.GetSlotRequest{})49もし 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 ENDPOINT = "YOUR_QN_ENDPOINT:10000";9const TOKEN = "YOUR_TOKEN_NUMBER";1011async 関数 main() {12const client = new Client(ENDPOINT, TOKEN, {});1314const commitment = CommitmentLevel.CONFIRMED;1516try {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}2425main()26.catch((err) => {27console.error("Unhandled error:", err);28process.exit(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 ENDPOINT = "YOUR_QN_ENDPOINT:10000";9const TOKEN = "YOUR_TOKEN_NUMBER";1011async 関数 main() {12const client = new Client(ENDPOINT, TOKEN, {});1314const commitment = CommitmentLevel.CONFIRMED;1516try {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}2425main()26.catch((err) => {27console.error("Unhandled error:", err);28process.exit(1);29});