Skip to main content

TotalTransaction gRPC Method

Loading...

Updated on
May 13, 2025

TotalTransaction gRPC Method

Parameters

This method does not accept any parameters

Returns

num
integer
Loading...
error
object
Loading...
Request
1
package main
2
3
import (
4
"context"
5
"crypto/tls"
6
"fmt"
7
8
"github.com/fbsobreira/gotron-sdk/pkg/client"
9
"google.golang.org/grpc"
10
"google.golang.org/grpc/credentials"
11
)
12
13
14
// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token
15
// For eg: QN Endpoint: https://docs-demo.tron-mainnet.quiknode.pro/abcde123456789
16
// endpoint will be: docs-demo.tron-mainnet.quiknode.pro:50051 {50051 is the port number for Tron gRPC}
17
// token will be : abcde123456789
18
19
var token = "YOUR_TOKEN"
20
var endpoint = "YOUR_ENDPOINT:50051"
21
22
23
type auth struct {
24
token string
25
}
26
27
func (a *auth) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) {
28
return map[string]string{
29
"x-token": a.token,
30
}, nil
31
}
32
33
func (a *auth) RequireTransportSecurity() bool {
34
return false
35
}
36
37
func main() {
38
opts := []grpc.DialOption{
39
grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{})),
40
grpc.WithPerRPCCredentials(&auth{token}),
41
}
42
conn := client.NewGrpcClient(endpoint)
43
if err := conn.Start(opts...); err != nil {
44
panic(err)
45
}
46
47
response, err := conn.TotalTransaction()
48
if err != nil {
49
fmt.Printf("Error getting total transactions: %v\n", err)
50
return
51
}
52
53
fmt.Printf("Total number of transactions on the TRON blockchain: %d\n", response.GetNum())
54
55
}
Don't have an account yet?
Create your Quicknode endpoint in seconds and start building
Get started for free