Skip to content

Constants

Solace::Constants holds the well-known Solana program IDs, and can load additional constants (e.g. your own program IDs or token addresses) from YAML.

Program IDs

ConstantValue
SYSTEM_PROGRAM_ID11111111111111111111111111111111
TOKEN_PROGRAM_IDTokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
TOKEN_2022_PROGRAM_IDTokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb
ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_IDATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL
SYSVAR_RENT_PROGRAM_IDSysvarRent111111111111111111111111111111111
COMPUTE_BUDGET_PROGRAM_IDComputeBudget111111111111111111111111111111
MEMO_PROGRAM_IDMemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr
ADDRESS_LOOKUP_TABLE_PROGRAM_IDAddressLookupTab1e1111111111111111111111111
ruby
Solace::Constants::SYSTEM_PROGRAM_ID
Solace::Constants::TOKEN_2022_PROGRAM_ID

These are the same across all clusters and are referenced throughout the instruction builders and composers.

Loading constants from YAML

Solace::Constants.load defines additional constants from a YAML file, namespaced so you can keep per-cluster sets in one file.

ParameterTypeRequiredDefaultDescription
pathStringyesPath to the YAML file.
namespaceStringno'default'Top-level key to load from.
protect_overridesBooleannotrueRaise ArgumentError if a constant is already defined (rather than redefining it).
yaml
# constants.yml
mainnet:
  my_program_id: "Prog1111111111111111111111111111111111111111"
ruby
Solace::Constants.load(path: 'constants.yml', namespace: 'mainnet')
Solace::Constants::MY_PROGRAM_ID # => "Prog1111…"

Keys are upper-cased to form the constant name. With protect_overrides: false, an existing constant is removed and redefined instead of raising.

A Ruby SDK for Solana