trc20

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package trc20 packs TRC-20 (TRON's ERC-20 equivalent) calldata for contract-call transactions on the TRON network. TRC-20 uses the same solidity ABI as ERC-20; the only difference is the address format (base58 with a 0x41 version byte instead of 0x00 hex).

The two helpers in this file (ConvertToBytes / ConvertToHex) are duplicated from signing/tron/utils.go so this package doesn't have to depend on the parent (which itself calls into trc20 for its PackPayloadForTrc20 helper — importing back would create a cycle). Behaviour is identical.

Index

Constants

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

Variables

This section is empty.

Functions

func ConvertToBytes

func ConvertToBytes(address string) []byte

ConvertToBytes base58-decodes a TRON T-address into raw bytes, prefixed with the base58 version byte. Returns nil on decode error.

func ConvertToHex

func ConvertToHex(address string) string

ConvertToHex takes a base58 T-address and returns its hex form (with the leading 0x41 version byte). Used to build EVM-style calldata parameters where TRC-20 contracts speak in hex-address terms. Returns "" for invalid input; "0" when the decoded bytes are empty (defensive fallback to keep downstream Pack calls from panicking on an empty string).

func PackPayloadForTrc20

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

Types

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 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