tron

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const ABITRC20 = `` /* 4470-byte string literal not displayed */

Variables

This section is empty.

Functions

func ConvertFromHex

func ConvertFromHex(hexAddress string) string

func ConvertToBytes

func ConvertToBytes(address string) []byte

func ConvertToHex

func ConvertToHex(address string) string

func Int64ToBytes

func Int64ToBytes(n int64) []byte

func NewAccountFromMnemonic

func NewAccountFromMnemonic(mnemonic, path string) (signing.AccountHandler, error)

func NewAccountFromPrivateKey

func NewAccountFromPrivateKey(privateKey []byte) (signing.AccountHandler, error)

func NewAccountFromPrivateKeyHex

func NewAccountFromPrivateKeyHex(privateKey string) (signing.AccountHandler, error)

func PackPayloadForTrc20

func PackPayloadForTrc20(function string, params []byte) (string, error)

func PublicKey2Address

func PublicKey2Address(publicKey []byte) string

func ValidAddress

func ValidAddress(address string) bool

Types

type Account

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

func (*Account) Address

func (a *Account) Address() string

func (*Account) PrivateKey

func (a *Account) PrivateKey() []byte

func (*Account) PrivateKeyHex

func (a *Account) PrivateKeyHex() string

func (*Account) PublicKey

func (a *Account) PublicKey() []byte

func (*Account) PublicKeyHex

func (a *Account) PublicKeyHex() string

func (*Account) SignData

func (a *Account) SignData(data []byte) ([]byte, error)

func (*Account) VerifySignData

func (a *Account) VerifySignData(data, sig []byte) bool

func (*Account) Wipe added in v0.9.0

func (a *Account) Wipe()

type CallTrc20In

type CallTrc20In struct {
	Address   string `json:"address,omitempty"`
	Owner     string `json:"owner,omitempty"`
	Spender   string `json:"spender,omitempty"`
	From      string `json:"from,omitempty"`
	To        string `json:"to,omitempty"`
	Recipient string `json:"recipient,omitempty"`
	Amount    string `json:"amount,omitempty"`
}

for call contract

type ContractValue

type ContractValue struct {
	OwnerAddress    string `json:"owner_address,omitempty"`
	ToAddress       string `json:"to_address,omitempty"`
	Data            string `json:"data,omitempty"`
	ContractAddress string `json:"contract_address,omitempty"`
	Amount          int64  `json:"amount,omitempty"`
	CallValue       int64  `json:"call_value,omitempty"`
}

types

type FreeGas

type FreeGas struct {
	FreeNetUsed  string `json:"freeNetUsed"`
	FreeNetLimit string `json:"freeNetLimit"`
}

types

type Ingredient

type Ingredient struct {
	TxType          string `json:"txType" validate:"required,oneof=0 1 2 3 4 5 6"`
	ContractAddress string `json:"contractAddress" validate:"required,trx_addr"`
	Sender          string `json:"sender" validate:"required,trx_addr"`
	Recipient       string `json:"recipient,omitempty" validate:"omitempty,trx_addr"`
	Amount          string `json:"amount,omitempty" validate:"omitempty,bigint_gt0"`
	Payload         string `json:"payload,omitempty" validate:"omitempty,hex_str"`
	FeeLimit        string `json:"feeLimit" validate:"required,u64"`
	//IsRecipientActivated string `json:"isRecipientActivated,omitempty" validate:"omitempty,bool_str"`
	RefBlockHash      string `json:"refBlockHash" validate:"required,hex_str"`
	RefBlockNumber    string `json:"refBlockNumber" validate:"required,u64_gt0"`
	RefBlockTimestamp string `json:"refTimestamp" validate:"required,u64_gt0"`
}

types

type NativeTx

type NativeTx struct {
	Signature []string `json:"signature,omitempty"`
	ID        string   `json:"txID,omitempty"`
	RawData   *TxRaw   `json:"raw_data,omitempty"`
	Ret       []TxRet  `json:"ret,omitempty"`
}

types

type TrxContract

type TrxContract struct {
	Type      string `json:"type"`
	Parameter struct {
		Value   ContractValue `json:"value"`
		TypeUrl string        `json:"type_url"`
	} `json:"parameter"`
}

types

type TxBuilder

type TxBuilder struct {
	*Ingredient
	// contains filtered or unexported fields
}

types

func NewTxBuilder

func NewTxBuilder(ti *Ingredient) *TxBuilder

func (*TxBuilder) Build

func (tx *TxBuilder) Build() error

func (*TxBuilder) ConcatSignature

func (tx *TxBuilder) ConcatSignature(signature string, isDerFormat bool) (string, error)

func (*TxBuilder) GetSigHash

func (tx *TxBuilder) GetSigHash() []string

func (*TxBuilder) GetTxHash

func (tx *TxBuilder) GetTxHash() string

func (*TxBuilder) GetUnsignedHex

func (tx *TxBuilder) GetUnsignedHex() string

func (*TxBuilder) SetSigHash

func (tx *TxBuilder) SetSigHash(sigHash []string)

func (*TxBuilder) SetUnsignedHex

func (tx *TxBuilder) SetUnsignedHex(unsignedHex string)

func (*TxBuilder) Sign

func (tx *TxBuilder) Sign(privateKey []byte) (string, error)

type TxRaw

type TxRaw struct {
	Contracts     []*TrxContract `json:"contract"`
	RefBlockBytes string         `json:"ref_block_bytes,omitempty"`
	RefBlockHash  string         `json:"ref_block_hash,omitempty"`
	Timestamp     int64          `json:"timestamp"`
	Expiration    int64          `json:"expiration,omitempty"`
	FeeLimit      int64          `json:"fee_limit,omitempty"`
}

types

type TxRet

type TxRet struct {
	ContractRet string `json:"contractRet"`
}

types

type UnpackTrc20

type UnpackTrc20 struct {
	Function string
	CallTrc20In
}

for call contract

func UnpackPayloadForTrc20

func UnpackPayloadForTrc20(payload string) (*UnpackTrc20, error)

Jump to

Keyboard shortcuts

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