• Stars
    star
    3,441
  • Rank 12,985 (Top 0.3 %)
  • Language
    Rust
  • License
    Apache License 2.0
  • Created over 4 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A collection of Solana programs maintained by Solana Labs

Solana Program Library

The Solana Program Library (SPL) is a collection of on-chain programs targeting the Sealevel parallel runtime. These programs are tested against Solana's implementation of Sealevel, solana-runtime, and some are deployed to Mainnet Beta. As others implement Sealevel, we will graciously accept patches to ensure the programs here are portable across all implementations.

For more information see the SPL documentation and the Token TypeDocs.

Audits

Only a subset of programs within the Solana Program Library repo are deployed to the Solana Mainnet Beta. Currently, this includes:

Program Last Audit Date Version
token 2022-08-04 (Peer review) 3.4.0
associated-token-account 2022-08-04 (Peer review) 1.1.0
token-2022 2023-02-10 0.5.0
governance N/A 3.1.0
stake-pool 2023-01-31 1.0.0
account-compression 2022-12-05 0.1.3
shared-memory 2021-02-25 1.0.0
feature-proposal Not audited 1.0.0
name-service Not audited 0.3.0
memo Not audited 3.0.0

All other programs may be updated from time to time. These programs are not audited, so fork and deploy them at your own risk. Here is the full list of unaudited programs:

More information about the repository's security policy at SECURITY.md.

The security-audits repo contains all past and present program audits.

Program Packages

Package Description Version Docs
spl-token ERC20-like token program on Solana Crates.io Docs.rs
spl-token-2022 Token program compatible with spl-token, with extensions Crates.io Docs.rs
spl-associated-token-account Stateless protocol defining a canonical "associated" token account for a wallet Crates.io Docs.rs
spl-governance DAO program using tokens for voting Crates.io Docs.rs
spl-account-compression Program for managing compressed accounts stored in an off-chain merkle tree Crates.io Docs.rs
spl-feature-proposal Program using tokens to vote on enabling Solana network features Crates.io Docs.rs
spl-noop Program that does nothing, used for logging instruction data Crates.io Docs.rs
spl-memo Program for logging signed memos on-chain Crates.io Docs.rs
spl-name-service Program for managing ownership of data on-chain Crates.io Docs.rs
spl-shared-memory Program for sharing data between programs Crates.io Docs.rs
spl-stake-pool Program for pooling stake accounts, managed by another entity Crates.io Docs.rs
spl-instruction-padding Program to padding to other instructions Crates.io Docs.rs
spl-concurrent-merkle-tree Library for on-chain representation of merkle tree Crates.io Docs.rs
spl-math Library for on-chain math Crates.io Docs.rs
spl-token-lending Over-collateralized lending program for tokens Crates.io Docs.rs
spl-token-swap AMM for trading tokens Crates.io Docs.rs
spl-token-upgrade Protocol for burning one token type in exchange for another Crates.io Docs.rs

CLI Packages

Package Description Version
spl-token-cli CLI for the token, token-2022, and associated-token-account programs Crates.io
spl-stake-pool-cli CLI for the stake-pool program Crates.io
spl-feature-proposal-cli CLI for the feature-proposal program Crates.io
spl-token-lending-cli CLI for the token-lending program Crates.io
spl-token-upgrade-cli CLI for the token-upgrade program Crates.io

JavaScript Packages

Package Description Version Docs
@solana/spl-token Bindings for the token, token-2022, and associated-token-account programs npm Docs
@solana/spl-governance Bindings for the governance program npm N/A
@solana/spl-account-compression Bindings for the account-compression program npm Docs
@solana/spl-memo Bindings for the memo program npm N/A
@solana/spl-name-service Bindings for the name-service program npm N/A
@solana/spl-stake-pool Bindings for the stake-pool program npm N/A
@solana/spl-token-lending Bindings for the token-lending program npm N/A
@solana/spl-token-swap Bindings for the token-swap program npm N/A

Development

Environment Setup

  1. Install the latest Solana tools.
  2. Install the latest Rust stable. If you already have Rust, run rustup update to get the latest version.
  3. Install the libudev development package for your distribution (libudev-dev on Debian-derived distros, libudev-devel on Redhat-derived).

Build

Build on-chain programs

# To build all on-chain programs
$ cargo build-sbf

# To build a specific on-chain program
$ cd <program_name>/program
$ cargo build-sbf

Build clients

# To build all clients
$ cargo build

# To build a specific client
$ cd <program_name>/cli
$ cargo build

Test

Unit tests contained within all projects can be run with:

$ cargo test      # <-- runs host-based tests
$ cargo test-sbf  # <-- runs BPF program tests

To run a specific program's tests, such as SPL Token:

$ cd token/program
$ cargo test      # <-- runs host-based tests
$ cargo test-sbf  # <-- runs BPF program tests

Integration testing may be performed via the per-project .js bindings. See the token program's js project for an example.

Common Issues

Solutions to a few issues you might run into are mentioned here.

  1. Failed to open: ../../deploy/spl_<program-name>.so

    Update your Rust and Cargo to the latest versions and re-run cargo build-sbf in the relevant <program-name> directory, or run it at the repository root to rebuild all on-chain programs.

  2. Error while loading shared libraries. (libssl.so.1.1)

    A working solution was mentioned here. Install libssl.

    wget http://nz2.archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1l-1ubuntu1.2_amd64.deb
    sudo dpkg -i libssl1.1_1.1.1l-1ubuntu1.2_amd64.deb
  3. CPU or Memory usage at 100%

    This is to be expected while building some of the programs in this library. The simplest solution is to add the --jobs 1 flag to the build commands to limit the number of parallel jobs to 1 and check if that fixes the issue. Although this will mean much longer build times.

Clippy

$ cargo clippy

Coverage

$ ./coverage.sh  # Help wanted! Coverage build currently fails on MacOS due to an XCode `grcov` mismatch...

MacOS

You may need to pin your grcov version, and then rustup with the apple-darwin nightly toolchain:

$ cargo install grcov --version 0.6.1
$ rustup toolchain install nightly-x86_64-apple-darwin

Release Process

SPL programs are currently tagged and released manually. Each program is versioned independently of the others, with all new development occurring on master. Once a program is tested and deemed ready for release:

Bump Version

  • Increment the version number in the program's Cargo.toml
  • Run cargo build-sbf <program> to build binary. Note the location of the generated spl_<program>.so for attaching to the Github release.
  • Open a PR with these version changes and merge after passing CI.

Create Github tag

Program tags are of the form <program>-vX.Y.Z. Create the new tag at the version-bump commit and push to the solana-program-library repository, eg:

$ git tag token-v1.0.0 b24bfe7
$ git push upstream --tags

Publish Github release

  • Go to GitHub Releases UI
  • Click "Draft new release", and enter the new tag in the "Tag version" box.
  • Title the release "SPL vX.Y.Z", complete the description, and attach the spl_<program>.so binary
  • Click "Publish release"

Publish to Crates.io

Navigate to the program directory and run cargo package to test the build. Then run cargo publish.

Disclaimer

All claims, content, designs, algorithms, estimates, roadmaps, specifications, and performance measurements described in this project are done with the Solana Labs, Inc. (β€œSL”) best efforts. It is up to the reader to check and validate their accuracy and truthfulness. Furthermore nothing in this project constitutes a solicitation for investment.

Any content produced by SL or developer resources that SL provides, are for educational and inspiration purposes only. SL does not encourage, induce or sanction the deployment, integration or use of any such applications (including the code comprising the Solana blockchain protocol) in violation of applicable laws or regulations and hereby prohibits any such deployment, integration or use. This includes use of any such applications by the reader (a) in violation of export control or sanctions laws of the United States or any other applicable jurisdiction, (b) if the reader is located in or ordinarily resident in a country or territory subject to comprehensive sanctions administered by the U.S. Office of Foreign Assets Control (OFAC), or (c) if the reader is or is working on behalf of a Specially Designated National (SDN) or a person subject to similar blocking or denied party prohibitions.

The reader should be aware that U.S. export control and sanctions laws prohibit U.S. persons (and other persons that are subject to such laws) from transacting with persons in certain countries and territories or that are on the SDN list. Accordingly, there is a risk to individuals that other persons using any of the code contained in this repo, or a derivation thereof, may be sanctioned persons and that transactions with such persons would be a violation of U.S. export controls and sanctions law.

More Repositories

1

solana

Web-Scale Blockchain for fast, secure, scalable, decentralized apps and marketplaces.
Rust
12,934
star
2

solana-web3.js

Solana JavaScript SDK
TypeScript
2,090
star
3

dapp-scaffold

Scaffolding for a dapp built on Solana
TypeScript
1,733
star
4

token-list

The community maintained Solana token registry
Go
1,470
star
5

wallet-adapter

Modular TypeScript wallet adapters and components for Solana applications.
TypeScript
1,180
star
6

solana-pay

A new standard for decentralized payments.
TypeScript
1,173
star
7

example-helloworld

Hello world on Solana
TypeScript
900
star
8

solana-season

337
star
9

break

Break Solana Game
TypeScript
300
star
10

governance-ui

TypeScript
293
star
11

explorer

Explorer for Solana clusters
TypeScript
222
star
12

chatgpt-plugin

TypeScript
179
star
13

defi-hackathon

170
star
14

octane

Octane is a gasless transaction relayer for Solana.
TypeScript
164
star
15

ecosystem

Project files for Solana ecosystem members
153
star
16

obsolete-spl-zk-token

Obsolete - don't use
Rust
145
star
17

oyster-swap

TypeScript
121
star
18

oyster

TypeScript
115
star
19

solana-solidity.js

Compile, deploy, and use Solidity contracts on Solana
TypeScript
115
star
20

solana-accountsdb-plugin-postgres

Rust
87
star
21

solana-payments-app

Solana Pay for Commerce Platforms
TypeScript
84
star
22

solana-bigtable

Shell
77
star
23

whitepaper

Solana whitepaper LaTeX source
TeX
71
star
24

perpetuals

Solana perpetuals reference implementation
Rust
71
star
25

dexterity

Reference implementation of a decentralized exchange for custom instruments, risk, and fees
Rust
69
star
26

oyster-lending

TypeScript
66
star
27

eslint-plugin-require-extensions

JavaScript
58
star
28

governance-program-library

Rust
48
star
29

wallet-standard

TypeScript
46
star
30

security-audits

Published security audits
45
star
31

solana-perf-libs

C and CUDA libraries to enhance Solana
C
41
star
32

solana-pay-scaffold

Scaffolding for a dapp using Solana Pay
TypeScript
41
star
33

example-token

Obsoleted by https://spl.solana.com/token (Token Example)
Rust
40
star
34

example-tictactoe

Tic-Tac-Toe built on Solana
JavaScript
37
star
35

obsolete-dontuse-example-webwallet

Example Solana Web-based Wallet
JavaScript
36
star
36

browser-extension

Solana Chrome Extension
TypeScript
35
star
37

wormhole-hackathon

34
star
38

example-messagefeed

Simple message feed built on Solana
JavaScript
34
star
39

solana-ping-api

solana ping api server
Go
33
star
40

platform-tools

Shell
30
star
41

cluster

Cluster Infrastructure
Shell
27
star
42

rust-bpf-sysroot

Rust sysroot source for Berkley Packet Filter Rust programs
C
20
star
43

governance-docs

JavaScript
20
star
44

solana-labs.github.io

Organization Pages
17
star
45

wbtc

TypeScript
17
star
46

auto-emissions

Python
16
star
47

example-move

Solana example which runs a Libra Move program
JavaScript
16
star
48

launchpad

Solana launchpad reference implementation
Rust
15
star
49

solana-voib-demo

Voice over Internet & Blockchain (VoIB) demo
Rust
15
star
50

buffer-layout-utils

TypeScript utilities for using buffer-layout with Solana programs
TypeScript
14
star
51

eslint-config-solana

ESLint rules to be shared across all Solana Labs projects
JavaScript
14
star
52

token-ops

Scripts and tools for token accounting and operation
Shell
14
star
53

networkexplorer

Retired
JavaScript
13
star
54

rust-bpf-builder

Dockerfile
13
star
55

network_simulation

Python
13
star
56

sealevel

A parallel runtime for layer 1 blockchains
12
star
57

token-aggregator

Aggregates tokens listed in onchain token registry
TypeScript
12
star
58

twamm

Solana twamm reference implementation
TypeScript
12
star
59

bench-tps-dos-test

UDP and QUIC dos test for buildkite using bench-tps utility
Shell
10
star
60

governance-api

TypeScript
10
star
61

farms

Solana Farms
Rust
10
star
62

interns-codehub

Public repo for Solana interns
TypeScript
10
star
63

solminer

Cross-platform Solana Replicator UI ⛏️
JavaScript
9
star
64

dc-homedir-skeleton

Base directory struct for the `solana` user on Solana's datacenter infrastructure
Shell
9
star
65

newlib

Newlib is a C library intended for use on embedded systems.
C
9
star
66

reddit-scaling-demo

Demo for Reddit scaling
Rust
9
star
67

solana-flagged-accounts

A community-maintained registry of flagged accounts
JavaScript
8
star
68

llvm-builder

Builds customized LLVM for Solana
Dockerfile
8
star
69

ledger-app-solana

Solana app for Ledger Wallet
8
star
70

tour-de-sol

Tour de SOL
Rust
8
star
71

bridge-adapter

TypeScript
8
star
72

secure-wrap-token

Rust
8
star
73

validator-tracker

https://metrics.solana.com:3000/d/jrdi4uUWz/validator-tracker
Shell
7
star
74

oyster-margin

7
star
75

governance-ui-landing

Governance UI Landing Page - realms.today
TypeScript
7
star
76

cargo-run-solana-tests

Cargo command to compile and run BPF test
Rust
7
star
77

contributor-access-policy

This document outlines the procedure for getting contributor access to various Solana Labs source code repositories
7
star
78

inc-20210825

Tool for audit and reclaim of delegated SPL Token accounts
Rust
6
star
79

prettier-config-solana

A Prettier config consistent to all Solana Labs projects
6
star
80

k8s-cluster

5
star
81

solana-pkcs8

A utility to parse DER-encoded PKCS #8 files
Rust
5
star
82

solana-graphql-playground

GraphQL web IDE for working with the Solana RPC-GraphQL resolver
TypeScript
5
star
83

kurtosis-solana-testing

Rust
5
star
84

solana-json-rpc-https-proxy

DEPRECATED - Provides a TLS proxy for web-based Solana JSON RPC users
Shell
4
star
85

solana-build

Rust
4
star
86

governance-sdk

Governance SDK
TypeScript
4
star
87

solana-tokens

Utility for distributing Solana tokens
4
star
88

oyster-bridge

3
star
89

oyster-gov

1
star
90

ipfs-ledger

1
star
91

sync_test

For developing a Github Action to sync solana-labs/solana from anza-xyz/agave
1
star
92

spl-token-subscription

Rust
1
star