TxStatus gRPC Method
参数
tx_id
字符串
必填
正在加载...
退货
高度
整数
正在加载...
索引
整数
正在加载...
execution_code
整数
正在加载...
错误
字符串
正在加载...
状态
字符串
正在加载...
请求
1包 main23导入 (4"上下文"5"crypto/tls"6"encoding/json"7"fmt"8"日志"9"time"1011"google.golang.org/grpc"12"google.golang.org/grpc/credentials"1314txtypes "celestia-grpc/celestia/core/v1/tx"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"2425类型 auth 结构体 {26token 字符串27}2829func (a *auth) GetRequestMetadata(ctx 上下文.上下文, uri ...字符串) (map[字符串]字符串, error) {30返回 map[字符串]字符串{31“x-token”: a.令牌,32}, nil33}3435func (a *auth) RequireTransportSecurity() bool {36返回 false37}3839func main() {40opts := []grpc.DialOption{41grpc.WithTransportCredentials(凭证.NewTLS(&tls.配置{})),42grpc.WithPerRPC凭据(&auth{令牌}),43}4445// Create gRPC connection46conn, err := grpc.Dial(endpoint, opts...)47如果 err != nil {48log.Fatalf("Failed to connect to Celestia gRPC server: %v", err)49}50defer conn.Close()5152client := txtypes.NewTxClient(conn)5354ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)55defer cancel()5657// Example transaction hash (64 characters hex string)58// Replace with an actual transaction hash59txHash := "3ae0d131ce0e50de8fedf4041ae2ca4bc7be0d208cd7e39baad526ac3794fe09"6061resp, err := client.TxStatus(ctx, &txtypes.TxStatusRequest{62TxId: txHash,63})64如果 err != nil {65log.Fatalf("Failed to query transaction status: %v", err)66}6768jsonData, err := json.MarshalIndent(resp, "", " ")69如果 err != nil {70log.Printf("Error converting to JSON: %v", err)71} else {72fmt.Println("\nOutput:")73fmt.Println(string(jsonData))74}75}
1包 main23导入 (4"上下文"5"crypto/tls"6"encoding/json"7"fmt"8"日志"9"time"1011"google.golang.org/grpc"12"google.golang.org/grpc/credentials"1314txtypes "celestia-grpc/celestia/core/v1/tx"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"2425类型 auth 结构体 {26token 字符串27}2829func (a *auth) GetRequestMetadata(ctx 上下文.上下文, uri ...字符串) (map[字符串]字符串, error) {30返回 map[字符串]字符串{31“x-token”: a.令牌,32}, nil33}3435func (a *auth) RequireTransportSecurity() bool {36返回 false37}3839func main() {40opts := []grpc.DialOption{41grpc.WithTransportCredentials(凭证.NewTLS(&tls.配置{})),42grpc.WithPerRPC凭据(&auth{令牌}),43}4445// Create gRPC connection46conn, err := grpc.Dial(endpoint, opts...)47如果 err != nil {48log.Fatalf("Failed to connect to Celestia gRPC server: %v", err)49}50defer conn.Close()5152client := txtypes.NewTxClient(conn)5354ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)55defer cancel()5657// Example transaction hash (64 characters hex string)58// Replace with an actual transaction hash59txHash := "3ae0d131ce0e50de8fedf4041ae2ca4bc7be0d208cd7e39baad526ac3794fe09"6061resp, err := client.TxStatus(ctx, &txtypes.TxStatusRequest{62TxId: txHash,63})64如果 err != nil {65log.Fatalf("Failed to query transaction status: %v", err)66}6768jsonData, err := json.MarshalIndent(resp, "", " ")69如果 err != nil {70log.Printf("Error converting to JSON: %v", err)71} else {72fmt.Println("\nOutput:")73fmt.Println(string(jsonData))74}75}