github.com/InjectiveLabs/sdk-go@v1.53.0/examples/explorer/1_GetTxByHash/example.go (about)

     1  package main
     2  
     3  import (
     4  	"context"
     5  	"encoding/json"
     6  	"fmt"
     7  
     8  	"github.com/InjectiveLabs/sdk-go/client/common"
     9  	explorerclient "github.com/InjectiveLabs/sdk-go/client/explorer"
    10  )
    11  
    12  func main() {
    13  	network := common.LoadNetwork("mainnet", "sentry")
    14  	explorerClient, err := explorerclient.NewExplorerClient(network)
    15  	if err != nil {
    16  		panic(err)
    17  	}
    18  
    19  	ctx := context.Background()
    20  	hash := "E5DCF04CC670A0567F58683409F7DAFC49754278DAAD507FE6EB40DFBFD71830"
    21  	res, err := explorerClient.GetTxByTxHash(ctx, hash)
    22  	if err != nil {
    23  		fmt.Println(err)
    24  	}
    25  
    26  	str, _ := json.MarshalIndent(res, "", " ")
    27  	fmt.Print(string(str))
    28  }