ParseTRC20StringProperty gRPC Method
매개변수
데이터
문자열
필수
로딩 중...
반품
값
문자열
로딩 중...
오류
객체
로딩 중...
요청
1패키지 main23가져오기 (4"문맥"5"crypto/tls"6"인코딩/16진수"7"fmt"89"github.com/fbsobreira/gotron-sdk/pkg/client"10"google.golang.grpc"11"google.golang.grpc"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"222324유형 auth struct {25토큰 문자열26}2728func (a *auth) GetRequestMetadata(ctx 컨텍스트.Context, uri ...문자열) (map[문자열]문자열, error) {29돌아가기 맵[문자열]문자열{30"x-token": a.토큰,31}, nil32}3334func (a *auth) RequireTransportSecurity() bool {35return false36}3738func main() {39opts := []grpc.DialOption{40grpc.WithTransportCredentialsWithTransportCredentials (인증 정보.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()4849ownerAddress := "THPvaUhoh2Qn2y9THCZML3H815hhFhn5YC"50contractAddress := "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"51method := "name()"52jsonParams := ""5354response, err := conn.TriggerConstantContract(55ownerAddress,56contractAddress,57method,58jsonParams,59)60만약 err != nil {61fmt.Printf("Error calling TriggerConstantContract: %v\n", err)62반환63}6465if len(response.ConstantResult) == 0 {66fmt.Println("No result returned from contract call")67반환68}6970hexData := hex.EncodeToString(response.ConstantResult[0])7172tokenName, err := conn.ParseTRC20StringProperty(hexData)73만약 err != nil {74fmt.Printf("Error parsing string property: %v\n", err)75반환76}7778fmt.Printf("Token Name: %s\n", tokenName)7980}
1패키지 main23가져오기 (4"문맥"5"crypto/tls"6"인코딩/16진수"7"fmt"89"github.com/fbsobreira/gotron-sdk/pkg/client"10"google.golang.grpc"11"google.golang.grpc"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"222324유형 auth struct {25토큰 문자열26}2728func (a *auth) GetRequestMetadata(ctx 컨텍스트.Context, uri ...문자열) (map[문자열]문자열, error) {29돌아가기 맵[문자열]문자열{30"x-token": a.토큰,31}, nil32}3334func (a *auth) RequireTransportSecurity() bool {35return false36}3738func main() {39opts := []grpc.DialOption{40grpc.WithTransportCredentialsWithTransportCredentials (인증 정보.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()4849ownerAddress := "THPvaUhoh2Qn2y9THCZML3H815hhFhn5YC"50contractAddress := "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"51method := "name()"52jsonParams := ""5354response, err := conn.TriggerConstantContract(55ownerAddress,56contractAddress,57method,58jsonParams,59)60만약 err != nil {61fmt.Printf("Error calling TriggerConstantContract: %v\n", err)62반환63}6465if len(response.ConstantResult) == 0 {66fmt.Println("No result returned from contract call")67반환68}6970hexData := hex.EncodeToString(response.ConstantResult[0])7172tokenName, err := conn.ParseTRC20StringProperty(hexData)73만약 err != nil {74fmt.Printf("Error parsing string property: %v\n", err)75반환76}7778fmt.Printf("Token Name: %s\n", tokenName)7980}