Documentation ¶
Index ¶
- Variables
- type AccountId
- type Authority
- type EventLogs
- type HTTPClient
- func (c *HTTPClient) BalanceAt(addr string) (*big.Int, error)
- func (c *HTTPClient) BalanceOf(contract, addr, body string) (*big.Int, error)
- func (c *HTTPClient) BlockNumber() (*big.Int, error)
- func (c *HTTPClient) BroadCastTransaction(transaction *TronTransaction) error
- func (c *HTTPClient) ChainID() (*big.Int, error)
- func (c *HTTPClient) DecimalsOf(contract string) (*big.Int, error)
- func (c *HTTPClient) DeployContract(strABI, strBIN, owner, name string) (*TransactionExtention, string, error)
- func (c *HTTPClient) EstimateGas(from, to string, hexValue string, data []byte) (*big.Int, error)
- func (c *HTTPClient) EthCall(from, to string, value *big.Int, data []byte) ([]byte, error)
- func (c *HTTPClient) GetAccountResource(address string) (*big.Int, *big.Int, error)
- func (c *HTTPClient) GetBlockByLastNumber() (*big.Int, error)
- func (c *HTTPClient) GetBlockByNumber(num *big.Int) (map[string]interface{}, error)
- func (c *HTTPClient) GetCode(addr ecommon.Address) (hexutil.Bytes, error)
- func (c *HTTPClient) GetEnergyPrice() (uint64, error)
- func (c *HTTPClient) GetGasPrice() (*big.Int, error)
- func (c *HTTPClient) GetTransactionByID(txHash string) (*TronTransaction, error)
- func (c *HTTPClient) GetTransactionEventsByID(txHash string) (*EventLogs, error)
- func (c *HTTPClient) GetTransactionInfoByID(txHash string) (*TransactionInfo, error)
- func (c *HTTPClient) SymbolOf(contract string) (string, error)
- func (c *HTTPClient) TotalSupplyOf(contract string) (*big.Int, error)
- func (c *HTTPClient) TransactionReceipt(hash ecommon.Hash) (*types.Receipt, error)
- func (c *HTTPClient) TriggerDelegateResource(from string, to string, resource string, amount *big.Int) (*TransactionExtention, error)
- func (c *HTTPClient) TriggerSmartContract(contract, from string, data []byte, feeLimit *big.Int) (*TransactionExtention, error)
- func (c *HTTPClient) TriggerStack(from string, resource string, amount *big.Int) (*TransactionExtention, error)
- func (c *HTTPClient) TriggerTransfer(from, to string, amount *big.Int) (*TransactionExtention, error)
- func (c *HTTPClient) TriggerUnStack(from string, resource string, amount *big.Int) (*TransactionExtention, error)
- func (c *HTTPClient) TriggerWithdrawUnStack(from string) (*TransactionExtention, error)
- type Parameter
- type TransactionContract
- type TransactionExtention
- type TransactionInfo
- type TransactionRaw
- type TransactionResult
- type TronClient
- func (tc *TronClient) AbiConvertToAddress(v interface{}) string
- func (tc *TronClient) AbiConvertToBytes(v interface{}) []byte
- func (tc *TronClient) AbiConvertToInt(v interface{}) *big.Int
- func (tc *TronClient) AbiConvertToString(v interface{}) string
- func (tc *TronClient) AddressFromPrivateKey(privateKey string) (string, error)
- func (tc *TronClient) AddressFromPublicKey(pubKey *ecdsa.PublicKey) (string, error)
- func (tc *TronClient) AddressFromString(addr string) (ecommon.Address, error)
- func (tc *TronClient) AddressToString(addr ecommon.Address) string
- func (tc *TronClient) Allowance(contract, owner, spender string) (*big.Int, error)
- func (tc *TronClient) ApproveData(contract, owner, spender string, amount *big.Int) ([]byte, error)
- func (tc *TronClient) BalanceAt(address string) (*big.Int, error)
- func (tc *TronClient) BalanceOf(contract, from string) (*big.Int, error)
- func (tc *TronClient) BlockNumber() (*big.Int, error)
- func (tc *TronClient) BroadcastTransaction(trans []byte, signature []byte) ([]byte, error)
- func (tc *TronClient) CallContract(td *chain_client.Transaction) ([]byte, error)
- func (tc *TronClient) ChainID() (*big.Int, error)
- func (tc *TronClient) ContractAddress(addr ecommon.Address) (bool, error)
- func (tc *TronClient) DecimalsOf(contract string) (uint8, error)
- func (tc *TronClient) DeployContract(contractAbi, contractBin string, td *chain_client.Transaction) ([]byte, []byte, string, error)
- func (tc *TronClient) EstimateGas(td *chain_client.Transaction) (uint64, error)
- func (tc *TronClient) GenerateDelegateResourceTransactionData(from, to, resource string, amount *big.Int) ([]byte, []byte, error)
- func (tc *TronClient) GenerateStackTransactionData(from string, resource string, amount *big.Int) ([]byte, []byte, error)
- func (tc *TronClient) GenerateUnStackTransactionData(from, resource string, amount *big.Int) ([]byte, []byte, error)
- func (tc *TronClient) GetABIByName(name string) (*eABI.ABI, error)
- func (tc *TronClient) GetBlockByNumber(num *big.Int) (map[string]interface{}, error)
- func (tc *TronClient) GetFunctionSelectorByData(abiName string, data []byte) (sig string, err error)
- func (tc *TronClient) GetGasPrice() (*big.Int, *big.Int, error)
- func (tc *TronClient) GetLackedGas(address string, gas uint64, gasPrice *big.Int, txSize uint64) (*big.Int, error)
- func (tc *TronClient) GetLatestBlockNumber() (*big.Int, error)
- func (tc *TronClient) GetNonce(address string) (uint64, error)
- func (tc *TronClient) GetNonceByNumber(address string, blockNumber *big.Int) (uint64, error)
- func (tc *TronClient) GetSuggestFee(td *chain_client.Transaction) (*chain_client.FeeLimit, error)
- func (tc *TronClient) GetSuggestGasPrice() (*big.Int, *big.Int, *big.Int, error)
- func (tc *TronClient) GetTransaction(td *chain_client.Transaction) ([]byte, []byte, error)
- func (tc *TronClient) GetTransactionByHash(transactionHash string) (*chain_client.TransactionInfo, error)
- func (tc *TronClient) GetTransactionData(method string, abiStr string, args ...interface{}) ([]byte, error)
- func (tc *TronClient) GetTransactionDataByABI(method, abiName string, args ...interface{}) (data []byte, err error)
- func (tc *TronClient) GetWithdrawUnStackData(from string) ([]byte, []byte, error)
- func (tc *TronClient) IsNativeAsset(asset string) bool
- func (tc *TronClient) IsValidAddress(addr string) bool
- func (tc *TronClient) NativeAssetAddress() string
- func (tc *TronClient) NativeAssetDecimals() uint8
- func (tc *TronClient) NormalizeAddress(addr string) string
- func (tc *TronClient) ParseEventLog(abiName string, eventLog *chain_client.EventLog) ([]interface{}, error)
- func (tc *TronClient) PublicKeyHexToAddress(key string) (string, error)
- func (tc *TronClient) RegisterABI(name, abiStr string) error
- func (tc *TronClient) SymbolOf(contract string) (string, error)
- func (tc *TronClient) TotalSupplyOf(contract string) (*big.Int, error)
- func (tc *TronClient) TransactionReceipt(hash ecommon.Hash) (*types.Receipt, error)
- func (tc *TronClient) TransferData(to string, value *big.Int) ([]byte, error)
- func (tc *TronClient) UnpackByABI(method, name string, data []byte) ([]interface{}, error)
- type TronEvent
- type TronTransaction
Constants ¶
This section is empty.
Variables ¶
var (
Trc20ABIName = "trc20"
)
Functions ¶
This section is empty.
Types ¶
type HTTPClient ¶
type HTTPClient struct { APIKey string // contains filtered or unexported fields }
HTTPClient is the chain_client to call tron http apis
func NewHTTPClient ¶
func NewHTTPClient(Endpoint, FullNode, TronGrid string) *HTTPClient
NewHTTPClient creates the chain_client Endpoint is the node address for http apis
func (*HTTPClient) BalanceAt ¶
func (c *HTTPClient) BalanceAt(addr string) (*big.Int, error)
BalanceAt returns the trx of an address
func (*HTTPClient) BalanceOf ¶
func (c *HTTPClient) BalanceOf(contract, addr, body string) (*big.Int, error)
BalanceOf calls balanceOf of TRC20
func (*HTTPClient) BlockNumber ¶
func (c *HTTPClient) BlockNumber() (*big.Int, error)
func (*HTTPClient) BroadCastTransaction ¶
func (c *HTTPClient) BroadCastTransaction(transaction *TronTransaction) error
BroadCastTransaction broads the signed transaction to tron
func (*HTTPClient) DecimalsOf ¶
func (c *HTTPClient) DecimalsOf(contract string) (*big.Int, error)
DecimalsOf calls decimals of TRC20
func (*HTTPClient) DeployContract ¶
func (c *HTTPClient) DeployContract(strABI, strBIN, owner, name string) (*TransactionExtention, string, error)
DeployContract will call deploycontract api, this api will generate the unsigned transaction
func (*HTTPClient) EstimateGas ¶
EstimateGas calls eth_estimateGas api This api is not used for now, we just use TriggerConstantContract to get the estimated energy
func (*HTTPClient) GetAccountResource ¶
GetAccountResource returns the resource of this account
func (*HTTPClient) GetBlockByLastNumber ¶
func (c *HTTPClient) GetBlockByLastNumber() (*big.Int, error)
func (*HTTPClient) GetBlockByNumber ¶
func (c *HTTPClient) GetBlockByNumber(num *big.Int) (map[string]interface{}, error)
GetBlockByNumber Returns information about a block by hash.
func (*HTTPClient) GetEnergyPrice ¶
func (c *HTTPClient) GetEnergyPrice() (uint64, error)
GetEnergyPrice calls https://api.shasta.trongrid.io/wallet/getenergyprices and gets the latest energy price in sun Can use GetGasPrice method, since the price is the same
func (*HTTPClient) GetGasPrice ¶
func (c *HTTPClient) GetGasPrice() (*big.Int, error)
func (*HTTPClient) GetTransactionByID ¶
func (c *HTTPClient) GetTransactionByID(txHash string) (*TronTransaction, error)
GetTransactionByID returns the transaction information, such as from, to, calldata
func (*HTTPClient) GetTransactionEventsByID ¶
func (c *HTTPClient) GetTransactionEventsByID(txHash string) (*EventLogs, error)
GetTransactionEventsByID returns the events log generated by a transaction
func (*HTTPClient) GetTransactionInfoByID ¶
func (c *HTTPClient) GetTransactionInfoByID(txHash string) (*TransactionInfo, error)
GetTransactionInfo returns the transaction receipt and status
func (*HTTPClient) SymbolOf ¶
func (c *HTTPClient) SymbolOf(contract string) (string, error)
SymbolOf calls symbol of TRC20
func (*HTTPClient) TotalSupplyOf ¶
func (c *HTTPClient) TotalSupplyOf(contract string) (*big.Int, error)
TotalSupplyOf implements totalSupply of an TRC20 contract
func (*HTTPClient) TransactionReceipt ¶
func (*HTTPClient) TriggerDelegateResource ¶
func (c *HTTPClient) TriggerDelegateResource(from string, to string, resource string, amount *big.Int) (*TransactionExtention, error)
func (*HTTPClient) TriggerSmartContract ¶
func (c *HTTPClient) TriggerSmartContract(contract, from string, data []byte, feeLimit *big.Int) (*TransactionExtention, error)
TriggerSmartContract calls TriggerSmartContract the details of this api can be found here: https://developers.tron.network/reference/triggersmartcontract This api will not run the contract, it just returns the transactions generated, but unsigned
func (*HTTPClient) TriggerStack ¶
func (c *HTTPClient) TriggerStack(from string, resource string, amount *big.Int) (*TransactionExtention, error)
TriggerStack generate a transaction to freeze trx
func (*HTTPClient) TriggerTransfer ¶
func (c *HTTPClient) TriggerTransfer(from, to string, amount *big.Int) (*TransactionExtention, error)
func (*HTTPClient) TriggerUnStack ¶
func (c *HTTPClient) TriggerUnStack(from string, resource string, amount *big.Int) (*TransactionExtention, error)
TriggerUnStack generate a transaction to unfreeze trx
func (*HTTPClient) TriggerWithdrawUnStack ¶
func (c *HTTPClient) TriggerWithdrawUnStack(from string) (*TransactionExtention, error)
TriggerWithdrawUnStack generate a transaction to withdraw unfrozen trx
type TransactionContract ¶
type TransactionExtention ¶
type TransactionExtention struct { Transaction *TronTransaction `json:"transaction,omitempty"` Txid string `json:"txID,omitempty"` ConstantResult [][]byte `json:"constant_result,omitempty"` Energy uint64 `json:"energy_used,omitempty"` }
type TransactionInfo ¶
type TransactionRaw ¶
type TransactionRaw struct { //only support size = 1, repeated list here for extension Contract []*TransactionContract `json:"contract,omitempty"` RefBlockBytes []byte `json:"ref_block_bytes,omitempty"` RefBlockNum int64 `json:"ref_block_num,omitempty"` RefBlockHash []byte `json:"ref_block_hash,omitempty"` Expiration int64 `json:"expiration,omitempty"` Auths []*Authority `json:"auths,omitempty"` // transaction note Data []byte `json:"data,omitempty"` // scripts not used Scripts []byte `json:"scripts,omitempty"` FeeLimit int64 `json:"fee_limit,omitempty"` Timestamp int64 `json:"timestamp,omitempty"` }
type TransactionResult ¶
type TransactionResult struct { Fee int64 `json:"fee,omitempty"` Ret string `json:"ret,omitempty"` ContractRet string `json:"contractRet,omitempty"` AssetIssueID string `json:"assetIssueID,omitempty"` WithdrawAmount int64 `json:"withdraw_amount,omitempty"` UnfreezeAmount int64 `json:"unfreeze_amount,omitempty"` ExchangeReceivedAmount int64 `json:"exchange_received_amount,omitempty"` ExchangeInjectAnotherAmount int64 `json:"exchange_inject_another_amount,omitempty"` ExchangeWithdrawAnotherAmount int64 `json:"exchange_withdraw_another_amount,omitempty"` ExchangeId int64 `json:"exchange_id,omitempty"` ShieldedTransactionFee int64 `json:"shielded_transaction_fee,omitempty"` }
type TronClient ¶
type TronClient struct {
// contains filtered or unexported fields
}
TronClient implements BlockChainClient Interface
func NewTronClient ¶
func NewTronClient(config *chain_client.ChainConfiguration) (*TronClient, error)
NewTronClient creates the chain_client
func (*TronClient) AbiConvertToAddress ¶
func (tc *TronClient) AbiConvertToAddress(v interface{}) string
func (*TronClient) AbiConvertToBytes ¶
func (tc *TronClient) AbiConvertToBytes(v interface{}) []byte
func (*TronClient) AbiConvertToInt ¶
func (tc *TronClient) AbiConvertToInt(v interface{}) *big.Int
func (*TronClient) AbiConvertToString ¶
func (tc *TronClient) AbiConvertToString(v interface{}) string
func (*TronClient) AddressFromPrivateKey ¶
func (tc *TronClient) AddressFromPrivateKey(privateKey string) (string, error)
func (*TronClient) AddressFromPublicKey ¶
func (tc *TronClient) AddressFromPublicKey(pubKey *ecdsa.PublicKey) (string, error)
func (*TronClient) AddressFromString ¶
func (tc *TronClient) AddressFromString(addr string) (ecommon.Address, error)
AddressFromString convert base58 address hexed address 兼容以太坊地址
func (*TronClient) AddressToString ¶
func (tc *TronClient) AddressToString(addr ecommon.Address) string
func (*TronClient) Allowance ¶
func (tc *TronClient) Allowance(contract, owner, spender string) (*big.Int, error)
func (*TronClient) ApproveData ¶
func (*TronClient) BalanceAt ¶
func (tc *TronClient) BalanceAt(address string) (*big.Int, error)
BalanceAt returns the amount of trx
func (*TronClient) BalanceOf ¶
func (tc *TronClient) BalanceOf(contract, from string) (*big.Int, error)
BalanceOf returns the amount of a token
func (*TronClient) BlockNumber ¶
func (tc *TronClient) BlockNumber() (*big.Int, error)
func (*TronClient) BroadcastTransaction ¶
func (tc *TronClient) BroadcastTransaction(trans []byte, signature []byte) ([]byte, error)
BroadcastTransaction broadcasts the transaction to chain
func (*TronClient) CallContract ¶
func (tc *TronClient) CallContract(td *chain_client.Transaction) ([]byte, error)
CallContract call eth_call
func (*TronClient) ChainID ¶
func (tc *TronClient) ChainID() (*big.Int, error)
ChainID returns chainID
func (*TronClient) ContractAddress ¶
func (tc *TronClient) ContractAddress(addr ecommon.Address) (bool, error)
func (*TronClient) DecimalsOf ¶
func (tc *TronClient) DecimalsOf(contract string) (uint8, error)
DecimalsOf returns the decimals of an contract
func (*TronClient) DeployContract ¶
func (tc *TronClient) DeployContract(contractAbi, contractBin string, td *chain_client.Transaction) ( []byte, []byte, string, error)
TODO, this function is not finished yet, need to refer to https://github.com/tronprotocol/sun-network/blob/develop/js-sdk/src/index.js to change the sign functions to make it work
func (*TronClient) EstimateGas ¶
func (tc *TronClient) EstimateGas(td *chain_client.Transaction) (uint64, error)
func (*TronClient) GenerateDelegateResourceTransactionData ¶
func (*TronClient) GenerateStackTransactionData ¶
func (*TronClient) GenerateUnStackTransactionData ¶
func (*TronClient) GetABIByName ¶
func (tc *TronClient) GetABIByName(name string) (*eABI.ABI, error)
func (*TronClient) GetBlockByNumber ¶
func (tc *TronClient) GetBlockByNumber(num *big.Int) (map[string]interface{}, error)
GetBlockByNumber returns block info
func (*TronClient) GetFunctionSelectorByData ¶
func (tc *TronClient) GetFunctionSelectorByData(abiName string, data []byte) (sig string, err error)
func (*TronClient) GetGasPrice ¶
func (*TronClient) GetLackedGas ¶
func (*TronClient) GetLatestBlockNumber ¶
func (tc *TronClient) GetLatestBlockNumber() (*big.Int, error)
func (*TronClient) GetNonce ¶
func (tc *TronClient) GetNonce(address string) (uint64, error)
GetNonce is not implemented for Tron And Tron is not used by Tron
func (*TronClient) GetNonceByNumber ¶
func (*TronClient) GetSuggestFee ¶
func (tc *TronClient) GetSuggestFee(td *chain_client.Transaction) (*chain_client.FeeLimit, error)
GetSuggestFee returns the estimated fee for a transaction
func (*TronClient) GetSuggestGasPrice ¶
func (*TronClient) GetTransaction ¶
func (tc *TronClient) GetTransaction(td *chain_client.Transaction) ([]byte, []byte, error)
GetTransaction returns the unsigned transaction and the hash value
func (*TronClient) GetTransactionByHash ¶
func (tc *TronClient) GetTransactionByHash(transactionHash string) (*chain_client.TransactionInfo, error)
func (*TronClient) GetTransactionData ¶
func (tc *TronClient) GetTransactionData(method string, abiStr string, args ...interface{}) ([]byte, error)
GetTransactionData generate the data in transaction
func (*TronClient) GetTransactionDataByABI ¶
func (tc *TronClient) GetTransactionDataByABI(method, abiName string, args ...interface{}) (data []byte, err error)
GetTransactionDataByABI GetERC20Transaction is similar with GetTransactionData, except it is using the build in abi
func (*TronClient) GetWithdrawUnStackData ¶
func (tc *TronClient) GetWithdrawUnStackData(from string) ([]byte, []byte, error)
func (*TronClient) IsNativeAsset ¶
func (tc *TronClient) IsNativeAsset(asset string) bool
func (*TronClient) IsValidAddress ¶
func (tc *TronClient) IsValidAddress(addr string) bool
func (*TronClient) NativeAssetAddress ¶
func (tc *TronClient) NativeAssetAddress() string
func (*TronClient) NativeAssetDecimals ¶
func (tc *TronClient) NativeAssetDecimals() uint8
func (*TronClient) NormalizeAddress ¶
func (tc *TronClient) NormalizeAddress(addr string) string
func (*TronClient) ParseEventLog ¶
func (tc *TronClient) ParseEventLog(abiName string, eventLog *chain_client.EventLog) ([]interface{}, error)
func (*TronClient) PublicKeyHexToAddress ¶
func (tc *TronClient) PublicKeyHexToAddress(key string) (string, error)
func (*TronClient) RegisterABI ¶
func (tc *TronClient) RegisterABI(name, abiStr string) error
RegisterABI registe the abi with a name
func (*TronClient) SymbolOf ¶
func (tc *TronClient) SymbolOf(contract string) (string, error)
SymbolOf returns the symbol of a contract
func (*TronClient) TotalSupplyOf ¶
func (tc *TronClient) TotalSupplyOf(contract string) (*big.Int, error)
TotalSupplyOf returns the total supply of a contract
func (*TronClient) TransactionReceipt ¶
func (*TronClient) TransferData ¶
func (*TronClient) UnpackByABI ¶
func (tc *TronClient) UnpackByABI(method, name string, data []byte) ([]interface{}, error)
type TronTransaction ¶
type TronTransaction struct { Visible bool `json:"visible"` Txid string `json:"txID,omitempty"` ContractAddress string `json:"contract_address,omitempty"` RawData *TransactionRaw `json:"raw_data,omitempty"` RawDataHex string `json:"raw_data_hex,omitempty"` Signature []string `json:"signature,omitempty"` Ret []*TransactionResult `json:"ret,omitempty"` }