svmutil

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2025 License: GPL-3.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DevnetUSDCMint is the USDC mint private key on local devnet.
	DevnetUSDCMint = solana.PrivateKey(ed25519.NewKeyFromSeed([]byte(usdcSeed)))
)
View Source
var Version = "stable"

Functions

func AwaitConfirmedTransaction

func AwaitConfirmedTransaction(ctx context.Context, cl *rpc.Client, txSig solana.Signature) (*rpc.GetTransactionResult, error)

AwaitConfirmedTransaction waits for a transaction to be confirmed.

func ChainID

func ChainID(ctx context.Context, cl *rpc.Client) (uint64, error)

func Deploy

func Deploy(ctx context.Context, rpcAddr string, program Program, deployer, upgrader solana.PrivateKey) (*rpc.GetTransactionResult, error)

Deploy deploys a program to the rpc network using the provided keys. It returns the confirmed transaction result or an error.

func EnsureATA

func EnsureATA(ctx context.Context, cl *rpc.Client, mint solana.PublicKey, owner solana.PrivateKey) (solana.PublicKey, error)

EnsureATA returns (and possibly creates) the owner's associated token account (ATA) for the given mint.

func EnsureATAs

func EnsureATAs(ctx context.Context, cl *rpc.Client, mint solana.PublicKey, owners ...solana.PrivateKey) (map[solana.PublicKey]solana.PublicKey, error)

EnsureATAs finds or creates the owners' associated token account (ATA) for the given mint.

func FillHash

func FillHash(
	orderID [32]byte,
	srcChainID uint64,
	destChainID uint64,
	fillDeadline uint32,
	callTarget common.Address,
	callSelector [4]byte,
	callValue *big.Int,
	callParams []byte,
	expenseSpender common.Address,
	expenseToken common.Address,
	expenseAmount *big.Int,
) (common.Hash, error)

FillHash returns the fill hash for the given parameters.

func FilterDataLogs

func FilterDataLogs(logs []string, program solana.PublicKey) ([]string, bool, error)

FilterDataLogs filters the logs for a specific program, returning only the data logs and true if logs were not truncated.

func GetAccountDataInto

func GetAccountDataInto(ctx context.Context, cl *rpc.Client, address solana.PublicKey, val any) (*rpc.GetAccountInfoResult, error)

GetAccountDataInto retrieves account data and decodes it into the provided value. It uses commitment level of "confirmed".

func GetBlock

func GetBlock(ctx context.Context, cl *rpc.Client, slot uint64, details rpc.TransactionDetailsType) (*rpc.GetBlockResult, bool, error)

GetBlock is a convenience function returning the block for the given slot, or false if no block found for the slot, or and error.

func MapEVMKey

func MapEVMKey(key *ecdsa.PrivateKey) solana.PrivateKey

MapEVMKey returns a deterministic mapping of an EVM secp256k1 private key to a Solana ed25519 private key.

func NativeBalanceAt

func NativeBalanceAt(ctx context.Context, cl *rpc.Client, addr solana.PublicKey) (*big.Int, error)

func RandomU96

func RandomU96() bin.Uint128

RandomU96 generates a random 96-bit unsigned integer of type bin.Uint128.

func Redeploy

func Redeploy(ctx context.Context, rpcAddr string, program Program, upgrader solana.PrivateKey) (*rpc.GetTransactionResult, error)

Redeploy redeployes/upgrades the program to the rpc network using the provided keys. It returns the confirmed transaction result or an error.

func SavePrivateKey

func SavePrivateKey(key solana.PrivateKey, path string) error

SavePrivateKey saves a Solana private key to a file in JSON format.

func Send

func Send(ctx context.Context, cl *rpc.Client, opts ...func(*sendOpts)) (solana.Signature, error)

func SendSimple

func SendSimple(ctx context.Context, cl *rpc.Client, privkey solana.PrivateKey, instrs ...solana.Instruction) (solana.Signature, error)

func Start

func Start(ctx context.Context, composeDir string) (*rpc.Client, string, solana.PrivateKey, func(), error)

Start starts a genesis solana node and returns a client, a funded private key and a stop function or an error. The dir parameter is the location of the docker compose.

func Stream

func Stream(ctx context.Context, cl *rpc.Client, req StreamReq, callback StreamCallback) error

func TokenBalanceAt

func TokenBalanceAt(ctx context.Context, cl *rpc.Client, mint, wallet solana.PublicKey) (*big.Int, error)

func U128

func U128(i *big.Int) (bin.Uint128, error)

U128 returns the big int as a solana binary uint128.

func WithInstructions

func WithInstructions(instrs ...solana.Instruction) func(*sendOpts)

func WithPrivateKeys

func WithPrivateKeys(privkeys ...solana.PrivateKey) func(*sendOpts)

func WrapRPCError

func WrapRPCError(err error, endpoint string, attrs ...any) error

Types

type CreateMintResp

type CreateMintResp struct {
	MintAccount solana.PublicKey
	Authority   solana.PrivateKey
	ATAs        map[solana.PublicKey]solana.PublicKey // Map of funded associated token accounts
}

func CreateMint

func CreateMint(
	ctx context.Context,
	cl *rpc.Client,
	authority solana.PrivateKey,
	mint solana.PrivateKey,
	decimals uint8,
	toFund ...solana.PublicKey,
) (CreateMintResp, error)

func (CreateMintResp) AuthATA

func (r CreateMintResp) AuthATA() solana.PublicKey

type Program

type Program struct {
	Name         string
	SharedObject []byte // Compiled BPF shared object
	KeyPairJSON  []byte
}

Program represents a Solana executable program (smart contract).

func Rebuild

func Rebuild(ctx context.Context, program Program, key solana.PrivateKey, anchorDir string) (Program, error)

Rebuild rebuilds the program's so file with the provided private key. This effectively changes the program ID.

func (Program) KeyPairFile

func (p Program) KeyPairFile() string

func (Program) MustPrivateKey

func (p Program) MustPrivateKey() solana.PrivateKey

func (Program) MustPublicKey

func (p Program) MustPublicKey() solana.PublicKey

func (Program) SOFile

func (p Program) SOFile() string

type StreamCallback

type StreamCallback func(ctx context.Context, sig *rpc.TransactionSignature) error

StreamCallback abstracts the logic that handles a stream of transaction signatures. The logic must be idempotent.

type StreamReq

type StreamReq struct {
	AfterSig   solana.Signature // Exclusive
	Account    solana.PublicKey
	Commitment rpc.CommitmentType
}

StreamReq defines which transactions to stream.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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