tokenprog

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const MintAccountSize = 82
View Source
const MultisigAccountSize uint64 = 355
View Source
const TokenAccountSize = 165

Variables

View Source
var (
	Some = []byte{1, 0, 0, 0}
	None = []byte{0, 0, 0, 0}
)

Functions

func Approve

func Approve(sourcePubkey, delegatePubkey, authPubkey common.PublicKey, signerPubkeys []common.PublicKey, amount uint64) types.Instruction

func ApproveChecked

func ApproveChecked(sourcePubkey, mintPubkey, delegatePubkey, authPubkey common.PublicKey, signerPubkeys []common.PublicKey, amount uint64, decimals uint8) types.Instruction

func Burn

func Burn(accountPubkey, mintPubkey, authPubkey common.PublicKey, signerPubkeys []common.PublicKey, amount uint64) types.Instruction

func BurnChecked

func BurnChecked(accountPubkey, mintPubkey, authPubkey common.PublicKey, signerPubkeys []common.PublicKey, amount uint64, decimals uint8) types.Instruction

func CloseAccount

func CloseAccount(accountPubkey, destPubkey, authPubkey common.PublicKey, signerPubkeys []common.PublicKey) 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(accountPubkey, mintPubkey, authPubkey common.PublicKey, signerPubkeys []common.PublicKey) types.Instruction

func InitializeAccount

func InitializeAccount(accountPublicKey, mintPublicKey, ownerPublickey common.PublicKey) types.Instruction

InitializeAccount init a token account which can receive token

func InitializeAccount2

func InitializeAccount2(accountPubkey, mintPubkey, ownerPubkey common.PublicKey) types.Instruction

func InitializeMint

func InitializeMint(decimals uint8, mint, mintAuthority common.PublicKey, freezeAuthority common.PublicKey) types.Instruction

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

func InitializeMultisig

func InitializeMultisig(authPubkey common.PublicKey, signerPubkeys []common.PublicKey, miniRequired uint8) types.Instruction

func MintTo

func MintTo(mintPubkey, destPubkey, authPubkey common.PublicKey, signerPubkeys []common.PublicKey, amount uint64) types.Instruction

func MintToChecked

func MintToChecked(mintPubkey, destPubkey, authPubkey common.PublicKey, signerPubkeys []common.PublicKey, amount uint64, decimals uint8) types.Instruction

func Revoke

func Revoke(srcPubkey, authPubkey common.PublicKey, signerPubkeys []common.PublicKey) types.Instruction

func SetAuthority

func SetAuthority(accountPubkey, newAuthPubkey common.PublicKey, authType AuthorityType, authPubkey common.PublicKey, signerPubkeys []common.PublicKey) types.Instruction

func SyncNative

func SyncNative(accountPubkey common.PublicKey) types.Instruction

SyncNative will update your wrapped SOL balance

func ThawAccount

func ThawAccount(accountPubkey, mintPubkey, authPubkey common.PublicKey, signerPubkeys []common.PublicKey) types.Instruction

func Transfer

func Transfer(srcPubkey, destPubkey, authPubkey common.PublicKey, signerPubkeys []common.PublicKey, amount uint64) types.Instruction

func TransferChecked

func TransferChecked(srcPubkey, destPubkey, mintPubkey, authPubkey common.PublicKey, signerPubkeys []common.PublicKey, amount uint64, decimals uint8) types.Instruction

Types

type AuthorityType

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

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
	InitializeAccount3
	InitializeMultisig2
	InitializeMint2
)

type MintAccount

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

type TokenAccount

type TokenAccount struct {
	Mint            common.PublicKey
	Owner           common.PublicKey
	Amount          uint64
	Delegate        *common.PublicKey
	State           TokenAccountState
	IsNative        *uint64
	DelegatedAmount uint64
	CloseAuthority  *common.PublicKey
}

TokenAccount is token program account

func TokenAccountFromData

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

type TokenAccountState

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

Jump to

Keyboard shortcuts

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