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.
- π§ 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
git clone https://github.com/fbsobreira/gotron-sdk.git
cd gotron-sdk
make install
go get -u github.com/fbsobreira/gotron-sdk
# 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>
package main
import (
"fmt"
"log"
"github.com/fbsobreira/gotron-sdk/pkg/address"
"github.com/fbsobreira/gotron-sdk/pkg/client"
)
func main() {
// Create client
c := client.NewGrpcClient("grpc.trongrid.io:50051")
err := c.Start(client.GRPCInsecure())
if err != nil {
log.Fatal(err)
}
defer c.Stop()
// Get account info
addr, _ := address.Base58ToAddress("TUEZSdKsoDHQMeZwihtdoBiN46zxhGWYdH")
account, err := c.GetAccount(addr.String())
if err != nil {
log.Fatal(err)
}
fmt.Printf("Balance: %d\n", account.Balance)
}
- Installation Guide - Detailed installation instructions
- CLI Usage Guide - Complete CLI command reference
- SDK Usage Guide - Go SDK examples and patterns
- API Reference - Detailed API documentation
- Examples - Common use cases and examples
- Create and import accounts
- Hardware wallet support (Ledger)
- Keystore management
- Multi-signature support
- TRX transfers
- TRC10 token operations
- TRC20 token operations
- Smart contract interactions
- Transaction signing and broadcasting
- Contract deployment
- Contract calls and triggers
- ABI encoding/decoding
- Event monitoring
- Block information
- Transaction details
- Account resources
- Witness/SR information
- Proposal management
# 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"
Create ~/.tronctl/config.yaml
:
node: grpc.trongrid.io:50051
network: mainnet
timeout: 60s
tls: true
apiKey: your-api-key
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
}
]
Add to your .bashrc
or .zshrc
:
# Bash
source <(tronctl completion bash)
# Zsh
source <(tronctl completion zsh)
- Go 1.18 or higher
- Make (for building)
- Protocol Buffers compiler (for regenerating protos)
# 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
We welcome contributions! Please see our Contributing Guidelines for details.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
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.
This project is licensed under the MIT License - see the LICENSE file for details.
- π Documentation
- π Issue Tracker
- π¬ Discussions