trx

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const ERC20_FEE_LIMIT = 20000000

Variables

View Source
var TrxExtensions = server.Extensions{
	AddressFromString: func(address string) (common.Address, error) {
		addrB58, err := base58.Decode(address, base58.BitcoinAlphabet)
		if err != nil {
			return common.Address{}, err
		}
		addrB58 = addrB58[:len(addrB58)-4]
		return common.BytesToAddress(addrB58[len(addrB58)-20:]), nil
	},
	AddressToString: func(address common.Address) string {
		addressTron := make([]byte, 0)
		addressTron = append(addressTron, trx.TronBytePrefix)
		addressTron = append(addressTron, address.Bytes()...)
		return trx.Address(addressTron).String()
	},
}

Functions

This section is empty.

Types

type BroadcastTransactionRequest added in v0.0.8

type BroadcastTransactionRequest struct {
	Visible   bool            `json:"visible"`
	RawData   json.RawMessage `json:"raw_data"`
	Signature []string        `json:"signature"`
}

type BroadcastTransactionResponse added in v0.0.8

type BroadcastTransactionResponse struct {
	Result  bool   `json:"result"`
	Code    string `json:"code"`
	Message string `json:"message"`
}

type ChainParameters added in v0.0.10

type ChainParameters struct {
	BandwidthPrice *big.Int
	EnergyPrice    *big.Int
}

type CreateTransactionRequest added in v0.0.8

type CreateTransactionRequest struct {
	OwnerAddress string `json:"owner_address"`
	ToAddress    string `json:"to_address"`
	Amount       uint64 `json:"amount"`
	Visible      bool   `json:"visible"`
}

type CreateTransactionResponse added in v0.0.8

type CreateTransactionResponse struct {
	TxId       string          `json:"txID"`
	RawData    json.RawMessage `json:"raw_data"`
	RawDataHex string          `json:"raw_data_hex"`
	Error      string          `json:"error"`
}

type RawTxData added in v0.0.10

type RawTxData struct {
	Contract      json.RawMessage `json:"contract,omitempty"`
	RefBlockBytes json.RawMessage `json:"ref_block_bytes,omitempty"`
	RefBlockHash  json.RawMessage `json:"ref_block_hash,omitempty"`
	Expiration    json.RawMessage `json:"expiration,omitempty"`
	FeeLimit      uint64          `json:"fee_limit,omitempty"`
	Timestamp     json.RawMessage `json:"timestamp,omitempty"`
}

type TriggerConstantContractResponse added in v0.0.10

type TriggerConstantContractResponse struct {
	Result struct {
		Result  bool   `json:"result"`
		Code    string `json:"code"`
		Message string `json:"message"`
	} `json:"result"`
	EnergyUsed  uint64 `json:"energy_used"`
	Transaction struct {
		TxId       string    `json:"txID"`
		RawData    RawTxData `json:"raw_data"`
		RawDataHex string    `json:"raw_data_hex"`
	} `json:"transaction"`
}

type TriggerContractRequest added in v0.0.10

type TriggerContractRequest struct {
	OwnerAddress    string `json:"owner_address"`
	ContractAddress string `json:"contract_address"`
	FeeLimit        uint64 `json:"fee_limit"`
	CallValue       uint64 `json:"call_value"`
	Data            string `json:"data"`
	Visible         bool   `json:"visible"`
}

type TriggerSmartContractResponse added in v0.0.8

type TriggerSmartContractResponse struct {
	Result struct {
		Result  bool   `json:"result"`
		Code    string `json:"code"`
		Message string `json:"message"`
	} `json:"result"`
	Transaction struct {
		TxId       string          `json:"txID"`
		RawData    json.RawMessage `json:"raw_data"`
		RawDataHex string          `json:"raw_data_hex"`
	} `json:"transaction"`
}

type TrxAgent added in v0.0.6

type TrxAgent struct {
	server.EthServer
	// contains filtered or unexported fields
}

func InitServer

func InitServer(ctx context.Context, config *agent.ChainConfig) *TrxAgent

func (*TrxAgent) CreateTransfer added in v0.0.8

func (*TrxAgent) GetFeePrices added in v0.0.10

func (srv *TrxAgent) GetFeePrices(ctx context.Context) (feePrices, error)

get energy and bandwidth prices in suns

func (*TrxAgent) Send added in v0.0.8

type TrxApiClient added in v0.0.8

type TrxApiClient struct {
	BaseUrl string
	Client  *http.Client
	Log     *slog.Logger
}

func NewTrxApiClient added in v0.0.8

func NewTrxApiClient(baseUrl string, log *slog.Logger) *TrxApiClient

func (*TrxApiClient) BroadcastTransaction added in v0.0.8

func (*TrxApiClient) CreateTransaction added in v0.0.8

func (*TrxApiClient) DoPost added in v0.0.8

func (c *TrxApiClient) DoPost(ctx context.Context, path string, req any, res any) error

func (*TrxApiClient) GetChainParameters added in v0.0.10

func (c *TrxApiClient) GetChainParameters(ctx context.Context) (ChainParameters, error)

func (*TrxApiClient) TriggerConstantContract added in v0.0.10

func (*TrxApiClient) TriggerSmartContract added in v0.0.8

Jump to

Keyboard shortcuts

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