tronhttpClient

package module
v0.0.0-...-3bc0096 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2020 License: GPL-3.0 Imports: 6 Imported by: 0

README

TRONHttpClient

A Golang client to use the TRON Http API.

Documentation

https://developers.tron.network/reference#note

https://tronprotocol.github.io/documentation-en/api/http/

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	Address               string          `json:"address"`
	Balance               int             `json:"balance"`
	Frozen                []Frozen        `json:"frozen"`
	CreateTime            int             `json:"create_time"`
	LatestOperationTime   int             `json:"latest_opration_time"`
	FreeNetUsage          int             `json:"free_net_usage"`
	LatestConsumeFreeTime int             `json:"latest_consume_free_time"`
	AccountResource       AccountResource `json:"account_resource"`
	OwnerPermission       Permission      `json:"owner_permission"`
	ActivePermission      []Permission    `json:"active_permission"`
	AssetV2               []Asset         `json:"assetV2"`
	FreeAssetNetUsageV2   []Asset         `json:"free_asset_net_usageV2"`
}

type AccountResource

type AccountResource struct {
	FrozenBalanceForEnergy     Frozen `json:"frozen_balance_for_energy"`
	LatestConsumeTimeForEnergy int    `json:"latest_consume_time_for_energy"`
}

type Address

type Address struct {
	PrivateKey string `json:"privateKey"`
	Address    string `json:"address"`
	HexAddress string `json:"hexAddress"`
}

type AddressWithoutPrivKey

type AddressWithoutPrivKey struct {
	Base58CheckAddress string `json:"base58checkAddress"`
	Value              string `json:"value"`
}

type Asset

type Asset struct {
	Key   string `json:"key"`
	Value int    `json:"value"`
}

type Client

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

func NewClient

func NewClient(network string) *Client

NewClient returns a new instance of Client

func (*Client) BroadcastHex

func (c *Client) BroadcastHex(txHex string) (*Transaction, error)

BroadcastHex Broadcast the protobuf encoded transaction hex string after sign

func (*Client) BroadcastTx

func (c *Client) BroadcastTx(tx *Transaction) (*Transaction, error)

BroadcastTx Broadcast the signed transaction

func (*Client) CreateAccount

func (c *Client) CreateAccount(ownerAddr, accountAddr string, visible bool, permissionID int) (*Transaction, error)

CreateAccount Create an account. Uses an already activated account to create a new account Note: The expiration time of the http api creation transaction is 1 minute,

so to complete the on-chain, you need to complete gettransactionsign and
broadcasttransaction within 1 minute after the creation.

func (*Client) CreateAddress

func (c *Client) CreateAddress(password string) (*AddressWithoutPrivKey, error)

CreateAddress Create address from a specified password string (NOT PRIVATE KEY)

func (*Client) CreateTx

func (c *Client) CreateTx(toAddr, ownerAddr string, amount int) (*Transaction, error)

CreateTx Create a TRX transfer transaction. If toAddr does not exist, then create the account on the blockchain.

func (*Client) EasyTransfer

func (c *Client) EasyTransfer(password, toAddress string, amount int) (*Transaction, error)

EasyTransfer Easily transfer from an address using the password string. Only works with accounts created from createAddress,integrated getransactionsign and broadcasttransaction.

func (*Client) EasyTransferByPrivate

func (c *Client) EasyTransferByPrivate(privateKey, toAddress string, amount int) (*Transaction, error)

EasyTransferByPrivate Easily transfer from an address using the private key.

func (*Client) GenerateAddress

func (c *Client) GenerateAddress() (*Address, error)

GenerateAddress Generates a random private key and address pair. Returns a private key, the corresponding address in hex, and base58.

func (*Client) GetAccount

func (c *Client) GetAccount(address string, visible bool) (*Account, error)

GetAccount Query information about an account,Including balances, freezes, votes and time, etc

func (*Client) GetTxSign

func (c *Client) GetTxSign(tx *Transaction, privKey string) (*Transaction, error)

GetTxSign Sign the transaction, the api has the risk of leaking the private key, please make sure to call the api in a secure environment

func (*Client) ValidateAddress

func (c *Client) ValidateAddress(address string) (bool, error)

ValidateAddress Validates address, returns either true or false.

type Frozen

type Frozen struct {
	FrozenBalance int `json:"frozen_balance"`
	ExpireTime    int `json:"expire_time"`
}

type Key

type Key struct {
	Address string `json:"address"`
	Weight  int    `json:"weight"`
}

type Permission

type Permission struct {
	Id             int    `json:"id"`
	Type           string `json:"type"`
	Operations     string `json:"operations"`
	PermissionName string `json:"permission_name"`
	Threshold      int    `json:"threshold"`
	Keys           []Key  `json:"keys"`
}

type Transaction

type Transaction struct {
	Visible    bool        `json:"visible"`
	TxId       string      `json:"txID"`
	RawData    interface{} `json:"raw_data"`
	RawDataHex string      `json:"raw_data_hex"`
	Signature  []string    `json:"signature"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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