solana

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: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DevnetRPCEndpoint  = rpc.DevnetRPCEndpoint
	TestnetRPCEndpoint = rpc.TestnetRPCEndpoint
	MainnetRPCEndpoint = rpc.MainnetRPCEndpoint
)

Variables

This section is empty.

Functions

func DecodeAddressToPublicKey

func DecodeAddressToPublicKey(address string) (string, error)

func EncodePublicKeyToAddress

func EncodePublicKeyToAddress(publicKey string) (string, error)

func IsValidAddress

func IsValidAddress(address string) bool

Types

type Account

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

func AccountWithPrivateKey

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

rename for support android. Android cant support both NewAccountWithMnemonic(string) and NewAccountWithPrivateKey(string)

func AsSolanaAccount

func AsSolanaAccount(account base.Account) *Account

func NewAccountWithMnemonic

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

func (*Account) Address

func (a *Account) Address() string

func (*Account) DecodeAddressToPublicKey

func (a *Account) DecodeAddressToPublicKey(address string) (string, error)

@return publicKey that will start with 0x.

func (*Account) EncodePublicKeyToAddress

func (a *Account) EncodePublicKeyToAddress(publicKey string) (string, error)

@param publicKey can start with 0x or not.

func (*Account) IsValidAddress

func (a *Account) IsValidAddress(address string) bool

func (*Account) PrivateKey

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

@return privateKey data

func (*Account) PrivateKeyHex

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

@return privateKey string that will start with 0x.

func (*Account) PublicKey

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

@return publicKey data

func (*Account) PublicKeyHex

func (a *Account) PublicKeyHex() string

@return publicKey string that will start with 0x.

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 {
	*Util
	RpcUrl string
	// contains filtered or unexported fields
}

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

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

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)

Fetch transaction details through transaction hash

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)

Send the raw transaction on-chain @return the hex hash string

func (*Chain) SendSignedTransaction

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

type SignedTransaction

type SignedTransaction struct {
	Transaction types.Transaction
}

func AsSignedTransaction

func AsSignedTransaction(txn base.SignedTransaction) *SignedTransaction

func (*SignedTransaction) HexString

func (txn *SignedTransaction) HexString() (res *base.OptionalString, err 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) BuildTransfer

func (t *Token) BuildTransfer(sender, receiver, amount string) (txn base.Transaction, err error)

func (*Token) BuildTransferAll

func (t *Token) BuildTransferAll(sender, receiver string) (txn base.Transaction, err error)

func (*Token) BuildTransferTx

func (t *Token) BuildTransferTx(privateKey, receiverAddress, amount string) (*base.OptionalString, error)

func (*Token) BuildTransferTxWithAccount

func (t *Token) BuildTransferTxWithAccount(account *Account, receiverAddress, amount string) (*base.OptionalString, error)

func (*Token) CanTransferAll

func (t *Token) CanTransferAll() bool

func (*Token) Chain

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

func (*Token) EstimateFees

func (t *Token) EstimateFees(receiverAddress, amount string) (*base.OptionalString, error)

func (*Token) TokenInfo

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

type Transaction

type Transaction struct {
	Message types.Message
}

func (*Transaction) SignWithAccount

func (t *Transaction) SignWithAccount(account base.Account) (signedTxn *base.OptionalString, err error)

func (*Transaction) SignedTransactionWithAccount

func (t *Transaction) SignedTransactionWithAccount(account base.Account) (signedTxn base.SignedTransaction, err error)

type Util

type Util struct {
}

func NewUtil

func NewUtil() *Util

func (*Util) DecodeAddressToPublicKey

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

Warning: eth cannot support decode address to public key

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