GenesisTime gRPC Method
Parameters
This method does not accept any parameters
Returns
genesis_time
object
Loading...
seconds
integer
Loading...
Request
package main import ( "context" "crypto/tls" "encoding/json" "fmt" "log" "time" "google.golang.org/grpc" "google.golang.org/grpc/credentials" minttypes "celestia-grpc/celestia/mint/v1" ) // QuickNode endpoints consist of two crucial components: the endpoint name and the corresponding token // For eg: QN Endpoint: https://docs-demo.celestia-mainnet.quiknode.pro/abcde123456789 // endpoint will be: docs-demo.celestia-mainnet.quiknode.pro:9090 {9090 is the port number for Celestia gRPC} // token will be : abcde123456789 var token = "YOUR_TOKEN" var endpoint = "YOUR_ENDPOINT:9090" type auth struct { token string } func (a *auth) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) { return map[string]string{ "x-token": a.token, }, nil } func (a *auth) RequireTransportSecurity() bool { return false } func main() { opts := []grpc.DialOption{ grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{})), grpc.WithPerRPCCredentials(&auth{token}), } // Create gRPC connection conn, err := grpc.Dial(endpoint, opts...) if err != nil { log.Fatalf("Failed to connect to Celestia gRPC server: %v", err) } defer conn.Close() client := minttypes.NewQueryClient(conn) ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() genesisResp, err := client.GenesisTime(ctx, &minttypes.QueryGenesisTimeRequest{}) if err != nil { log.Printf("Failed to query genesis time: %v", err) } else { jsonData, _ := json.MarshalIndent(genesisResp, "", " ") fmt.Println(string(jsonData)) } }
Don't have an account yet?
Create your QuickNode endpoint in seconds and start building
Get started for free