github.com/pokt-network/tendermint@v0.32.11-0.20230426215212-59310158d3e9/test/app/grpc_client.go (about) 1 package main 2 3 import ( 4 "encoding/hex" 5 "fmt" 6 "os" 7 8 "context" 9 10 amino "github.com/tendermint/go-amino" 11 12 coregrpc "github.com/tendermint/tendermint/rpc/grpc" 13 ) 14 15 var grpcAddr = "tcp://localhost:36656" 16 17 func main() { 18 args := os.Args 19 if len(args) == 1 { 20 fmt.Println("Must enter a transaction to send (hex)") 21 os.Exit(1) 22 } 23 tx := args[1] 24 txBytes, err := hex.DecodeString(tx) 25 if err != nil { 26 fmt.Println("Invalid hex", err) 27 os.Exit(1) 28 } 29 30 clientGRPC := coregrpc.StartGRPCClient(grpcAddr) 31 res, err := clientGRPC.BroadcastTx(context.Background(), &coregrpc.RequestBroadcastTx{Tx: txBytes}) 32 if err != nil { 33 fmt.Println(err) 34 os.Exit(1) 35 } 36 37 bz, err := amino.NewCodec().MarshalJSON(res) 38 if err != nil { 39 fmt.Println(err) 40 os.Exit(1) 41 } 42 fmt.Println(string(bz)) 43 }