tron

package
v0.0.0-...-3f3ae68 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: MIT Imports: 26 Imported by: 0

README

address (create, getBalance)

TODO {energy or bandwidth with freezes}

TODO {gas,gasLimit}

token (balance, transfer,fecthTransaction)

TODO {test}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeAddressToPublicKey

func DecodeAddressToPublicKey(address string) (string, error)

func DecodeCheck

func DecodeCheck(input string) ([]byte, error)

func EncodePublicKeyToAddress

func EncodePublicKeyToAddress(publicKey string) (string, error)

func IsValidAddress

func IsValidAddress(address string) bool

IsValidAddress Check if address is 34 hexadecimal characters

func SignTransaction

func SignTransaction(transaction *core.Transaction, key *ecdsa.PrivateKey) ([]byte, error)

SignTransaction 签名交易

Types

type Account

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

func AccountWithPrivateKey

func AccountWithPrivateKey(privatekey string) (*Account, error)

AccountWithPrivateKey creates a new account with a given private key

func NewAccountWithMnemonic

func NewAccountWithMnemonic(mnemonic string) (*Account, error)

NewAccountWithMnemonic creates a new account with a given mnemonic

func (Account) Address

func (a Account) Address() string

func (Account) PrivateKey

func (a Account) PrivateKey() ([]byte, error)

func (Account) PrivateKeyHex

func (a Account) PrivateKeyHex() (string, error)

func (Account) PublicKey

func (a Account) PublicKey() []byte

func (Account) PublicKeyHex

func (a Account) PublicKeyHex() string

func (Account) Sign

func (a Account) Sign(message []byte, password string) ([]byte, error)

func (Account) SignHex

func (a Account) SignHex(messageHex string, password string) (*base.OptionalString, error)

type Chain

type Chain struct {
	RpcUrl string
}

func NewChainWithRpc

func NewChainWithRpc(rpcUrl string) *Chain

func (*Chain) BalanceOfAccount

func (c *Chain) BalanceOfAccount(account base.Account) (*base.Balance, error)

func (*Chain) BalanceOfAddress

func (c *Chain) BalanceOfAddress(address string) (*base.Balance, error)

func (*Chain) BalanceOfPublicKey deprecated

func (c *Chain) BalanceOfPublicKey(publicKey string) (*base.Balance, error)

Deprecated: This method is no longer supported. Please use NewMethod() instead

func (*Chain) BatchFetchTransactionStatus

func (c *Chain) BatchFetchTransactionStatus(hashListString string) string

func (*Chain) EstimateTransactionFee

func (c *Chain) EstimateTransactionFee(transaction base.Transaction) (fee *base.OptionalString, err error)

func (*Chain) EstimateTransactionFeeUsePublicKey

func (c *Chain) EstimateTransactionFeeUsePublicKey(transaction base.Transaction, pubkey string) (fee *base.OptionalString, err error)

func (*Chain) FetchTransactionDetail

func (c *Chain) FetchTransactionDetail(hash string) (*base.TransactionDetail, error)

func (*Chain) FetchTransactionStatus

func (c *Chain) FetchTransactionStatus(hash string) base.TransactionStatus

func (*Chain) MainToken

func (c *Chain) MainToken() base.Token

func (*Chain) SendRawTransaction

func (c *Chain) SendRawTransaction(signedTx string) (string, error)

func (*Chain) SendSignedTransaction

func (c *Chain) SendSignedTransaction(signedTxn base.SignedTransaction) (*base.OptionalString, error)

type IChain

type IChain interface {
	base.Chain
	SubmitTransactionData(account base.Account, to string, data []byte, value string) (string, error)
	GetEthChain() (*TronChain, error)
}

type Token

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

func NewToken

func NewToken(chain *Chain) *Token

func (*Token) BalanceOfAccount

func (t *Token) BalanceOfAccount(account base.Account) (*base.Balance, error)

func (*Token) BalanceOfAddress

func (t *Token) BalanceOfAddress(address string) (*base.Balance, error)

func (*Token) BalanceOfPublicKey

func (t *Token) BalanceOfPublicKey(publicKey string) (*base.Balance, error)

func (*Token) Chain

func (t *Token) Chain() base.Chain

func (*Token) TokenInfo

func (t *Token) TokenInfo() (*base.TokenInfo, error)

Warning: Main token does not support

type TokenProtocol

type TokenProtocol interface {
	base.Token
}

type TronChain

type TronChain struct {
	RemoteRpcClient *client.GrpcClient
	RpcClient       *client.GrpcClient
	// contains filtered or unexported fields
}

func NewTronChain

func NewTronChain() *TronChain

func (*TronChain) Balance

func (e *TronChain) Balance(address string) (string, error)

@title 主网代币余额查询 @description 返回主网代币余额,decimal为代币精度 @param (walletAddress) (string) 合约名称,钱包地址 @return (string,error) 代币余额,错误信息

func (*TronChain) BroadcastTransaction

func (e *TronChain) BroadcastTransaction(transaction *core.Transaction) error

func (*TronChain) Close

func (e *TronChain) Close()

func (*TronChain) ConnectRemote

func (e *TronChain) ConnectRemote(rpcUrl string) error

func (*TronChain) CreateRemote

func (e *TronChain) CreateRemote(rpcUrl string) (chain *TronChain, err error)

func (*TronChain) CreateRemoteWithTimeout

func (e *TronChain) CreateRemoteWithTimeout(rpcUrl string, timeout int64) (chain *TronChain, err error)

@param timeout time unit millsecond. 0 means use chain's default: 60000ms.

func (*TronChain) FreezeBalance

func (e *TronChain) FreezeBalance(from, delegateTo string, ownerKey *ecdsa.PrivateKey, resource core.ResourceCode, frozenBalance int64) (*api.TransactionExtention, error)

func (*TronChain) GetTrc10Balance

func (e *TronChain) GetTrc10Balance(addr, assetId string) (int64, error)

func (*TronChain) GetTrc20Balance

func (e *TronChain) GetTrc20Balance(addr, contractAddress string) (*big.Int, error)

func (*TronChain) GetTrxBalance

func (e *TronChain) GetTrxBalance(addr string) (*core.Account, error)

func (*TronChain) GetTrxTransaction

func (e *TronChain) GetTrxTransaction(txhash string) (*core.TransactionInfo, error)

func (*TronChain) LatestBlockNumber

func (e *TronChain) LatestBlockNumber() (string, error)

获取最新区块高度

func (*TronChain) Transfer

func (e *TronChain) Transfer(from, to string, amount int64) (*api.TransactionExtention, error)

func (*TronChain) TransferTrc10

func (e *TronChain) TransferTrc10(from, to, assetId string, amount int64) (*api.TransactionExtention, error)

func (*TronChain) TransferTrc20

func (e *TronChain) TransferTrc20(from, to, contract string, amount *big.Int, feeLimit int64) (*api.TransactionExtention, error)

func (*TronChain) UnFreezeBalance

func (e *TronChain) UnFreezeBalance(from, delegateTo string, ownerKey *ecdsa.PrivateKey, resource core.ResourceCode) (*api.TransactionExtention, error)

type Util

type Util struct {
}

func NewUtil

func NewUtil() *Util

func (*Util) DecodeAddressToPublicKey

func (u *Util) DecodeAddressToPublicKey(address string) (string, error)

func (*Util) EncodePublicKeyToAddress

func (u *Util) EncodePublicKeyToAddress(publicKey string) (string, error)

func (*Util) IsValidAddress

func (u *Util) IsValidAddress(address string) bool

Check if address is 40 hexadecimal characters

Jump to

Keyboard shortcuts

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