Documentation ¶
Index ¶
- Constants
- func Base58ToHex(base58Address string) (string, error)
- func NewChainAdaptor(conf *config.Config) (chain.IChainAdaptor, error)
- func PadLeftZero(hexStr string, length int) string
- func ParseTRC20TransferData(data string) (string, *big.Int)
- type Account
- type AccountResource
- type ActivePermission
- type AssetV2
- type Block
- type BroadcastReturns
- type ChainAdaptor
- func (c *ChainAdaptor) BuildSignedTransaction(req *account.SignedTransactionRequest) (*account.SignedTransactionResponse, error)
- func (c *ChainAdaptor) ConvertAddress(req *account.ConvertAddressRequest) (*account.ConvertAddressResponse, error)
- func (c *ChainAdaptor) CreateUnSignTransaction(req *account.UnSignTransactionRequest) (*account.UnSignTransactionResponse, error)
- func (c *ChainAdaptor) DecodeTransaction(req *account.DecodeTransactionRequest) (*account.DecodeTransactionResponse, error)
- func (c *ChainAdaptor) GetAccount(req *account.AccountRequest) (*account.AccountResponse, error)
- func (c *ChainAdaptor) GetBlockByHash(req *account.BlockHashRequest) (*account.BlockResponse, error)
- func (c *ChainAdaptor) GetBlockByNumber(req *account.BlockNumberRequest) (*account.BlockResponse, error)
- func (c *ChainAdaptor) GetBlockByRange(req *account.BlockByRangeRequest) (*account.BlockByRangeResponse, error)
- func (c *ChainAdaptor) GetBlockHeaderByHash(req *account.BlockHeaderHashRequest) (*account.BlockHeaderResponse, error)
- func (c *ChainAdaptor) GetBlockHeaderByNumber(req *account.BlockHeaderNumberRequest) (*account.BlockHeaderResponse, error)
- func (c *ChainAdaptor) GetExtraData(req *account.ExtraDataRequest) (*account.ExtraDataResponse, error)
- func (c *ChainAdaptor) GetFee(req *account.FeeRequest) (*account.FeeResponse, error)
- func (c *ChainAdaptor) GetSupportChains(req *account.SupportChainsRequest) (*account.SupportChainsResponse, error)
- func (c *ChainAdaptor) GetTxByAddress(req *account.TxAddressRequest) (*account.TxAddressResponse, error)
- func (c *ChainAdaptor) GetTxByHash(req *account.TxHashRequest) (*account.TxHashResponse, error)
- func (c *ChainAdaptor) SendTx(req *account.SendTxRequest) (*account.SendTxResponse, error)
- func (c *ChainAdaptor) ValidAddress(req *account.ValidAddressRequest) (*account.ValidAddressResponse, error)
- func (c *ChainAdaptor) VerifySignedTransaction(req *account.VerifyTransactionRequest) (*account.VerifyTransactionResponse, error)
- type ChainParameters
- type Contract
- type FreeAssetNetUsageV2
- type FrozenV2
- type Keys
- type OwnerPermission
- type Parameter
- type RawData
- type Response
- type Ret
- type SendTxReq
- type TRC20BalanceResponse
- type Transaction
- type TronClient
- func (client *TronClient) BroadcastTransaction(raw *SendTxReq) (*BroadcastReturns, error)
- func (client *TronClient) CreateTRC20Transaction(from, to, contractAddress string, amount int64) (*UnSignTransaction, error)
- func (client *TronClient) CreateTRXTransaction(from, to string, amount int64) (*UnSignTransaction, error)
- func (client *TronClient) GetAccount(address string) (*Account, error)
- func (client *TronClient) GetBlockByHash(blockHash string) (*Block, error)
- func (client *TronClient) GetBlockByNumber(blockNumber int64) (*Block, error)
- func (client *TronClient) GetChainParameters() (*ChainParameters, error)
- func (client *TronClient) GetTRC20Balance(address, contractAddress string) (string, error)
- func (client *TronClient) GetTransactionByID(txHash string) (*Transaction, error)
- func (client *TronClient) GetTxByAddress(address string) (interface{}, error)
- func (client *TronClient) JsonRpc(method string, params interface{}, result interface{}) error
- func (client *TronClient) Solidity(method string, params interface{}, result interface{}) error
- func (client *TronClient) Wallet(method string, params interface{}, result interface{}) error
- type TronData
- type TxStructure
- type UnSignTransaction
- type UnSignTrc20Transaction
- type Value
Constants ¶
const ( ChainName = "Tron" TronSymbol = "TRX" )
const (
AddressPrefix = "41"
)
Variables ¶
This section is empty.
Functions ¶
func Base58ToHex ¶
Base58ToHex Convert TRON address from base58 to hexadecimal
func NewChainAdaptor ¶
func NewChainAdaptor(conf *config.Config) (chain.IChainAdaptor, error)
func PadLeftZero ¶
PadLeftZero Fill the left side of the hexadecimal string with zero to the specified length
Types ¶
type Account ¶
type Account struct { Address string `json:"address"` Balance int `json:"balance"` CreateTime int64 `json:"create_time"` LatestConsumeTime int64 `json:"latest_consume_time"` NetWindowSize int `json:"net_window_size"` NetWindowOptimized bool `json:"net_window_optimized"` AccountResource AccountResource `json:"account_resource"` OwnerPermission OwnerPermission `json:"owner_permission"` ActivePermission []ActivePermission `json:"active_permission"` FrozenV2 []FrozenV2 `json:"frozenV2"` AssetV2 []AssetV2 `json:"assetV2"` FreeAssetNetUsageV2 []FreeAssetNetUsageV2 `json:"free_asset_net_usageV2"` AssetOptimized bool `json:"asset_optimized"` }
type AccountResource ¶
type AccountResource struct { LatestConsumeTimeForEnergy int64 `json:"latest_consume_time_for_energy"` EnergyWindowSize int `json:"energy_window_size"` AcquiredDelegatedFrozenV2BalanceForEnergy int `json:"acquired_delegated_frozenV2_balance_for_energy"` EnergyWindowOptimized bool `json:"energy_window_optimized"` }
type ActivePermission ¶
type Block ¶
type Block struct { BaseFeePerGas string `json:"baseFeePerGas"` Difficulty string `json:"difficulty"` ExtraData string `json:"extraData"` GasLimit string `json:"gasLimit"` GasUsed string `json:"gasUsed"` Hash string `json:"hash"` LogsBloom string `json:"logsBloom"` Miner string `json:"miner"` MixHash string `json:"mixHash"` Nonce string `json:"nonce"` Number string `json:"number"` ParentHash string `json:"parentHash"` ReceiptsRoot string `json:"receiptsRoot"` Sha3Uncles string `json:"sha3Uncles"` Size string `json:"size"` StateRoot string `json:"stateRoot"` Timestamp string `json:"timestamp"` TotalDifficulty string `json:"totalDifficulty"` Transactions []string `json:"transactions"` TransactionsRoot string `json:"transactionsRoot"` Uncles []interface{} `json:"uncles"` }
type BroadcastReturns ¶
type ChainAdaptor ¶
type ChainAdaptor struct {
// contains filtered or unexported fields
}
func (*ChainAdaptor) BuildSignedTransaction ¶
func (c *ChainAdaptor) BuildSignedTransaction(req *account.SignedTransactionRequest) (*account.SignedTransactionResponse, error)
BuildSignedTransaction Create a signed transaction
func (*ChainAdaptor) ConvertAddress ¶
func (c *ChainAdaptor) ConvertAddress(req *account.ConvertAddressRequest) (*account.ConvertAddressResponse, error)
ConvertAddress Convert public key to address
func (*ChainAdaptor) CreateUnSignTransaction ¶
func (c *ChainAdaptor) CreateUnSignTransaction(req *account.UnSignTransactionRequest) (*account.UnSignTransactionResponse, error)
CreateUnSignTransaction Create unsigned transactions
func (*ChainAdaptor) DecodeTransaction ¶
func (c *ChainAdaptor) DecodeTransaction(req *account.DecodeTransactionRequest) (*account.DecodeTransactionResponse, error)
DecodeTransaction Decoding transactions
func (*ChainAdaptor) GetAccount ¶
func (c *ChainAdaptor) GetAccount(req *account.AccountRequest) (*account.AccountResponse, error)
GetAccount Obtain account information based on the address
func (*ChainAdaptor) GetBlockByHash ¶
func (c *ChainAdaptor) GetBlockByHash(req *account.BlockHashRequest) (*account.BlockResponse, error)
GetBlockByHash Obtain block information based on block hash
func (*ChainAdaptor) GetBlockByNumber ¶
func (c *ChainAdaptor) GetBlockByNumber(req *account.BlockNumberRequest) (*account.BlockResponse, error)
GetBlockByNumber Obtain block information based on block height
func (*ChainAdaptor) GetBlockByRange ¶
func (c *ChainAdaptor) GetBlockByRange(req *account.BlockByRangeRequest) (*account.BlockByRangeResponse, error)
GetBlockByRange Obtain blocks based on their scope
func (*ChainAdaptor) GetBlockHeaderByHash ¶
func (c *ChainAdaptor) GetBlockHeaderByHash(req *account.BlockHeaderHashRequest) (*account.BlockHeaderResponse, error)
GetBlockHeaderByHash Obtain block header information based on block hash
func (*ChainAdaptor) GetBlockHeaderByNumber ¶
func (c *ChainAdaptor) GetBlockHeaderByNumber(req *account.BlockHeaderNumberRequest) (*account.BlockHeaderResponse, error)
GetBlockHeaderByNumber Obtain block header information based on block height
func (*ChainAdaptor) GetExtraData ¶
func (c *ChainAdaptor) GetExtraData(req *account.ExtraDataRequest) (*account.ExtraDataResponse, error)
GetExtraData Obtain additional data
func (*ChainAdaptor) GetFee ¶
func (c *ChainAdaptor) GetFee(req *account.FeeRequest) (*account.FeeResponse, error)
GetFee Obtain transaction fees
func (*ChainAdaptor) GetSupportChains ¶
func (c *ChainAdaptor) GetSupportChains(req *account.SupportChainsRequest) (*account.SupportChainsResponse, error)
GetSupportChains Return whether the chain is supported
func (*ChainAdaptor) GetTxByAddress ¶
func (c *ChainAdaptor) GetTxByAddress(req *account.TxAddressRequest) (*account.TxAddressResponse, error)
GetTxByAddress Obtain transactions based on the address
func (*ChainAdaptor) GetTxByHash ¶
func (c *ChainAdaptor) GetTxByHash(req *account.TxHashRequest) (*account.TxHashResponse, error)
GetTxByHash Obtain transactions based on transaction hash
func (*ChainAdaptor) SendTx ¶
func (c *ChainAdaptor) SendTx(req *account.SendTxRequest) (*account.SendTxResponse, error)
SendTx Send transaction
func (*ChainAdaptor) ValidAddress ¶
func (c *ChainAdaptor) ValidAddress(req *account.ValidAddressRequest) (*account.ValidAddressResponse, error)
ValidAddress verify address
func (*ChainAdaptor) VerifySignedTransaction ¶
func (c *ChainAdaptor) VerifySignedTransaction(req *account.VerifyTransactionRequest) (*account.VerifyTransactionResponse, error)
VerifySignedTransaction verify signature
type ChainParameters ¶
type FreeAssetNetUsageV2 ¶
type OwnerPermission ¶
type TRC20BalanceResponse ¶
type TRC20BalanceResponse struct { Data []struct { OwnerPermission OwnerPermission `json:"owner_permission"` AccountResource AccountResource `json:"account_resource"` ActivePermission AccountResource `json:"active_permission"` Address string `json:"address"` CreateTime int64 `json:"create_time"` LatestOprationTime int64 `json:"latest_opration_time"` FreeAssetNetUsageV2 FreeAssetNetUsageV2 `json:"free_asset_net_usageV2"` FreeNetUsage int `json:"free_net_usage"` AssetV2 AssetV2 `json:"assetV2"` FrozenV2 FrozenV2 `json:"frozenV2"` Balance int64 `json:"balance"` TRC20 []map[string]string `json:"trc20"` LatestConsumeFreeTime int64 `json:"latest_consume_free_time"` NetWindowSize int `json:"net_window_size"` NetWindowOptimized bool `json:"net_window_optimized"` } `json:"data"` Success bool `json:"success"` Meta struct { At int64 `json:"at"` PageSize int `json:"page_size"` } `json:"meta"` }
type Transaction ¶
type TronClient ¶
type TronClient struct {
// contains filtered or unexported fields
}
TronClient Define a Tron RPC client
func DialTronClient ¶
func DialTronClient(rpcURL, rpcUser, rpcPass string) *TronClient
DialTronClient Initialize and return a TronClient instance
func (*TronClient) BroadcastTransaction ¶
func (client *TronClient) BroadcastTransaction(raw *SendTxReq) (*BroadcastReturns, error)
BroadcastTransaction Broadcast trading
func (*TronClient) CreateTRC20Transaction ¶
func (client *TronClient) CreateTRC20Transaction(from, to, contractAddress string, amount int64) (*UnSignTransaction, error)
CreateTRC20Transaction Create TRC20 token transaction to be signed
func (*TronClient) CreateTRXTransaction ¶
func (client *TronClient) CreateTRXTransaction(from, to string, amount int64) (*UnSignTransaction, error)
CreateTRXTransaction Create TRX transaction to be signed
func (*TronClient) GetAccount ¶
func (client *TronClient) GetAccount(address string) (*Account, error)
GetAccount Get account information
func (*TronClient) GetBlockByHash ¶
func (client *TronClient) GetBlockByHash(blockHash string) (*Block, error)
GetBlockByHash Obtain block information based on block hash
func (*TronClient) GetBlockByNumber ¶
func (client *TronClient) GetBlockByNumber(blockNumber int64) (*Block, error)
GetBlockByNumber Obtain block information based on block number
func (*TronClient) GetChainParameters ¶
func (client *TronClient) GetChainParameters() (*ChainParameters, error)
GetChainParameters Get chain parameters
func (*TronClient) GetTRC20Balance ¶
func (client *TronClient) GetTRC20Balance(address, contractAddress string) (string, error)
GetTRC20Balance Query the TRC20 token balance at the specified address
func (*TronClient) GetTransactionByID ¶
func (client *TronClient) GetTransactionByID(txHash string) (*Transaction, error)
GetTransactionByID Obtain transaction information based on transaction hash
func (*TronClient) GetTxByAddress ¶
func (client *TronClient) GetTxByAddress(address string) (interface{}, error)
GetTxByAddress Obtain transaction list based on address
func (*TronClient) JsonRpc ¶
func (client *TronClient) JsonRpc(method string, params interface{}, result interface{}) error
JsonRpc Call JSON-RPC
func (*TronClient) Solidity ¶
func (client *TronClient) Solidity(method string, params interface{}, result interface{}) error
Solidity Call Solidity
func (*TronClient) Wallet ¶
func (client *TronClient) Wallet(method string, params interface{}, result interface{}) error
Wallet Call Wallet
type TronData ¶
type TronData struct {
TronDataCli *oklink.ChainExplorerAdaptor
}
func NewTronDataClient ¶
func (*TronData) GetEstimateGasFee ¶
func (td *TronData) GetEstimateGasFee() (*gas_fee.GasEstimateFeeResponse, error)
GetEstimateGasFee Obtain estimated transaction fees
func (*TronData) GetTxByAddress ¶
func (td *TronData) GetTxByAddress(page, pagesize uint64, address string, action account.ActionType) (*account.TransactionResponse[account.AccountTxResponse], error)
GetTxByAddress Transaction for obtaining address
type TxStructure ¶
type UnSignTransaction ¶
type UnSignTrc20Transaction ¶
type UnSignTrc20Transaction struct { Result struct { Result bool `json:"result"` } `json:"result"` Transaction UnSignTransaction `json:"transaction"` }