token

package
v1.30.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: MIT Imports: 6 Imported by: 10

Documentation

Index

Constants

View Source
const MaxSigners = 11
View Source
const MintAccountSize = 82
View Source
const MultisigAccountSize = 355
View Source
const TokenAccountSize = 165

Variables

View Source
var (
	ErrInvalidAccountOwner    = errors.New("invalid account owner")
	ErrInvalidAccountDataSize = errors.New("invalid account data size")
)
View Source
var (
	Some = []byte{1, 0, 0, 0}
	None = []byte{0, 0, 0, 0}
)

Functions

func Approve

func Approve(param ApproveParam) types.Instruction

func ApproveChecked

func ApproveChecked(param ApproveCheckedParam) types.Instruction

func Burn

func Burn(param BurnParam) types.Instruction

func BurnChecked

func BurnChecked(param BurnCheckedParam) types.Instruction

func CloseAccount

func CloseAccount(param CloseAccountParam) types.Instruction

Close an account and transfer its all SOL to dest, only account's token balance is zero can be closed.

func FreezeAccount

func FreezeAccount(param FreezeAccountParam) types.Instruction

func InitializeAccount

func InitializeAccount(param InitializeAccountParam) types.Instruction

InitializeAccount init a token account which can receive token

func InitializeAccount2

func InitializeAccount2(param InitializeAccount2Param) types.Instruction

func InitializeAccount3

func InitializeAccount3(param InitializeAccount3Param) types.Instruction

func InitializeMint

func InitializeMint(param InitializeMintParam) types.Instruction

InitializeMint init a mint, if you don't need to freeze, pass the empty pubKey common.PublicKey{}

func InitializeMint2

func InitializeMint2(param InitializeMint2Param) types.Instruction

func InitializeMultisig

func InitializeMultisig(param InitializeMultisigParam) types.Instruction

func InitializeMultisig2

func InitializeMultisig2(param InitializeMultisig2Param) types.Instruction

func MintTo

func MintTo(param MintToParam) types.Instruction

func MintToChecked

func MintToChecked(param MintToCheckedParam) types.Instruction

func Revoke

func Revoke(param RevokeParam) types.Instruction

func SetAuthority

func SetAuthority(param SetAuthorityParam) types.Instruction

func SyncNative

func SyncNative(param SyncNativeParam) types.Instruction

SyncNative will update your wrapped SOL balance

func ThawAccount

func ThawAccount(param ThawAccountParam) types.Instruction

func Transfer

func Transfer(param TransferParam) types.Instruction

func TransferChecked

func TransferChecked(param TransferCheckedParam) types.Instruction

Types

type ApproveCheckedParam

type ApproveCheckedParam struct {
	From     common.PublicKey
	Mint     common.PublicKey
	To       common.PublicKey
	Auth     common.PublicKey
	Signers  []common.PublicKey
	Amount   uint64
	Decimals uint8
}

type ApproveParam

type ApproveParam struct {
	From    common.PublicKey
	To      common.PublicKey
	Auth    common.PublicKey
	Signers []common.PublicKey
	Amount  uint64
}

type AuthorityType

type AuthorityType uint8
const (
	AuthorityTypeMintTokens AuthorityType = iota
	AuthorityTypeFreezeAccount
	AuthorityTypeAccountOwner
	AuthorityTypeCloseAccount
)

type BurnCheckedParam

type BurnCheckedParam struct {
	Account  common.PublicKey
	Auth     common.PublicKey
	Signers  []common.PublicKey
	Mint     common.PublicKey
	Amount   uint64
	Decimals uint8
}

type BurnParam

type BurnParam struct {
	Account common.PublicKey
	Mint    common.PublicKey
	Auth    common.PublicKey
	Signers []common.PublicKey
	Amount  uint64
}

type CloseAccountParam

type CloseAccountParam struct {
	Account common.PublicKey
	Auth    common.PublicKey
	Signers []common.PublicKey
	To      common.PublicKey
}

type FreezeAccountParam

type FreezeAccountParam struct {
	Account common.PublicKey
	Mint    common.PublicKey
	Auth    common.PublicKey
	Signers []common.PublicKey
}

type InitializeAccount2Param

type InitializeAccount2Param struct {
	Account common.PublicKey
	Mint    common.PublicKey
	Owner   common.PublicKey
}

type InitializeAccount3Param

type InitializeAccount3Param struct {
	Account common.PublicKey
	Mint    common.PublicKey
	Owner   common.PublicKey
}

type InitializeAccountParam

type InitializeAccountParam struct {
	Account common.PublicKey
	Mint    common.PublicKey
	Owner   common.PublicKey
}

type InitializeMint2Param

type InitializeMint2Param struct {
	Decimals   uint8
	Mint       common.PublicKey
	MintAuth   common.PublicKey
	FreezeAuth *common.PublicKey
}

type InitializeMintParam

type InitializeMintParam struct {
	Decimals   uint8
	Mint       common.PublicKey
	MintAuth   common.PublicKey
	FreezeAuth *common.PublicKey
}

type InitializeMultisig2Param

type InitializeMultisig2Param struct {
	Account     common.PublicKey
	Signers     []common.PublicKey
	MinRequired uint8
}

type InitializeMultisigParam

type InitializeMultisigParam struct {
	Account     common.PublicKey
	Signers     []common.PublicKey
	MinRequired uint8
}

type Instruction

type Instruction uint8
const (
	InstructionInitializeMint Instruction = iota
	InstructionInitializeAccount
	InstructionInitializeMultisig
	InstructionTransfer
	InstructionApprove
	InstructionRevoke
	InstructionSetAuthority
	InstructionMintTo
	InstructionBurn
	InstructionCloseAccount
	InstructionFreezeAccount
	InstructionThawAccount
	InstructionTransferChecked
	InstructionApproveChecked
	InstructionMintToChecked
	InstructionBurnChecked
	InstructionInitializeAccount2
	InstructionSyncNative
	InstructionInitializeAccount3
	InstructionInitializeMultisig2
	InstructionInitializeMint2
)

type MintAccount

type MintAccount struct {
	MintAuthority   *common.PublicKey
	Supply          uint64
	Decimals        uint8
	IsInitialized   bool
	FreezeAuthority *common.PublicKey
}

func MintAccountFromData

func MintAccountFromData(data []byte) (MintAccount, error)

type MintToCheckedParam

type MintToCheckedParam struct {
	Mint     common.PublicKey
	Auth     common.PublicKey
	Signers  []common.PublicKey
	To       common.PublicKey
	Amount   uint64
	Decimals uint8
}

type MintToParam

type MintToParam struct {
	Mint    common.PublicKey
	To      common.PublicKey
	Auth    common.PublicKey
	Signers []common.PublicKey
	Amount  uint64
}

type MultisigAccount

type MultisigAccount struct {
	M             uint8 // Number of signers required
	N             uint8 // Number of valid signers
	IsInitialized bool
	Signers       []common.PublicKey
}

func MultisigAccountFromData

func MultisigAccountFromData(data []byte) (MultisigAccount, error)

type RevokeParam

type RevokeParam struct {
	From    common.PublicKey
	Auth    common.PublicKey
	Signers []common.PublicKey
}

type SetAuthorityParam

type SetAuthorityParam struct {
	Account  common.PublicKey
	NewAuth  *common.PublicKey
	AuthType AuthorityType
	Auth     common.PublicKey
	Signers  []common.PublicKey
}

type SyncNativeParam

type SyncNativeParam struct {
	Account common.PublicKey
}

type ThawAccountParam

type ThawAccountParam struct {
	Account common.PublicKey
	Mint    common.PublicKey
	Auth    common.PublicKey
	Signers []common.PublicKey
}

type TokenAccount

type TokenAccount struct {
	Mint     common.PublicKey
	Owner    common.PublicKey
	Amount   uint64
	Delegate *common.PublicKey
	State    TokenAccountState
	// if is wrapped SOL, IsNative is the rent-exempt value
	IsNative        *uint64
	DelegatedAmount uint64
	CloseAuthority  *common.PublicKey
}

TokenAccount is token program account

func DeserializeTokenAccount

func DeserializeTokenAccount(data []byte, accountOwner common.PublicKey) (TokenAccount, error)

func TokenAccountFromData

func TokenAccountFromData(data []byte) (TokenAccount, error)

type TokenAccountState

type TokenAccountState uint8
const (
	TokenAccountStateUninitialized TokenAccountState = iota
	TokenAccountStateInitialized
	TokenAccountFrozen
)

type TransferCheckedParam

type TransferCheckedParam struct {
	From     common.PublicKey
	To       common.PublicKey
	Mint     common.PublicKey
	Auth     common.PublicKey
	Signers  []common.PublicKey
	Amount   uint64
	Decimals uint8
}

type TransferParam

type TransferParam struct {
	From    common.PublicKey
	To      common.PublicKey
	Auth    common.PublicKey
	Signers []common.PublicKey
	Amount  uint64
}

Jump to

Keyboard shortcuts

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