Documentation ¶
Index ¶
- Constants
- Variables
- func AdjustDecimals(rawAmount int64, decimals int) *big.Rat
- func GetDecimalsFromMint(solanaClient *rpc.Provider, splAccount solana.PublicKey) (uint8, error)
- func GetDecimalsFromPda(solanaClient *rpc.Provider, account solana.PublicKey, commitment string) (uint8, error)
- func GetMintFromPda(solanaClient *rpc.Provider, splAccount solana.PublicKey) (solana.PublicKey, error)
- func IsInitialiseAccount(data string) (bool, error)
- func SendTransfer(solanaClient *rpc.Provider, ...) (string, error)
- type InstructionTransfer
- type SplBurn
- type SplInstruction
- type SplMintAccountTruncated
- type SplMintTo
- type SplTransfer
- type SplTransferChecked
- type SplUserAccountTruncated
Constants ¶
const ( // VariantInitialiseAccount to initialise a spl token account VariantInitialiseAccount = 1 // VariantTransfer to transfer an amount to a user VariantTransfer = 3 // VariantMintTo to mint tokens to a user VariantMintTo = 7 // VariantBurn to burn tokens from a user VariantBurn = 8 // VariantTransferChecked to transfer an amount, // verifying the expected token decimals VariantTransferChecked = 12 )
const ( // TokenProgramAddress to use as the SPL token TokenProgramAddress = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" // TokenAssociatedProgramAddress used to create accounts TokenAssociatedProgramAddress = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" // WrappedSolMintAddress used to wrap sol into an SPL token WrappedSolMintAddress = "So11111111111111111111111111111111111111112" // WrappedSolDecimals to calculate decimals for the wrapped sol token WrappedSolDecimals = 9 )
Variables ¶
var ( // TokenProgramAddressPubkey TokenProgramAddressPubkey solLib.PublicKey // TokenAssociatedProgramAddressPubkey TokenAssociatedProgramAddressPubkey solLib.PublicKey // WrappedSolMintAddressPubkey WrappedSolMintAddressPubkey solLib.PublicKey )
initialised in init.go
var UnknownInstructionError = solana.UnknownInstructionError
Functions ¶
func AdjustDecimals ¶
AdjustDecimals takens a rawAmount (int64) and an number of decimals and returns a rat of the rawAmount adjusted to that many decimal places
func GetDecimalsFromMint ¶
GetDecimals by taking an spl-token mint account, getting its data from the chain, and deserialising to get the decimals
func GetDecimalsFromPda ¶
func GetDecimalsFromPda(solanaClient *rpc.Provider, account solana.PublicKey, commitment string) (uint8, error)
GetDecimalsFromPda to get a token's decimals from a PDA of that token
func GetMintFromPda ¶
func GetMintFromPda(solanaClient *rpc.Provider, splAccount solana.PublicKey) (solana.PublicKey, error)
GetMintFromPda by taking an spl-token user account, getting its data from the chain, and deserialising to get the mint account
func IsInitialiseAccount ¶
IsInitialiseAccount returns if an instruction is an InitialiseAccount
func SendTransfer ¶
func SendTransfer(solanaClient *rpc.Provider, senderPdaAddress, recipientAddress, tokenMintAddress solLib.PublicKey, amount uint64, recentBlockHash solLib.Hash, ownerPublicKey solLib.PublicKey, ownerPrivateKey solLib.PrivateKey) (string, error)
SendTransfer using the token address given, the sender address, returning the signature or an error
Types ¶
type InstructionTransfer ¶
InstructionTransfer generally used with VariantTransfer to send amounts
type SplBurn ¶
type SplBurn struct {
Amount uint64
}
SplBurn represents Burn(u64), burning a token from an account
type SplInstruction ¶
type SplInstruction struct { Transfer *SplTransfer MintTo *SplMintTo Burn *SplBurn TransferChecked *SplTransferChecked }
SplInstruction is a container storing a single variant of the decoded SPL Token instruction enum
func DecodeSplUserAction ¶
func DecodeSplUserAction(data string) (SplInstruction, error)
DecodeSplUserAction tries to decode base58 encoded solana transaction data into one of the SPL token instructions we care about for user actions
type SplMintAccountTruncated ¶
type SplMintAccountTruncated struct { MintAuthority [36]byte Supply uint64 Decimals uint8 Initialised bool FreezeAuthority [36]byte }
SplMintAccountTruncated is a truncated version of the spl-token mint account struct, used to get the decimals
type SplMintTo ¶
type SplMintTo struct {
Amount uint64
}
SplMintTo represents MintTo(u64), minting a token to an account
type SplTransfer ¶
type SplTransfer struct {
Amount uint64
}
SplTransfer represents Transfer(u64), transfering an SPL token between two accounts
type SplTransferChecked ¶
SplTransferChecked represents TransferChecked(u64, u8), transfering a token between two accounts with verification of the token decimals
type SplUserAccountTruncated ¶
SplUserAccountTruncated is a truncated version of the spl-token user account struct, used to get the mint