sgo

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 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 and Mint Escrow Tokens

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

On-Chain Escrow Token Faucet

Transfer the mint authority to an on-chain faucet on devnet:

go run init_escrow_faucet/main.go -mint mytoken.json -authority ~/.config/solana/id.json -url d

Run an airdrop against the faucet. In order to avoid spam the faucet gives out tokens for devent SOL at a rate of 100x by default. Here we swap 1 SOL for 100 escrow tokens:

go run faucet_airdrop/main.go -amount 1 -payer ~/.config/solana/id.json -mint <MINT PUBKEY> -url d

If you hold the faucet sweep authority, you can regularly claim the devnet SOL deposited for tokens. On devnet for example:

go run sweep_faucet/main.go -amount 1.2 -authority ~/.config/solana/id.json -mint <MINT 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
generated

Jump to

Keyboard shortcuts

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