trxapi

package
v0.0.0-...-d64fc3f Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2021 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Asset

type Asset struct {
	Coinid     string  `json:"coinid"`
	Contractid string  `json:"contractid"`
	Symbol     string  `json:"symbol"`
	Value      float64 `json:"value"`
}

type Assets

type Assets struct {
	Address string `json:"address"`
	Balance int64  `json:"balance"`
	Asset   []struct {
		Key   string `json:"key"`
		Value int    `json:"value"`
	} `json:"asset"`
	CreateTime            int64 `json:"create_time"`
	LatestOprationTime    int64 `json:"latest_opration_time"`
	FreeNetUsage          int   `json:"free_net_usage"`
	LatestConsumeFreeTime int64 `json:"latest_consume_free_time"`
	AccountResource       struct {
		EnergyUsage                             int   `json:"energy_usage"`
		LatestConsumeTimeForEnergy              int64 `json:"latest_consume_time_for_energy"`
		AcquiredDelegatedFrozenBalanceForEnergy int   `json:"acquired_delegated_frozen_balance_for_energy"`
	} `json:"account_resource"`
	AcquiredDelegatedFrozenBalanceForBandwidth int `json:"acquired_delegated_frozen_balance_for_bandwidth"`
	AssetV2                                    []struct {
		Key   string `json:"key"`
		Value int    `json:"value"`
	} `json:"assetV2"`
	FreeAssetNetUsageV2 []struct {
		Key   string `json:"key"`
		Value int    `json:"value"`
	} `json:"free_asset_net_usageV2"`
}

type Block

type Block struct {
	BlockID     string `json:"blockID"`
	BlockHeader struct {
		RawData struct {
			Number         int    `json:"number"`
			TxTrieRoot     string `json:"txTrieRoot"`
			WitnessAddress string `json:"witness_address"`
			ParentHash     string `json:"parentHash"`
			Version        int    `json:"version"`
			Timestamp      int64  `json:"timestamp"`
		} `json:"raw_data"`
		WitnessSignature string `json:"witness_signature"`
	} `json:"block_header"`
	Transactions []Transactions `json:"transactions"`
}

type BlockInfo

type BlockInfo struct {
	BlockID     string `json:"blockID"`
	BlockHeader struct {
		RawData struct {
			Number         int    `json:"number"`
			TxTrieRoot     string `json:"txTrieRoot"`
			WitnessAddress string `json:"witness_address"`
			ParentHash     string `json:"parentHash"`
			Version        int    `json:"version"`
			Timestamp      int64  `json:"timestamp"`
		} `json:"raw_data"`
		WitnessSignature string `json:"witness_signature"`
	} `json:"block_header"`
	Transactions []struct {
		Ret []struct {
			ContractRet string `json:"contractRet"`
		} `json:"ret"`
		Signature []string `json:"signature"`
		TxID      string   `json:"txID"`
		RawData   struct {
			Contract []struct {
				Parameter struct {
					Value struct {
						Data         string `json:"data"`
						Amount       int    `json:"amount"`
						AssetName    string `json:"asset_name"`
						OwnerAddress string `json:"owner_address"`
						ToAddress    string `json:"to_address"`
					} `json:"value"`
					TypeURL string `json:"type_url"`
				} `json:"parameter"`
				Type string `json:"type"`
			} `json:"contract"`
			RefBlockBytes string `json:"ref_block_bytes"`
			RefBlockHash  string `json:"ref_block_hash"`
			Expiration    int64  `json:"expiration"`
			Timestamp     int64  `json:"timestamp"`
		} `json:"raw_data,omitempty"`
	} `json:"transactions"`
}

type Client

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

func New

func New(logger log.Logger, ip string) *Client

func (*Client) BalanceOfErc20Usdt

func (c *Client) BalanceOfErc20Usdt(from string) (map[string]interface{}, error)

func (*Client) CheckBlockNumber

func (c *Client) CheckBlockNumber() (blocknumber int64)

func (*Client) CheckHash

func (c *Client) CheckHash(hash string) (status int, blocknumber int)

func (*Client) GetAccountById

func (cli *Client) GetAccountById(add string) (info *Assets, err error)

func (*Client) GetAssetissueByAccount

func (cli *Client) GetAssetissueByAccount(add string) (info *Assets, err error)

func (*Client) GetBalance

func (cli *Client) GetBalance(add string) (info *Assets, err error)

func (*Client) GetBalanceByContract

func (c *Client) GetBalanceByContract(address, contractid string) (balance float64)

func (*Client) GetBalanceX

func (c *Client) GetBalanceX(address string) ([]Asset, error)

GetBalance 查询地址余额

func (*Client) GetBlockByHeight

func (cli *Client) GetBlockByHeight(num int64) (info *Block, err error)

func (*Client) GetBlockInfo

func (cli *Client) GetBlockInfo() (info *BlockInfo, err error)

func (*Client) GetContract

func (cli *Client) GetContract(value string) (res string, err error)

func (*Client) GetHeight

func (c *Client) GetHeight() int64

GetHeight 获取当前高度

func (*Client) GetLastBlock

func (cli *Client) GetLastBlock() (lastblock LastBlock, err error)

func (*Client) GetTransactionByHash

func (cli *Client) GetTransactionByHash(hash string) (info *Transactions, err error)

func (*Client) GetTransactionByIDEx

func (c *Client) GetTransactionByIDEx(hash string) (map[string]interface{}, error)

GetTransactionByIDEx 根据hash获取交易信息

func (*Client) GetTransactionInfoByHash

func (cli *Client) GetTransactionInfoByHash(hash string) (info *TransactionInfo, err error)

func (*Client) PushTransaction

func (cli *Client) PushTransaction(sign string) (tx *TxResult, err error)

func (*Client) SendErc20Usdt

func (c *Client) SendErc20Usdt(signerAddress tronAddress, to string, amount string) (map[string]interface{}, error)

SendErc20Usdt 不用

func (*Client) Start

func (c *Client) Start() (err error)

func (*Client) Stop

func (c *Client) Stop()

type LastBlock

type LastBlock struct {
	Number         int    `json:"number"`
	Hash           string `json:"hash"`
	Size           int    `json:"size"`
	Timestamp      int64  `json:"timestamp"`
	TxTrieRoot     string `json:"txTrieRoot"`
	ParentHash     string `json:"parentHash"`
	WitnessID      int    `json:"witnessId"`
	WitnessAddress string `json:"witnessAddress"`
	NrOfTrx        int    `json:"nrOfTrx"`
	Confirmed      bool   `json:"confirmed"`
}

type Transaction

type Transaction struct {
	Block        int    `json:"block"`
	Hash         string `json:"hash"`
	Timestamp    int64  `json:"timestamp"`
	OwnerAddress string `json:"ownerAddress"`
	ToAddress    string `json:"toAddress"`
	ContractType int    `json:"contractType"`
	Confirmed    bool   `json:"confirmed"`
	ContractRet  string `json:"contractRet"`
	ContractData struct {
		Data            string `json:"data"`
		OwnerAddress    string `json:"owner_address"`
		ContractAddress string `json:"contract_address"`
		CallValue       int    `json:"call_value"`
	} `json:"contractData"`
	Data string `json:"data"`
	Cost struct {
		NetUsage          int `json:"net_usage"`
		NetFee            int `json:"net_fee"`
		EnergyUsage       int `json:"energy_usage"`
		EnergyFee         int `json:"energy_fee"`
		OriginEnergyUsage int `json:"origin_energy_usage"`
		EnergyUsageTotal  int `json:"energy_usage_total"`
	} `json:"cost"`
	TriggerInfo struct {
		Method    string `json:"method"`
		Parameter struct {
			Number    string `json:"_number"`
			Direction string `json:"_direction"`
		} `json:"parameter"`
		CallValue int `json:"call_value"`
	} `json:"trigger_info"`
	InternalTransactions struct {
		Num1 []struct {
			TransactionID     string `json:"transaction_id"`
			CallerAddress     string `json:"caller_address"`
			Note              string `json:"note"`
			Rejected          bool   `json:"rejected"`
			ValueInfoList     string `json:"value_info_list"`
			DateCreated       int64  `json:"date_created"`
			Block             int    `json:"block"`
			Hash              string `json:"hash"`
			TransferToAddress string `json:"transfer_to_address"`
		} `json:"1"`
	} `json:"internal_transactions"`
}

type TransactionInfo

type TransactionInfo struct {
	BlockNumber     int64    `json:"blockNumber"`
	BlockTimeStamp  int64    `json:"blockTimeStamp"`
	ContractResult  []string `json:"contractResult"`
	ContractAddress string   `json:"contract_address"`
	Fee             int64    `json:"fee"`
	ID              string   `json:"id"`
	Log             []struct {
		Address string   `json:"address"`
		Data    string   `json:"data"`
		Topics  []string `json:"topics"`
	} `json:"log"`
	Receipt struct {
		EnergyFee        int64  `json:"energy_fee"`
		EnergyUsageTotal int64  `json:"energy_usage_total"`
		NetUsage         int64  `json:"net_usage"`
		Result           string `json:"result"`
	} `json:"receipt"`
}

type Transactions

type Transactions struct {
	RawData struct {
		Contract []struct {
			Parameter struct {
				TypeURL string `json:"type_url"`
				Value   struct {
					AccountAddress  string `json:"account_address"`
					Amount          int64  `json:"amount"`
					CallValue       int64  `json:"call_value"`
					ContractAddress string `json:"contract_address"`
					Data            string `json:"data"`
					OwnerAddress    string `json:"owner_address"`
					ToAddress       string `json:"to_address"`
				} `json:"value"`
			} `json:"parameter"`
			Type string `json:"type"`
		} `json:"contract"`
		Data          string `json:"data"`
		Expiration    int64  `json:"expiration"`
		FeeLimit      int64  `json:"fee_limit"`
		RefBlockBytes string `json:"ref_block_bytes"`
		RefBlockHash  string `json:"ref_block_hash"`
		Timestamp     int64  `json:"timestamp"`
	} `json:"raw_data"`
	RawDataHex string `json:"raw_data_hex"`
	Ret        []struct {
		ContractRet string `json:"contractRet"`
	} `json:"ret"`
	Signature []string `json:"signature"`
	TxID      string   `json:"txID"`
}

type TriggerConstantContractReq

type TriggerConstantContractReq struct {
	ContractAddress  string `json:"contract_address"`
	FunctionSelector string `json:"function_selector"`
	Parameter        string `json:"parameter"`
	FeeLimit         int    `json:"fee_limit"`
	CallValue        int    `json:"call_value"`
	OwnerAddress     string `json:"owner_address"`
	Visible          bool   `json:"visible"`
}

type TriggerConstantContractResp

type TriggerConstantContractResp struct {
	Result struct {
		Result  bool   `json:"result"`
		Code    string `json:"code"`
		Message string `json:"message"`
	} `json:"result"`
	ConstantResult []string `json:"constant_result"`
	Transaction    struct {
		Visible bool `json:"visible"`
	} `json:"transaction"`
}

type TxResult

type TxResult struct {
	Result      bool   `json:"result"`
	Code        string `json:"code"`
	Txid        string `json:"txid"`
	Message     string `json:"message"`
	Transaction string `json:"transaction"`
}

type TxRet

type TxRet struct {
	Ret         int
	ContractRet int
}

Jump to

Keyboard shortcuts

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