gotron-sdk

module
v0.26.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2026 License: LGPL-3.0

README

GoTRON SDK

Go Reference Go Report Card codecov License

GoTRON SDK is a comprehensive Go SDK and CLI tool for interacting with the TRON blockchain. It provides both a command-line interface (tronctl) and Go libraries for TRON blockchain operations.

tronctl demo

Built For

  • Exchanges — deposit/withdrawal engines, hot wallet management
  • Wallets — HD wallet derivation, hardware signing, multi-sig
  • Trading Bots — fast gRPC client, typed responses, batch operations
  • Staking Services — freeze/delegate resources, vote for SRs
  • Infrastructure — CLI scripting, monitoring, automation

Why GoTRON?

GoTRON SDK is built for backend and infrastructure teams that need performance, reliability, and operational tooling.

GoTRON SDK tronweb (JS/TS) tron-api-python
Transport gRPC (binary, streaming) HTTP/JSON HTTP/JSON
Deployment Single static binary Node.js runtime Python runtime
Hardware Signing Built-in Ledger support Separate adapter No
CLI Tooling tronctl included None Yes (CLI framework)
Concurrency Goroutines (native) Event loop GIL-limited
HD Wallets Yes (BIP39/44) Yes (BIP39/44) No
Multi-sig Yes Yes Not documented
Type Safety Full (compiled) Full (TypeScript) Not documented

Comparison as of 2026-03-16. Verify claims against each project's README.

Features

  • 🔧 Complete CLI Tool: Manage accounts, send transactions, interact with smart contracts
  • 📚 Go SDK: Build TRON applications with a clean, idiomatic Go API
  • 🔐 Secure Key Management: Hardware wallet support, encrypted keystores
  • 🚀 High Performance: Native gRPC communication with TRON nodes
  • 🛠️ Developer Friendly: Comprehensive examples and documentation
  • 🤖 AI-Ready: MCP server lets AI agents interact with TRON blockchain

MCP Server

Connect AI agents to TRON via the GoTRON MCP Server. Zero install — hosted at mcp.gotron.sh.

Claude Code:

claude mcp add gotron --scope user --transport http https://mcp.gotron.sh/mcp

Claude Desktop: Add via Settings > Connectors using URL https://mcp.gotron.sh/mcp

Includes read-only blockchain queries, unsigned transaction builders, and full SDK documentation for AI-assisted development. See the gotron-mcp repo for local mode with signing support.

Quick Start

Installation
Quick Install
curl -fsSL gotron.sh/install | sh
Install with Go
go install github.com/fbsobreira/gotron-sdk/cmd/tronctl@latest
Install with Homebrew
brew install fbsobreira/tap/tronctl
Install from source
git clone https://github.com/fbsobreira/gotron-sdk.git
cd gotron-sdk
make install
Use as a Go library
go get -u github.com/fbsobreira/gotron-sdk
Basic Usage
CLI Usage
# Create a new account
tronctl keys add <account-name>

# Check balance
tronctl account balance <address>

# Send TRX
tronctl account send <to-address> <amount> --signer <signer-name>
30-Second Quickstart (SDK)
package main

import (
	"fmt"
	"log"

	"github.com/fbsobreira/gotron-sdk/pkg/client"
)

func main() {
	c := client.NewGrpcClient("grpc.trongrid.io:50051")
	if err := c.Start(client.GRPCInsecure()); err != nil {
		log.Fatal(err)
	}
	defer c.Stop()

	account, err := c.GetAccount("TUEZSdKsoDHQMeZwihtdoBiN46zxhGWYdH")
	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("Balance: %d SUN\n", account.Balance)
}

Documentation

Supported Features

Account Management
  • Create and import accounts
  • Hardware wallet support (Ledger)
  • Keystore management
  • Multi-signature support
Transactions
  • TRX transfers
  • TRC10 token operations
  • TRC20 token operations
  • Smart contract interactions
  • Transaction signing and broadcasting
Smart Contracts
  • Contract deployment
  • Contract calls and triggers
  • ABI encoding/decoding
  • Event monitoring
Blockchain Queries
  • Block information
  • Transaction details
  • Account resources
  • Witness/SR information
  • Proposal management

Configuration

Environment Variables
# Set custom node
export TRON_NODE="grpc.trongrid.io:50051"

# Enable TLS
export TRON_NODE_TLS="true"

# Set Trongrid API key
export TRONGRID_APIKEY="your-api-key"

# Enable debug mode
export GOTRON_SDK_DEBUG="true"
Configuration File

Create ~/.tronctl/config.yaml:

node: grpc.trongrid.io:50051
network: mainnet
timeout: 60s
tls: true
apiKey: your-api-key
Transfer JSON Format

For batch transfers, use a JSON file with the following format:

Key Value-type Value-description
from string [Required] Sender's address, must have key in keystore
to string [Required] Receiver's address
amount string [Required] Amount to send in TRX
passphrase-file string [Optional] File path containing passphrase
passphrase-string string [Optional] Passphrase as string
stop-on-error boolean [Optional] Stop on error (default: false)

Example:

[
  {
    "from": "TUEZSdKsoDHQMeZwihtdoBiN46zxhGWYdH",
    "to": "TKSXDA8HfE9E1y39RczVQ1ZascUEtaSToF",
    "amount": "100",
    "passphrase-string": "",
    "stop-on-error": true
  }
]

Shell Completion

Add to your .bashrc or .zshrc:

# Bash
source <(tronctl completion bash)

# Zsh
source <(tronctl completion zsh)

Development

Requirements
  • Go 1.24 or higher
  • Make (for building)
  • Protocol Buffers compiler (for regenerating protos)
Building
# Build binary
make build

# Cross-compile for Windows
make build-windows

# Run tests
make test

# Run linter
make lint

# Generate protobuf files
./gen-proto.sh

Contributing

We welcome contributions! Please see our Contributing Guidelines for details.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Version History

Note on Versions

The v2.x.x releases were incorrectly tagged without proper Go module versioning. These versions have been retracted. Please use v1.x.x versions or later.

Projects Using GoTRON

Using GoTRON SDK in your project? Open an issue to add it here!

License

This project is licensed under the LGPL-3.0 License - see the LICENSE file for details.

Support

Directories

Path Synopsis
cmd
subcommands
Package cmd provides CLI subcommands for the tronctl command-line tool.
Package cmd provides CLI subcommands for the tronctl command-line tool.
tronctl command
examples
builder command
Example: Transaction Builder + Contract Call Builder + TRC20
Example: Transaction Builder + Contract Call Builder + TRC20
justlend command
Minimal example showing how to rent and return energy via JustLend DAO's energy rental contract using the GoTRON SDK.
Minimal example showing how to rent and return energy via JustLend DAO's energy rental contract using the GoTRON SDK.
multisig command
Runnable version of every multi-sig code block from docs/examples.md.
Runnable version of every multi-sig code block from docs/examples.md.
pkg
abi
Package abi provides ABI encoding and decoding for TRON smart contracts.
Package abi provides ABI encoding and decoding for TRON smart contracts.
account
Package account provides TRON account creation, import, and export operations.
Package account provides TRON account creation, import, and export operations.
address
Package address provides TRON address encoding, decoding, and validation.
Package address provides TRON address encoding, decoding, and validation.
client
Package client provides a gRPC client for interacting with the TRON network.
Package client provides a gRPC client for interacting with the TRON network.
client/transaction
Package transaction provides transaction signing and submission for TRON.
Package transaction provides transaction signing and submission for TRON.
common
Package common provides shared utilities for encoding, hashing, and data conversion.
Package common provides shared utilities for encoding, hashing, and data conversion.
common/decimals
Package decimals provides decimal formatting and conversion utilities.
Package decimals provides decimal formatting and conversion utilities.
common/numeric
Package numeric provides decimal arithmetic utilities.
Package numeric provides decimal arithmetic utilities.
contract
Package contract provides smart contract interaction utilities for TRON.
Package contract provides smart contract interaction utilities for TRON.
keys
Package keys provides key management utilities for TRON accounts.
Package keys provides key management utilities for TRON accounts.
keys/hd
Package hd provides basic functionality Hierarchical Deterministic Wallets.
Package hd provides basic functionality Hierarchical Deterministic Wallets.
keystore
Package keystore implements encrypted storage of secp256k1 private keys.
Package keystore implements encrypted storage of secp256k1 private keys.
ledger
Package ledger provides hardware wallet integration for TRON signing.
Package ledger provides hardware wallet integration for TRON signing.
mnemonic
Package mnemonic provides BIP39 mnemonic phrase generation and validation.
Package mnemonic provides BIP39 mnemonic phrase generation and validation.
signer
Package signer defines a signing interface for TRON transactions and provides concrete implementations backed by private keys, keystores, and hardware wallets.
Package signer defines a signing interface for TRON transactions and provides concrete implementations backed by private keys, keystores, and hardware wallets.
standards/trc20
Package trc20 provides a typed, high-level wrapper for TRC20 token interactions.
Package trc20 provides a typed, high-level wrapper for TRC20 token interactions.
standards/trc20enc
Package trc20enc provides low-level ABI encoding and decoding helpers for TRC20 token interactions.
Package trc20enc provides low-level ABI encoding and decoding helpers for TRC20 token interactions.
store
Package store provides local keystore management for TRON accounts.
Package store provides local keystore management for TRON accounts.
tron
Package tron provides convenience constructors that bind a GrpcClient to the builder packages (txbuilder, contract, trc20).
Package tron provides convenience constructors that bind a GrpcClient to the builder packages (txbuilder, contract, trc20).
txbuilder
Package txbuilder provides a fluent builder for native TRON transactions (transfers, staking, voting, etc.) with Build / Send / SendAndConfirm terminal operations.
Package txbuilder provides a fluent builder for native TRON transactions (transfers, staking, voting, etc.) with Build / Send / SendAndConfirm terminal operations.
txcore
Package txcore provides shared transaction signing, broadcasting, and confirmation logic used by both txbuilder and contract packages.
Package txcore provides shared transaction signing, broadcasting, and confirmation logic used by both txbuilder and contract packages.
txresult
Package txresult defines shared result types for TRON transaction operations, used by both the txbuilder and contract packages.
Package txresult defines shared result types for TRON transaction operations, used by both the txbuilder and contract packages.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL