Documentation ¶
Overview ¶
Package client provides functionality for interacting with the Tron node RESTful APIs.
Index ¶
- type CallContractInput
- type Client
- func (c *Client) BroadcastTransaction(tx *tron.Transaction) error
- func (c *Client) CallContract(acc account.Account, input CallContractInput) (tron.Transaction, error)
- func (c *Client) DeployContract(acc account.Account, input DeployContractInput) (*TransactionInfo, error)
- func (c *Client) GetAccount(addr string) (Getaccount, error)
- func (c *Client) GetBlockByHeight(n uint64) (*tron.Block, error)
- func (c *Client) GetBlockById(id string) (*tron.Block, error)
- func (c *Client) GetBlockRange(start, end uint64) ([]tron.Block, error)
- func (c *Client) GetLatestBlock() (tron.Block, error)
- func (c *Client) GetLatestBlocks(n int) ([]tron.Block, error)
- func (c *Client) TransactionById(id string) (*tron.Transaction, error)
- func (c *Client) TransactionInfoById(id string) (*TransactionInfo, error)
- func (c *Client) Transfer(src account.Account, dest address.Address, amount uint64) (tron.Transaction, error)
- func (c *Client) TransferAsset(src account.Account, dest address.Address, assetName string, amount uint64) (tron.Transaction, error)
- func (c *Client) TriggerSmartContract(acc account.Account, input CallContractInput) ([]string, error)
- type DeployContractInput
- type Getaccount
- type TransactionInfo
- type TransactionReceipt
- type TransactionResult
- type V2
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CallContractInput ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) BroadcastTransaction ¶
BroadcastTransaction broadcasts a signed transaction to the network.
func (*Client) CallContract ¶
func (c *Client) CallContract(acc account.Account, input CallContractInput) (tron.Transaction, error)
CallContract calls a function of a contract. If the function is immutable (either 'pure' or 'view') then the constant function is triggered and the returned encoded ABI value is unmarshaled to CallContractInput.Result. Immutable functions will return nil transaction info because there is no transaction that is committed to the blockchain. Mutable function calls will be broadcasted and the function will wait until the call has been completed. The returned ABI value is also unmarshaled to CallContractInput.Result. Mutable functions will return transaction info if they are successfully processed.
func (*Client) DeployContract ¶
func (c *Client) DeployContract(acc account.Account, input DeployContractInput) (*TransactionInfo, error)
DeployContract deploys a contract. The owner of the deployed contract will be the account that this function was called with.
func (*Client) GetAccount ¶
func (c *Client) GetAccount(addr string) (Getaccount, error)
func (*Client) GetBlockByHeight ¶
GetBlockByHeight returns the block at the specified height.
func (*Client) GetBlockById ¶
GetBlockById returns the block for the specified id.
func (*Client) GetBlockRange ¶
GetBlockRange returns the blocks within a height range, end exclusive.
func (*Client) GetLatestBlock ¶
GetLatestBlock returns the latest block synced to the node.
func (*Client) GetLatestBlocks ¶
GetLatestBlocks returns the last n blocks synced to the node.
func (*Client) TransactionById ¶
TransactionById returns the transaction for the provided id.
func (*Client) TransactionInfoById ¶
func (c *Client) TransactionInfoById(id string) (*TransactionInfo, error)
TransactionInfoById returns the information about a processed transaction. If the transaction does not exist or has not yet been processed then the returned information will be nil even though an error will not be returned.
func (*Client) Transfer ¶
func (c *Client) Transfer(src account.Account, dest address.Address, amount uint64) (tron.Transaction, error)
Transfer transfers a balance of Tron from a source account to a destination address.
func (*Client) TransferAsset ¶
func (c *Client) TransferAsset(src account.Account, dest address.Address, assetName string, amount uint64) (tron.Transaction, error)
TransferAsset trc10
func (*Client) TriggerSmartContract ¶
type DeployContractInput ¶
type Getaccount ¶
type TransactionInfo ¶
type TransactionInfo struct { Id string `json:"id"` Fee uint64 `json:"fee"` BlockNumber uint64 `json:"blockNumber"` BlockTimestamp uint64 `json:"blockTimestamp"` ContractResult []string `json:"contractResult"` ContractAddress address.Address `json:"contract_address"` Receipt TransactionReceipt `json:"receipt"` Log *json.RawMessage `json:"log"` }
TransactionInfo contains information about a processed transaction.
func (TransactionInfo) Error ¶
func (t TransactionInfo) Error() error
type TransactionReceipt ¶
type TransactionReceipt struct { EnergyFee uint64 `json:"energy_fee"` EnergyUsageTotal uint64 `json:"energy_usage_total"` NetFee uint64 `json:"net_fee"` NetUsage uint64 `json:"net_usage"` Result TransactionResult `json:"result"` }
type TransactionResult ¶
type TransactionResult string
TransactionResult is an enumeration which described what happened when processing a transaction. This is not to be confused with the result of executing a contract which will be an ABI encoded payload.
const ( TxResultSuccess TransactionResult = "SUCCESS" TxResultRevert TransactionResult = "REVERT" TxResultBadJump TransactionResult = "BAD_JUST_DESTINATION" TxResultOutOfMemory TransactionResult = "OUT_OF_MEMORY" TxResultPrecompiledContract TransactionResult = "PRECOMPILED_CONTRACT" TxResultStackTooSmall TransactionResult = "STACK_TOO_SMALL" TxResultStackTooLarge TransactionResult = "STACK_TOO_LARGE" TxResultIllegalOp TransactionResult = "ILLEGAL_OPERATION" TxResultStackOverflow TransactionResult = "STACK_OVERFLOW" TxResultOutOfEnergy TransactionResult = "OUT_OF_ENERGY" TxOutOfTime TransactionResult = "OUT_OF_TIME" TxResultJVMStackOverflow TransactionResult = "JVM_STACK_OVER_FLOW" TxResultUnknown TransactionResult = "UNKNOWN" TxResultTransferFailed TransactionResult = "TRANSFER_FAILED" )