solana

package
v0.128.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 18 Imported by: 35

Documentation

Index

Constants

View Source
const (
	ProgramIDPrefix      = "Program Id: "
	BufferIDPrefix       = "Buffer: "
	SolDefaultCommitment = solrpc.CommitmentConfirmed
)

Variables

This section is empty.

Functions

func AddressToBytes added in v0.44.0

func AddressToBytes(address string) ([]byte, error)

AddressToBytes converts a Solana address string to bytes. Solana addresses are base58-encoded public keys (32 bytes).

Types

type AddressConverter added in v0.44.0

type AddressConverter struct{}

AddressConverter implements address conversion for Solana chains. This struct implements the AddressConverter strategy interface.

func (AddressConverter) ConvertToBytes added in v0.44.0

func (s AddressConverter) ConvertToBytes(address string) ([]byte, error)

ConvertToBytes converts a Solana address string to bytes.

func (AddressConverter) Supports added in v0.44.0

func (s AddressConverter) Supports(family string) bool

Supports returns true if this converter supports the given chain family.

type Chain

type Chain struct {
	Selector uint64

	// RPC client
	Client *solrpc.Client
	URL    string
	WSURL  string
	// DeployerKey is the deployer's raw private key. It is nil when the deployer signs remotely
	// (e.g. with AWS KMS). Prefer Deployer(), which works in both cases.
	DeployerKey *sollib.PrivateKey

	// DeployerSigner signs transactions on behalf of the deployer. If DeployerKey is nil, the
	// keypair at KeypairPath (if any) is a separate key used only by the Solana CLI.
	DeployerSigner Signer

	// SendAndConfim provides a utility function to send a transaction and waits for confirmation.
	// Options can be passed to modify the transaction such as setting additional signers or
	// modifying compute unit limits.
	SendAndConfirm func(
		ctx context.Context, instructions []sollib.Instruction, opts ...rpcclient.TxModifier,
	) error

	// Legacy: Use SendAndConfirm instead. This function will be removed in the future.
	// Confirm is a legacy function that sends a transaction and waits for confirmation.
	Confirm func(instructions []sollib.Instruction, opts ...solCommonUtil.TxModifier) error

	// deploy uses the solana CLI which needs a keyfile
	KeypairPath  string
	ProgramsPath string
}

Chain represents a Solana chain.

func (Chain) ChainSelector

func (c Chain) ChainSelector() uint64

ChainSelector returns the chain selector of the chain

func (Chain) CloseBuffers

func (c Chain) CloseBuffers(logger logger.Logger, buffer string) error

func (Chain) DeployProgram

func (c Chain) DeployProgram(logger logger.Logger, programInfo ProgramInfo, isUpgrade bool, overallocate bool) (string, error)

Overallocate should be set when deploying any program that may eventually be owned by timelock Overallocate is mutually exclusive with isUpgrade

func (Chain) Deployer added in v0.128.0

func (c Chain) Deployer() Signer

Deployer returns the signer for the deployer account, or nil if the chain has no deployer.

func (Chain) Family added in v0.5.1

func (c Chain) Family() string

Family returns the family of the chain

func (Chain) GetAccountDataBorshInto

func (c Chain) GetAccountDataBorshInto(ctx context.Context, pubkey sollib.PublicKey, accountState interface{}) error

func (Chain) IsNetworkType added in v0.78.0

func (c Chain) IsNetworkType(networkType chainsel.NetworkType) bool

IsNetworkType checks if the chain is on the given network type

func (Chain) Name

func (c Chain) Name() string

Name returns the name of the chain

func (Chain) NetworkType added in v0.78.0

func (c Chain) NetworkType() (chainsel.NetworkType, error)

NetworkType returns the type of network the chain is on (e.g. mainnet, testnet)

func (Chain) ReadOnly added in v0.100.0

func (c Chain) ReadOnly() (chaincommon.BlockChain, error)

func (Chain) String

func (c Chain) String() string

String returns chain name and selector "<name> (<selector>)"

type KMSSigner added in v0.128.0

type KMSSigner struct {
	// contains filtered or unexported fields
}

KMSSigner signs Solana transactions with an Ed25519 key held in AWS KMS. The private key never leaves KMS.

func NewKMSSigner added in v0.128.0

func NewKMSSigner(ctx context.Context, keyID, keyRegion string) (*KMSSigner, error)

NewKMSSigner builds a Signer backed by an AWS KMS Ed25519 key. The ctx is only used to fetch the public key and is not retained.

func (*KMSSigner) PublicKey added in v0.128.0

func (s *KMSSigner) PublicKey() sollib.PublicKey

PublicKey returns the Solana address of the KMS key.

func (*KMSSigner) Sign added in v0.128.0

func (s *KMSSigner) Sign(ctx context.Context, message []byte) (sollib.Signature, error)

Sign signs the message with the KMS Ed25519 key.

type ProgramInfo

type ProgramInfo struct {
	Name  string
	Bytes int
}

ProgramInfo contains information about a Solana program.

type Signer added in v0.128.0

type Signer = rpcclient.Signer

Signer signs Solana transaction messages on behalf of a single account.

func NewPrivateKeySigner added in v0.128.0

func NewPrivateKeySigner(key sollib.PrivateKey) Signer

NewPrivateKeySigner returns a Signer backed by a local private key.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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