package tron import ( "github.com/fbsobreira/gotron-sdk/pkg/client" "github.com/fbsobreira/gotron-sdk/pkg/proto/api" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" ) func TronLastBlock() (uint64, error) { conn := client.NewGrpcClient(tronNode.grpcNode) err := conn.Start(grpc.WithTransportCredentials(insecure.NewCredentials())) if err != nil { return 0, err } block, err := conn.GetNowBlock() if err != nil { return 0, err } return uint64(block.BlockHeader.RawData.Number), nil } func TronBlockByNumber(blockNumber uint64) (*api.BlockExtention, error) { conn := client.NewGrpcClient(tronNode.grpcNode) err := conn.Start(grpc.WithTransportCredentials(insecure.NewCredentials())) if err != nil { return nil, err } block, err := conn.GetBlockByNum(int64(blockNumber)) if err != nil { return nil, err } return block, nil }