AnnualProvisions gRPC Method
Parâmetros
Este método não aceita quaisquer parâmetros
Devoluções
annual_provisions
cadeia de caracteres
A carregar...
Pedido
1pacote principal23importar (4"contexto"5"crypto/tls"6"encoding/json"7"fmt"8"registo"9"time"1011"google.golang.org/grpc"12"google.golang.org/grpc/credentials"1314minttypes "celestia-grpc/celestia/mint/v1"15)1617// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token18// For eg: QN Endpoint: https://docs-demo.celestia-mainnet.quiknode.pro/abcde12345678919// endpoint will be: docs-demo.celestia-mainnet.quiknode.pro:9090 {9090 is the port number for Celestia gRPC}20// token will be : abcde1234567892122var token = "YOUR_TOKEN"23var endpoint = "YOUR_ENDPOINT:9090"2425tipo auth estrutura {26token string27}2829func (a *auth) GetRequestMetadata(ctx contexto.Context, uri ...string) (mapa[string]string, erro) {30return map[string]string{31"x-token": a.token,32}, nil33}3435func (a *auth) RequireTransportSecurity() bool {36return false37}3839func main() {40opts := []grpc.DialOption{41grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{})),42grpc.WithPerRPCCredentials(&auth{token}),43}4445// Create gRPC connection46conn, err := grpc.Dial(endpoint, opts...)47if err != nil {48log.Fatalf("Failed to connect to Celestia gRPC server: %v", err)49}50defer conn.Close()5152client := minttypes.NewQueryClient(conn)5354ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)55defer cancel()5657provisionsResp, err := client.AnnualProvisions(ctx, &minttypes.QueryAnnualProvisionsRequest{})58if err != nil {59log.Printf("Failed to query annual provisions: %v", err)60} else {61jsonData, _ := json.MarshalIndent(provisionsResp, "", " ")62fmt.Println(string(jsonData))63}64}
1pacote principal23importar (4"contexto"5"crypto/tls"6"encoding/json"7"fmt"8"registo"9"time"1011"google.golang.org/grpc"12"google.golang.org/grpc/credentials"1314minttypes "celestia-grpc/celestia/mint/v1"15)1617// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token18// For eg: QN Endpoint: https://docs-demo.celestia-mainnet.quiknode.pro/abcde12345678919// endpoint will be: docs-demo.celestia-mainnet.quiknode.pro:9090 {9090 is the port number for Celestia gRPC}20// token will be : abcde1234567892122var token = "YOUR_TOKEN"23var endpoint = "YOUR_ENDPOINT:9090"2425tipo auth estrutura {26token string27}2829func (a *auth) GetRequestMetadata(ctx contexto.Context, uri ...string) (mapa[string]string, erro) {30return map[string]string{31"x-token": a.token,32}, nil33}3435func (a *auth) RequireTransportSecurity() bool {36return false37}3839func main() {40opts := []grpc.DialOption{41grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{})),42grpc.WithPerRPCCredentials(&auth{token}),43}4445// Create gRPC connection46conn, err := grpc.Dial(endpoint, opts...)47if err != nil {48log.Fatalf("Failed to connect to Celestia gRPC server: %v", err)49}50defer conn.Close()5152client := minttypes.NewQueryClient(conn)5354ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)55defer cancel()5657provisionsResp, err := client.AnnualProvisions(ctx, &minttypes.QueryAnnualProvisionsRequest{})58if err != nil {59log.Printf("Failed to query annual provisions: %v", err)60} else {61jsonData, _ := json.MarshalIndent(provisionsResp, "", " ")62fmt.Println(string(jsonData))63}64}
Ainda não tem uma conta?
Crie o seu ponto de extremidade Quicknode em segundos e comece a desenvolver
Comece gratuitamente