utron

package
v0.0.0-...-3ec7072 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2025 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SunPerTRX   int64 = 1000000 // 1 TRX = 1,000,000 Sun
	TRXDecimals uint8 = 6
)

Variables

This section is empty.

Functions

func CreateWalletAccount

func CreateWalletAccount() (privateKeyHex, address string, err error)

func WalletAddressFromPrivateKey

func WalletAddressFromPrivateKey(privateKeyHex string) (address string, err error)

Types

type Gas

type Gas struct {
	Total int64 // = Bandwidth * BandwidthUnitPrice + Energy + EnergyUnitPrice

	BandwidthUsed      int64
	BandwidthUnitPrice int64

	// --- contract deploy or call ---
	EnergyUsed      int64
	EnergyUnitPrice int64

	// --- only transfer trx to inactivated account ---
	CreateAccountFee          int64
	CreateAccountBandwidthFee int64
}

type ParsedLog

type ParsedLog struct {
	Topics []string // log topics // hex string
	Data   string   // log data // hex string
}

type ParsedTx

type ParsedTx struct {
	Block     int64        // block height
	Timestamp int64        // block timestamp // milliseconds
	TxHash    string       // transaction hash
	Status    string       // transaction status // success or fail
	From      string       // from address
	To        string       // to address // wallet or contract address
	Value     int64        // transaction value
	Fee       ParsedTxFee  // transaction fee
	FeeLimit  int64        // transaction fee limit
	InputData string       // transaction input data // hex string
	Logs      []*ParsedLog // transaction logs
	TxType    int32        // transaction type // https://github.com/tronprotocol/java-tron/blob/develop/protocol/src/main/protos/core/Tron.proto#L338
}

type ParsedTxFee

type ParsedTxFee struct {
	Fee           int64 // transaction fee
	EnergyUsed    int64 // energy used
	BandwidthUsed int64 // bandwidth used
}

type TxParser

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

func NewTxParser

func NewTxParser(endpoint string) (tp *TxParser, cleanup func(), err error)

func NewTxParserWithBasicAuth

func NewTxParserWithBasicAuth(endpoint, token string) (tp *TxParser, cleanup func(), err error)

func NewTxParserWithXToken

func NewTxParserWithXToken(endpoint, token string) (tp *TxParser, cleanup func(), err error)

func (*TxParser) ParseBlock

func (tp *TxParser) ParseBlock(ctx context.Context) ([]*ParsedTx, error)

type WalletClient

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

func NewWalletClient

func NewWalletClient(endpoint, privateKeyHex string) (wc *WalletClient, cleanup func(), err error)

func NewWalletClientWithBasicAuth

func NewWalletClientWithBasicAuth(endpoint, token, privateKeyHex string) (wc *WalletClient, cleanup func(), err error)

func NewWalletClientWithXToken

func NewWalletClientWithXToken(endpoint, token, privateKeyHex string) (wc *WalletClient, cleanup func(), err error)

func (*WalletClient) EstimateGasTransferTRC20Token

func (wc *WalletClient) EstimateGasTransferTRC20Token(ctx context.Context, tokenAddress, to string, amount *big.Int, feeLimit int64) (gas Gas, err error)

func (*WalletClient) EstimateGasTransferTRC20TokenV2

func (wc *WalletClient) EstimateGasTransferTRC20TokenV2(ctx context.Context, tokenAddress, to string, amount *big.Int, feeLimit int64) (gas Gas, err error)

func (*WalletClient) EstimateGasTransferTRX

func (wc *WalletClient) EstimateGasTransferTRX(ctx context.Context, to string, amount int64) (gas Gas, err error)

func (*WalletClient) GetTRC20TokenBalance

func (wc *WalletClient) GetTRC20TokenBalance(ctx context.Context, tokenAddress string) (balance *big.Int, err error)

func (*WalletClient) GetTRC20TokenBalanceByAddress

func (wc *WalletClient) GetTRC20TokenBalanceByAddress(ctx context.Context, tokenAddress, address string) (balance *big.Int, err error)

func (*WalletClient) GetTRXBalance

func (wc *WalletClient) GetTRXBalance(ctx context.Context) (balance int64, err error)

func (*WalletClient) GetTRXBalanceByAddress

func (wc *WalletClient) GetTRXBalanceByAddress(ctx context.Context, address string) (balance int64, err error)

func (*WalletClient) TransferTRC20Token

func (wc *WalletClient) TransferTRC20Token(ctx context.Context, tokenAddress, to string, amount *big.Int, feeLimit int64) (txHash string, err error)

func (*WalletClient) TransferTRX

func (wc *WalletClient) TransferTRX(ctx context.Context, to string, amount int64) (txHash string, err error)

Jump to

Keyboard shortcuts

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