8
"github.com/fbsobreira/gotron-sdk/pkg/client"9
"github.com/fbsobreira/gotron-sdk/pkg/proto/core"10
"google.golang.org/grpc"11
"google.golang.org/grpc/credentials"19
var token = "YOUR_TOKEN"20
var endpoint = "YOUR_ENDPOINT:50051"26
func (a *auth) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) {27
return map[string]string{32
func (a *auth) RequireTransportSecurity() bool {55
opts := []grpc.DialOption{56
grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{})),57
grpc.WithPerRPCCredentials(&auth{token}),59
conn := client.NewGrpcClient(endpoint)60
if err := conn.Start(opts...); err != nil {63
defer conn.Conn.Close()65
from := "TZ4UXDV5ZhNW7fb2AMSbgfAEZ7hWsnYS2g"66
to := "TFgY1uN8buRxAtV2r6Zy5sG3ACko6pJT1y"67
delegateBalance := int64(1000000)68
lockPeriod := int64(3)70
resource := core.ResourceCode_BANDWIDTH 73
fmt.Println("Creating resource delegation transaction...")78
tx, err := conn.DelegateResource(88
fmt.Printf("Error creating resource delegation transaction: %v\n", err)92
fmt.Println("Resource delegation transaction created successfully. Transaction details:")93
jsonData, _ := json.MarshalIndent(tx, "", " ")94
fmt.Println(string(jsonData))96
fmt.Println("\nBroadcasting transaction to the TRON network...")97
result, err := conn.Broadcast(tx.Transaction)99
fmt.Printf("Error broadcasting transaction: %v\n", err)103
if !result.GetResult() {104
fmt.Printf("Broadcast failed: %s\n", result.GetMessage())108
fmt.Println("Resource delegation successful! Result:")109
resultJSON, _ := json.MarshalIndent(result, "", " ")110
fmt.Println(string(resultJSON))
8
"github.com/fbsobreira/gotron-sdk/pkg/client"9
"github.com/fbsobreira/gotron-sdk/pkg/proto/core"10
"google.golang.org/grpc"11
"google.golang.org/grpc/credentials"19
var token = "YOUR_TOKEN"20
var endpoint = "YOUR_ENDPOINT:50051"26
func (a *auth) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) {27
return map[string]string{32
func (a *auth) RequireTransportSecurity() bool {55
opts := []grpc.DialOption{56
grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{})),57
grpc.WithPerRPCCredentials(&auth{token}),59
conn := client.NewGrpcClient(endpoint)60
if err := conn.Start(opts...); err != nil {63
defer conn.Conn.Close()65
from := "TZ4UXDV5ZhNW7fb2AMSbgfAEZ7hWsnYS2g"66
to := "TFgY1uN8buRxAtV2r6Zy5sG3ACko6pJT1y"67
delegateBalance := int64(1000000)68
lockPeriod := int64(3)70
resource := core.ResourceCode_BANDWIDTH 73
fmt.Println("Creating resource delegation transaction...")78
tx, err := conn.DelegateResource(88
fmt.Printf("Error creating resource delegation transaction: %v\n", err)92
fmt.Println("Resource delegation transaction created successfully. Transaction details:")93
jsonData, _ := json.MarshalIndent(tx, "", " ")94
fmt.Println(string(jsonData))96
fmt.Println("\nBroadcasting transaction to the TRON network...")97
result, err := conn.Broadcast(tx.Transaction)99
fmt.Printf("Error broadcasting transaction: %v\n", err)103
if !result.GetResult() {104
fmt.Printf("Broadcast failed: %s\n", result.GetMessage())108
fmt.Println("Resource delegation successful! Result:")109
resultJSON, _ := json.MarshalIndent(result, "", " ")110
fmt.Println(string(resultJSON))