# Functions
BuildTxV2 构建一笔交易 BuildTxV2 根据给定参数构建交易v2版本。 参数:
chainId - 区块链ID。 sequence - 账户序列号。 accountNumber - 账户编号。 privKey - 私钥,用于交易签名。 fee - 交易费用。 gaslimit - 交易燃气限制。 msgs - 交易消息数组。
返回:
*typetx.TxRaw - 构建的交易原始数据。 error - 如果构建过程中出现错误,则返回错误。.
func NewGrpcClient() (grpcClient *grpc.ClientConn, err error) { // 创建grpc连接 target := "cosmos-grpc.publicnode.com:443" var opts []grpc.DialOption opts = append(opts, grpc.WithCredentialsBundle(google.NewDefaultCredentials())) grpcConn, err := grpc.NewClient(target, opts...) if err != nil { panic(err) } txClient := typetx.NewServiceClient(grpcConn)
req := &typetx.GetBlockWithTxsRequest{Height: 20758858} resp, err := txClient.GetBlockWithTxs(context.Background(), req) if err != nil { panic(err) } fmt.Println(resp.Txs[0].Body) return grpcConn, nil }
Import 根据十六进制字符串导入私钥。 参数 privKeyHex 是一个十六进制编码的私钥字符串。 返回值是一个指向 secp256k1 私钥结构的指针,以及可能的错误。 该函数的目的是将十六进制表示的私钥转换为 secp256k1 私钥结构,以供后续加密操作使用。.
No description provided by the author
NewClient 新建链接,用于创建一个 grpc 客户端.