Parameters
tx
object
REQUIRED
The transaction extension object to update the hash for
transaction
object
The transaction object
txid
string
The transaction ID (will be updated by this method)
constant_result
array
Results of constant function calls
result
object
The result of the transaction
Returns
error
object
Error object that will be nil if operation was successful
Request
1package main23import (4"context"5"crypto/tls"6"fmt"7"encoding/json"89"github.com/fbsobreira/gotron-sdk/pkg/client"10"google.golang.org/grpc"11"google.golang.org/grpc/credentials"12)131415// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token16// For eg: QN Endpoint: https://docs-demo.tron-mainnet.quiknode.pro/abcde12345678917// endpoint will be: docs-demo.tron-mainnet.quiknode.pro:50051 {50051 is the port number for Tron gRPC}18// token will be : abcde1234567891920var token = "YOUR_TOKEN"21var endpoint = "YOUR_ENDPOINT:50051"222324type auth struct {25token string26}2728func (a *auth) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) {29return map[string]string{30"x-token": a.token,31}, nil32}3334func (a *auth) RequireTransportSecurity() bool {35return false36}3738func main() {39opts := []grpc.DialOption{40grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{})),41grpc.WithPerRPCCredentials(&auth{token}),42}43conn := client.NewGrpcClient(endpoint)44if err := conn.Start(opts...); err != nil {45panic(err)46}47defer conn.Conn.Close()4849fromAddress := "TC7xSvcMqW7PXuZXAuzhie81g22fA45kyY"50toAddress := "TTW663tQYJTTCtHh6DWKAfexRhPMf2DxQ1"51amount := int64(1000000)5253tx, err := conn.Transfer(fromAddress, toAddress, amount)54if err != nil {55fmt.Printf("Error creating transfer transaction: %v\n", err)56return57}58fmt.Printf("Transaction ID before UpdateHash: %x\n", tx.Txid)5960err = conn.UpdateHash(tx)61if err != nil {62fmt.Printf("Error calling UpdateHash: %v\n", err)63return64}6566fmt.Println("Transaction after UpdateHash:")6768jsonData, err := json.MarshalIndent(tx, "", " ")69if err != nil {70fmt.Printf("Error marshaling to JSON: %v\n", err)71return72}7374fmt.Println(string(jsonData))75}
1package main23import (4"context"5"crypto/tls"6"fmt"7"encoding/json"89"github.com/fbsobreira/gotron-sdk/pkg/client"10"google.golang.org/grpc"11"google.golang.org/grpc/credentials"12)131415// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token16// For eg: QN Endpoint: https://docs-demo.tron-mainnet.quiknode.pro/abcde12345678917// endpoint will be: docs-demo.tron-mainnet.quiknode.pro:50051 {50051 is the port number for Tron gRPC}18// token will be : abcde1234567891920var token = "YOUR_TOKEN"21var endpoint = "YOUR_ENDPOINT:50051"222324type auth struct {25token string26}2728func (a *auth) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) {29return map[string]string{30"x-token": a.token,31}, nil32}3334func (a *auth) RequireTransportSecurity() bool {35return false36}3738func main() {39opts := []grpc.DialOption{40grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{})),41grpc.WithPerRPCCredentials(&auth{token}),42}43conn := client.NewGrpcClient(endpoint)44if err := conn.Start(opts...); err != nil {45panic(err)46}47defer conn.Conn.Close()4849fromAddress := "TC7xSvcMqW7PXuZXAuzhie81g22fA45kyY"50toAddress := "TTW663tQYJTTCtHh6DWKAfexRhPMf2DxQ1"51amount := int64(1000000)5253tx, err := conn.Transfer(fromAddress, toAddress, amount)54if err != nil {55fmt.Printf("Error creating transfer transaction: %v\n", err)56return57}58fmt.Printf("Transaction ID before UpdateHash: %x\n", tx.Txid)5960err = conn.UpdateHash(tx)61if err != nil {62fmt.Printf("Error calling UpdateHash: %v\n", err)63return64}6566fmt.Println("Transaction after UpdateHash:")6768jsonData, err := json.MarshalIndent(tx, "", " ")69if err != nil {70fmt.Printf("Error marshaling to JSON: %v\n", err)71return72}7374fmt.Println(string(jsonData))75}
Don't have an account yet?
Create your Quicknode endpoint in seconds and start building
Get started for free