sgo

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2022 License: MIT Imports: 11 Imported by: 0

README

Go Report Card GoDoc

Solana Go Tools

Solana Go cli tools we used in early development while building magic.markets to create and manage a stable coin mint substitute on local and devnet. Such mint is used by our escrow program and is the medium of exchange for market participants. This heavily depends on the fantastic Go package gagliardetto/solana-go.

Custom rpc and websocket URLs are supported as well as monikers (and by their first letter), mainnet-beta, testnet, devnet, localhost.

Create a new token keypair using the solana toolchain:

solana-keygen new --outfile mytoken.json

Create the mint using the keypair on devnet:

go run create_escrow_mint/main.go -decimals 6 -payer ~/.config/solana/id.json -mint mytoken.json -url devnet

Mint 100k tokens to acccount <PUBKEY> on devnet:

go run mint_escrow_tokens/main.go -amount 100000 -mint mytoken.json -payer ~/.config/solana/id.json -receiver <PUBKEY> -url d

Documentation

Index

Constants

View Source
const MintAccountSize = 82

Variables

View Source
var ErrUnknownMoniker = errors.New("unknown moniker")

Functions

func CreateAssociatedTokenAccount

func CreateAssociatedTokenAccount(ctx context.Context, client *rpc.Client, ws *ws.Client, wallet, mint solana.PublicKey, payer solana.PrivateKey) (*solana.PublicKey, error)

func GetMint

func GetMint(ctx context.Context, client *rpc.Client, address solana.PublicKey) (*token.Mint, error)

func InitMintInstruction

func InitMintInstruction(ctx context.Context, decimals uint8, mint, owner solana.PublicKey) (solana.Instruction, error)

func MintTo

func MintTo(ctx context.Context, client *rpc.Client, ws *ws.Client, mintAccount, tokenAccount solana.PublicKey, amount uint64, mintAuthority, payer solana.PrivateKey) (*solana.Signature, error)

func MintToInstruction

func MintToInstruction(ctx context.Context, mintAccount, mintAuthority, tokenAccount solana.PublicKey, amount uint64) (solana.Instruction, error)

func NewAccountInstruction

func NewAccountInstruction(ctx context.Context, client *rpc.Client, account, owner, payer solana.PublicKey, size uint64) (solana.Instruction, error)

func NewMintInstruction

func NewMintInstruction(ctx context.Context, client *rpc.Client, decimals uint8, mint, owner, payer solana.PublicKey) ([]solana.Instruction, error)

func RPCFromMoniker

func RPCFromMoniker(moniker string) (string, error)

func SendTx

func SendTx(ctx context.Context, rpcClient *rpc.Client, wsClient *ws.Client, instructions []solana.Instruction, signers []solana.PrivateKey, payer solana.PrivateKey, synchronous bool) (*solana.Signature, error)

func WSFromMoniker

func WSFromMoniker(moniker string) (string, error)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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