getVersion gRPC Method - Solana gRPC
Solana gRPC is included with Scale plans and up. Learn more on our pricing page.
参数
该方法不接受任何参数
退货
版本
对象
正在加载...
package
字符串
正在加载...
版本
字符串
正在加载...
proto
字符串
正在加载...
solana
字符串
正在加载...
git
字符串
正在加载...
rustc
字符串
正在加载...
buildts
字符串
正在加载...
额外
对象
正在加载...
hostname
字符串
正在加载...
请求
1包 main23import (4"上下文"5"crypto/tls"6"fmt"7“日志”8“时间”910pb "yellowstone"111213"google.golang.grpc"14"google.golang.grpc"15"google.golang.grpc"16"google.golang.grpc"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:443 {443 is the port number for gRPC}22// token will be : abcde1234567892324var (25endpoint = "YOUR_QN_ENDPOINT:443"26token = "您的令牌编号"27)2829var kacp = keepalive.ClientParameters{30Time: 10 * time.Second,31Timeout: time.Second,32PermitWithoutStream: true,33}3435type tokenAuth struct {36token 字符串37}3839func (t tokenAuth) GetRequestMetadata(ctx context.Context, in ...string) (map[string]string, error) {40返回 map[字符串]字符串{41"x-token": t.token,42}, nil43}4445func (tokenAuth) RequireTransportSecurity() bool {46返回 true47}4849func main() {50opts := []grpc.DialOption{51grpc.WithTransportCredentials(凭证.NewTLS(&tls.配置{})),52grpc.WithKeepaliveParams(kacp),53grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(1024*1024*1024), grpc.UseCompressor(gzip.名称)),54grpc.WithPerRPCCredentials(tokenAuth{token: token}),55}5657conn, err := grpc.NewClient(endpoint, opts...)58如果 err != nil {59log.Fatalf("连接失败:%v", err)60}61推迟 conn.关闭()6263client := pb.NewGeyserClient(conn)6465ctx, 取消 := context.带超时(context.Background(), 10*时间.第二次)66推迟 取消()6768version, err := client.GetVersion(ctx, &pb.GetVersionRequest{})69如果 err != nil {70log.Fatalf("Failed to get version: %v", err)71}7273fmt.Printf("Yellowstone gRPC Version:\n")74fmt.Printf(" GeyserGrpc: %s\n", version.GetVersion())7576}77
1包 main23import (4"上下文"5"crypto/tls"6"fmt"7“日志”8“时间”910pb "yellowstone"111213"google.golang.grpc"14"google.golang.grpc"15"google.golang.grpc"16"google.golang.grpc"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:443 {443 is the port number for gRPC}22// token will be : abcde1234567892324var (25endpoint = "YOUR_QN_ENDPOINT:443"26token = "您的令牌编号"27)2829var kacp = keepalive.ClientParameters{30Time: 10 * time.Second,31Timeout: time.Second,32PermitWithoutStream: true,33}3435type tokenAuth struct {36token 字符串37}3839func (t tokenAuth) GetRequestMetadata(ctx context.Context, in ...string) (map[string]string, error) {40返回 map[字符串]字符串{41"x-token": t.token,42}, nil43}4445func (tokenAuth) RequireTransportSecurity() bool {46返回 true47}4849func main() {50opts := []grpc.DialOption{51grpc.WithTransportCredentials(凭证.NewTLS(&tls.配置{})),52grpc.WithKeepaliveParams(kacp),53grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(1024*1024*1024), grpc.UseCompressor(gzip.名称)),54grpc.WithPerRPCCredentials(tokenAuth{token: token}),55}5657conn, err := grpc.NewClient(endpoint, opts...)58如果 err != nil {59log.Fatalf("连接失败:%v", err)60}61推迟 conn.关闭()6263client := pb.NewGeyserClient(conn)6465ctx, 取消 := context.带超时(context.Background(), 10*时间.第二次)66推迟 取消()6768version, err := client.GetVersion(ctx, &pb.GetVersionRequest{})69如果 err != nil {70log.Fatalf("Failed to get version: %v", err)71}7273fmt.Printf("Yellowstone gRPC Version:\n")74fmt.Printf(" GeyserGrpc: %s\n", version.GetVersion())7576}77
1import Client 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: https://docs-demo.solana-mainnet.quiknode.pro:443 {443 is the port number for gRPC}6// token will be : abcde12345678978const ENDPOINT = "https://YOUR_QN_ENDPOINT:443";9const TOKEN = "您的令牌编号";1011async 函数 main() {12const client = new Client(ENDPOINT, TOKEN, {13grpcDefaultCompressionAlgorithm: 0, // 0 = gzip, 1 = zstd14});15await client.connect();1617试一试 {18const version = await client.getVersion();19console.log("Solana Version Information:");20console.log(`getVersion: ${version.version}`);21} catch (error) {22console.error("Error fetching version:", error);23}24}2526主()27.catch((err) => {28控制台.错误("未处理的错误:", err);29流程.退出(1);30});31
1import Client 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: https://docs-demo.solana-mainnet.quiknode.pro:443 {443 is the port number for gRPC}6// token will be : abcde12345678978const ENDPOINT = "https://YOUR_QN_ENDPOINT:443";9const TOKEN = "您的令牌编号";1011async 函数 main() {12const client = new Client(ENDPOINT, TOKEN, {13grpcDefaultCompressionAlgorithm: 0, // 0 = gzip, 1 = zstd14});15await client.connect();1617试一试 {18const version = await client.getVersion();19console.log("Solana Version Information:");20console.log(`getVersion: ${version.version}`);21} catch (error) {22console.error("Error fetching version:", error);23}24}2526主()27.catch((err) => {28控制台.错误("未处理的错误:", err);29流程.退出(1);30});31