chains

package
v0.0.1-gowrapper-dev Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompileTronTransaction

func CompileTronTransaction(inputData []byte, signatures [][]byte, publicKeys [][]byte) ([]byte, error)

CompileTronTransaction compiles the transaction with signatures

func CreateAndSignTronTransaction

func CreateAndSignTronTransaction(input *tron.SigningInput, privateKey []byte) ([]byte, error)

CreateAndSignTronTransaction creates and signs a transaction

func DecodeBase58

func DecodeBase58(data string) ([]byte, error)

DecodeBase58 decodes a base58 string

func DecodeBase64

func DecodeBase64(data string) ([]byte, error)

DecodeBase64 decodes a base64 string

func EncodeBase58

func EncodeBase58(data []byte) string

EncodeBase58 encodes data to base58

func EncodeBase64

func EncodeBase64(data []byte) string

EncodeBase64 encodes data to base64

func FormatTRC20Amount

func FormatTRC20Amount(amount *big.Int) []byte

FormatTRC20Amount formats a uint256 amount for TRC20 transfers

func GetTronPreimageHash

func GetTronPreimageHash(preimageData []byte) ([]byte, []byte, error)

GetTronPreimageHash gets the preimage and hash for external signing

func GetTronTransactionHash

func GetTronTransactionHash(encodedTx []byte) (string, error)

GetTronTransactionHash calculates Tron transaction hash using SHA256

func ParseTRC20Amount

func ParseTRC20Amount(data []byte) *big.Int

ParseTRC20Amount parses a uint256 amount from TRC20 transfer data

func SignTronPreimage

func SignTronPreimage(preimage []byte, privateKey []byte) ([]byte, error)

SignTronPreimage signs the preimage with the private key

func SunToTRX

func SunToTRX(sun int64) float64

SunToTRX converts sun to TRX

func TRXToSun

func TRXToSun(trx float64) int64

TRXToSun converts TRX to sun (smallest unit)

func ValidateTronTransactionInput

func ValidateTronTransactionInput(input interface{}) error

ValidateTronTransactionInput validates the transaction input

Types

type TronChain

type TronChain struct {
	chain_abstraction.BaseChain
}

TronChain implements the Chain interface for Tron blockchain

func NewTronChain

func NewTronChain() *TronChain

NewTronChain creates a new Tron chain instance

func (*TronChain) BuildSigningInput

func (c *TronChain) BuildSigningInput(
	ownerAddress string,
	transfer *tron.TransferContract,
	tokenTransfer *tron.TransferTRC20Contract,
) (*tron.SigningInput, error)

BuildSigningInput builds a signing input for the given transaction

func (*TronChain) BuildSigningInputFromTokenTransferRequest

func (c *TronChain) BuildSigningInputFromTokenTransferRequest(req *TronTokenTransferRequest) (*tron.SigningInput, error)

BuildSigningInputFromTokenTransferRequest builds a signing input from a TRC20 token transfer request

func (*TronChain) BuildSigningInputFromTransferRequest

func (c *TronChain) BuildSigningInputFromTransferRequest(req *TronTransferRequest) (*tron.SigningInput, error)

BuildSigningInputFromTransferRequest builds a signing input from a TRX transfer request

func (*TronChain) BuildTokenTransferTransaction

func (c *TronChain) BuildTokenTransferTransaction(
	contractAddress string,
	toAddress string,
	amount []byte,
) *tron.TransferTRC20Contract

BuildTokenTransferTransaction builds a TRC20 token transfer transaction

func (*TronChain) BuildTransferTransaction

func (c *TronChain) BuildTransferTransaction(
	toAddress string,
	amount int64,
	memo string,
) *tron.TransferContract

BuildTransferTransaction builds a TRX transfer transaction

func (*TronChain) CompileTransaction

func (c *TronChain) CompileTransaction(input *chain_abstraction.TransactionInput, signatures [][]byte, publicKeys [][]byte) ([]byte, error)

CompileTransaction compiles the transaction with signatures

func (*TronChain) ConvertAmount

func (c *TronChain) ConvertAmount(amount float64, toSun bool) int64

ConvertAmount converts between TRX and sun (smallest unit)

func (*TronChain) CreateAndSignTransaction

func (c *TronChain) CreateAndSignTransaction(input interface{}, privateKey []byte) ([]byte, error)

CreateAndSignTransaction creates and signs a transaction

func (*TronChain) GetPreimageHash

func (c *TronChain) GetPreimageHash(input *chain_abstraction.TransactionInput) ([]byte, []byte, error)

GetPreimageHash gets the preimage and hash for external signing

func (*TronChain) GetTransactionHash

func (c *TronChain) GetTransactionHash(encodedTx []byte) (string, error)

GetTransactionHash calculates the transaction hash for Tron transactions

func (*TronChain) PrepareTransaction

func (c *TronChain) PrepareTransaction(input interface{}) (*chain_abstraction.TransactionInput, error)

PrepareTransaction prepares a transaction for external signing

func (*TronChain) Sign

func (c *TronChain) Sign(preimage []byte, privateKey []byte) ([]byte, error)

Sign signs the preimage with the private key

func (*TronChain) ValidateTransactionInput

func (c *TronChain) ValidateTransactionInput(input interface{}) error

ValidateTransactionInput validates the transaction input

type TronTokenTransferRequest

type TronTokenTransferRequest struct {
	FromAddress     string  `json:"from_address"`
	ToAddress       string  `json:"to_address"`
	ContractAddress string  `json:"contract_address"`
	Amount          float64 `json:"amount"`   // Amount in token units
	Decimals        int     `json:"decimals"` // Token decimals
}

TronTokenTransferRequest represents a TRC20 token transfer request

type TronTransferRequest

type TronTransferRequest struct {
	FromAddress string  `json:"from_address"`
	ToAddress   string  `json:"to_address"`
	Amount      float64 `json:"amount"` // Amount in TRX
	Memo        string  `json:"memo,omitempty"`
}

TronTransferRequest represents a TRX transfer request

Jump to

Keyboard shortcuts

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