tron

package
v0.0.0-...-03146ae Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DEBUG = false

Functions

This section is empty.

Types

type Config

type Config struct {
	GrpcHost   string
	GrpcPort   int
	GrpcAPIKEY string
	Solidity   string
	ZeroMQ     string
	Contracts  []string
}

type Contract

type Contract struct {
	Decimals *big.Int
	Symbol   string
	Name     string
}

type Message

type Message struct {
	Timestamp                   int64           `json:"timestamp"`
	TriggerName                 string          `json:"triggerName"`
	TransactionId               string          `json:"transactionId"`
	BlockHash                   string          `json:"blockHash"`
	BlockNumber                 int64           `json:"blockNumber"`
	EnergyUsage                 decimal.Decimal `json:"energyUsage"`
	EnergyFee                   decimal.Decimal `json:"energyFee"`
	OriginEnergyUsage           decimal.Decimal `json:"originEnergyUsage"`
	EnergyUsageTotal            decimal.Decimal `json:"energyUsageTotal"`
	NetUsage                    decimal.Decimal `json:"netUsage"`
	NetFee                      decimal.Decimal `json:"netFee"`
	Result                      string          `json:"result"`
	ContractAddress             string          `json:"contractAddress"`
	ContractType                string          `json:"contractType"`
	FeeLimit                    decimal.Decimal `json:"feeLimit"`
	ContractCallValue           decimal.Decimal `json:"contractCallValue"`
	ContractResult              string          `json:"contractResult"`
	FromAddress                 string          `json:"fromAddress"`
	ToAddress                   string          `json:"toAddress"`
	AssetName                   string          `json:"assetName"`
	AssetAmount                 decimal.Decimal `json:"assetAmount"`
	LatestSolidifiedBlockNumber int64           `json:"latestSolidifiedBlockNumber"`
	Data                        string          `json:"data"`
	TransactionIndex            int64           `json:"transactionIndex"`
	CumulativeEnergyUsed        decimal.Decimal `json:"cumulativeEnergyUsed"`
	PreCumulativeLogCount       int64           `json:"preCumulativeLogCount"`
	EnergyUnitPrice             decimal.Decimal `json:"energyUnitPrice"`
}

type Transaction

type Transaction struct {
	Type         int
	Raw          Message
	TxId         string
	Contract     string
	Address      string
	AddressTo    string
	Amount       decimal.Decimal
	ContractData *Contract
}

type TronClient

type TronClient struct {
	C         *tron_client.GrpcClient
	Cfg       *Config
	ABIs      map[string]abi.ABI
	ChStatus  bool
	Ch        chan Transaction
	Mu        *sync.RWMutex
	Contracts map[string]Contract
	Ctx       context.Context
	CancelCtx context.CancelFunc
}

func Client

func Client(cfg *Config) (*TronClient, error)

func (*TronClient) GetContractData

func (c *TronClient) GetContractData(contract string) (*Contract, error)

func (*TronClient) StartListener

func (c *TronClient) StartListener() (chan Transaction, error)

func (*TronClient) StopListener

func (c *TronClient) StopListener()

Jump to

Keyboard shortcuts

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