EstimateGasPrice gRPC Method
パラメータ
tx_priority
文字列
必須
読み込み中...
TX_PRIORITY_UNSPECIFIED
整数
読み込み中...
TX_PRIORITY_LOW
整数
読み込み中...
TX_PRIORITY_MEDIUM
整数
読み込み中...
TX_PRIORITY_HIGH
整数
読み込み中...
返します
estimated_gas_price
整数
読み込み中...
リクエスト
1パッケージ main23インポート (4「文脈」5"crypto/tls"6"encoding/json"7"fmt"8「ログ」9「時間」1011"google.golang.grpc"12"google.golang.grpc"1314gasestimation "celestia-grpc/celestia/core/v1/gas_estimation"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 トークン = "YOUR_TOKEN"23var endpoint = "YOUR_ENDPOINT:9090"2425タイプ auth 構造体 {26トークン 文字列27}2829func (a *auth) GetRequestMetadata(ctx コンテキスト.Context, uri ...文字列) (map[文字列]文字列, エラー) {30戻る map[文字列]文字列{31「x-token」: a.トークン,32}, nil33}3435func (a *auth) RequireTransportSecurity(auth) bool {36戻る false37}3839func main() {40opts := []grpc.DialOption{41grpc.WithTransportCredentialsWithTransportCredentials(credentials.NewTLS(&tls.設定{})),42grpc.WithPerRPCCredentials(&auth{token}),43}4445// Create gRPC connection46conn, err := grpc.Dial(endpoint, opts...)47もし err != nil {48log.Fatalf("Celestia gRPC への接続に失敗しました: %v", err)49}50延期 conn.閉じる()5152client := gasestimation.NewGasEstimatorClient(conn)5354ctx, cancel := context.WithTimeout)(コンテキスト.Background(), 10*時間.2番目)55延期 延期()5657resp, err := client.EstimateGasPrice(ctx, &gasestimation.EstimateGasPriceRequest{58TxPriority: gasestimation.TxPriority_TX_PRIORITY_MEDIUM,59})60もし err != nil {61log.Fatalf("Failed to estimate gas price: %v", err)62}6364jsonData, err := json.MarshalIndent(resp, "", " ")65もし err != nil {66log.Printf("Error converting to JSON: %v", err)67} else {68fmt.Println("\nOutput:")69fmt.PrintlnPrintln文字列(jsonData))70}71}
1パッケージ main23インポート (4「文脈」5"crypto/tls"6"encoding/json"7"fmt"8「ログ」9「時間」1011"google.golang.grpc"12"google.golang.grpc"1314gasestimation "celestia-grpc/celestia/core/v1/gas_estimation"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 トークン = "YOUR_TOKEN"23var endpoint = "YOUR_ENDPOINT:9090"2425タイプ auth 構造体 {26トークン 文字列27}2829func (a *auth) GetRequestMetadata(ctx コンテキスト.Context, uri ...文字列) (map[文字列]文字列, エラー) {30戻る map[文字列]文字列{31「x-token」: a.トークン,32}, nil33}3435func (a *auth) RequireTransportSecurity(auth) bool {36戻る false37}3839func main() {40opts := []grpc.DialOption{41grpc.WithTransportCredentialsWithTransportCredentials(credentials.NewTLS(&tls.設定{})),42grpc.WithPerRPCCredentials(&auth{token}),43}4445// Create gRPC connection46conn, err := grpc.Dial(endpoint, opts...)47もし err != nil {48log.Fatalf("Celestia gRPC への接続に失敗しました: %v", err)49}50延期 conn.閉じる()5152client := gasestimation.NewGasEstimatorClient(conn)5354ctx, cancel := context.WithTimeout)(コンテキスト.Background(), 10*時間.2番目)55延期 延期()5657resp, err := client.EstimateGasPrice(ctx, &gasestimation.EstimateGasPriceRequest{58TxPriority: gasestimation.TxPriority_TX_PRIORITY_MEDIUM,59})60もし err != nil {61log.Fatalf("Failed to estimate gas price: %v", err)62}6364jsonData, err := json.MarshalIndent(resp, "", " ")65もし err != nil {66log.Printf("Error converting to JSON: %v", err)67} else {68fmt.Println("\nOutput:")69fmt.PrintlnPrintln文字列(jsonData))70}71}