tron

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Overview

Package tron reads a Tron wallet (Ledger, TronLink…) from its public address: TRX and TRC-20 history and balances. Nothing is signed and no secret is needed.

Data comes from TronGrid's v1 API (/v1/accounts/{address}, …/transactions, …/transactions/trc20), which answers without a key at a low rate; a free TronGrid key raises the limit.

Limits of this first version:

  • a swap on a DEX shows as its two legs (a Withdrawal of what was sent and a Deposit of what was received), not as a Trade;
  • TRC-10 tokens (TransferAssetContract) are ignored: nearly all are airdropped junk;
  • spam TRC-20 tokens are skipped by heuristics (see spam), and well-known symbols (USDT, USDC, USDD…) only count from their canonical contract, so a counterfeit "USDT" airdrop is ignored;
  • TRX frozen for energy or bandwidth (Stake 1.0 and 2.0), delegated to another account or waiting to be unfrozen still counts in the balance: it is still the owner's;
  • voting rewards are read when claimed (WithdrawBalanceContract), with one extra call per claim for the amount; unclaimed rewards are not counted.

Index

Constants

View Source
const Network = "tron"

Network is the chain name set on activities.

Variables

This section is empty.

Functions

func FromHex

func FromHex(h string) string

FromHex converts the hex form raw transactions use (41 + 20 bytes, or the 20 bytes alone as in EVM-style logs) to base58check; anything else comes back unchanged, so a base58 address passes through.

func New

func New(cfg source.Config) (source.Source, error)

New builds the connector from its settings.

func ToHex

func ToHex(addr string) string

ToHex is the inverse of FromHex: "41" + 40 hex digits ("" when invalid).

func Valid

func Valid(s string) bool

Valid reports whether s is a Tron address: base58check of 21 bytes whose first is 0x41 (so it starts with T), with a good checksum.

Types

type Source

type Source struct {
	// contains filtered or unexported fields
}

Source is a configured wallet.

func (*Source) Activities

func (s *Source) Activities(ctx context.Context, f source.Fetch) error

func (*Source) Balances

func (s *Source) Balances(ctx context.Context) ([]model.Balance, error)

func (*Source) State

func (s *Source) State() []byte

func (*Source) Test

func (s *Source) Test(ctx context.Context) error

Test checks TronGrid answers for the address (and accepts the key).

Jump to

Keyboard shortcuts

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