API Reference

Full reference for the pkg/client package — the main entry point for interacting with TRON via GoTRON SDK.

Client

client.NewGrpcClient(endpoint string) *GrpcClient

Creates a new TRON gRPC client instance.

conn := client.NewGrpcClient("grpc.trongrid.io:50051")

client.NewGrpcClientWithTimeout(endpoint string, timeout time.Duration) *GrpcClient

Creates a new client with a custom connection timeout.

(g *GrpcClient) Start(opts ...grpc.DialOption) error

Establishes the gRPC connection. Accepts optional dial options.

(g *GrpcClient) Stop()

Closes the gRPC connection.

Account Operations

GetAccount(address string) (*core.Account, error)

Returns the full account information including balance, resources, permissions, and frozen balances. Access balance via account.Balance.

GetAccountDetailed(address string) (*account.Account, error)

Returns a detailed account view with additional computed fields.

GetAccountResource(address string) (*api.AccountResourceMessage, error)

Returns the account’s energy and bandwidth resources.

Transfers

Transfer(from, toAddress string, amount int64) (*api.TransactionExtention, error)

Creates an unsigned TRX transfer transaction.

Parameters:

  • from — Sender address (base58)
  • toAddress — Recipient address (base58)
  • amount — Amount in SUN (1 TRX = 1,000,000 SUN)

TRC20 Tokens

TRC20ContractBalance(addr, contractAddress string) (*big.Int, error)

Returns the TRC20 token balance for the given owner.

TRC20Send(from, to, contract string, amount *big.Int, feeLimit int64) (*api.TransactionExtention, error)

Creates an unsigned TRC20 transfer transaction.

TRC20GetDecimals(contractAddress string) (*big.Int, error)

Returns the token’s decimal places.

TRC20GetName(contractAddress string) (string, error)

Returns the token name.

TRC20GetSymbol(contractAddress string) (string, error)

Returns the token symbol.

TRC10 Tokens

GetAssetIssueByID(id string) (*core.AssetIssueContract, error)

Returns TRC10 token information by asset ID.

TransferAsset(from, toAddress, assetID string, amount int64) (*api.TransactionExtention, error)

Creates an unsigned TRC10 transfer transaction.

Staking & Resources

FreezeBalance(from, delegateTo string, resource core.ResourceCode, frozenBalance int64) (*api.TransactionExtention, error)

Creates a freeze balance transaction for energy or bandwidth. Use core.ResourceCode_ENERGY or core.ResourceCode_BANDWIDTH.

UnfreezeBalance(from, delegateTo string, resource core.ResourceCode) (*api.TransactionExtention, error)

Unfreezes previously frozen TRX.

VoteWitnessAccount(owner string, votes map[string]int64) (*api.TransactionExtention, error)

Votes for super representative candidates.

Transaction Operations

Broadcast(tx *core.Transaction) (*api.Return, error)

Broadcasts a signed transaction to the network.

GetTransactionByID(id string) (*core.Transaction, error)

Retrieves a transaction by its hash.

GetTransactionInfoByID(id string) (*core.TransactionInfo, error)

Retrieves transaction execution details including fee, energy usage, and logs.

Block Operations

GetNowBlock() (*api.BlockExtention, error)

Returns the latest block.

GetBlockByNum(num int64) (*api.BlockExtention, error)

Returns a block by its number.

Smart Contracts

TriggerContract(from, contractAddress, method, jsonString string, feeLimit, tAmount int64, tTokenID string, tTokenAmount int64) (*api.TransactionExtention, error)

Calls a smart contract method.

TriggerConstantContract(from, contractAddress, method, jsonString string) (*api.TransactionExtention, error)

Calls a read-only smart contract method (no broadcast needed).

Next Steps