23 stable releases
| 3.0.0 | Aug 7, 2025 |
|---|---|
| 2.2.1 | Feb 12, 2025 |
| 2.1.21 | Apr 18, 2025 |
| 2.1.16 | Mar 15, 2025 |
| 0.0.2 | Oct 28, 2024 |
#6 in #sysvar
309,673 downloads per month
Used in 763 crates
(9 directly)
9KB
74 lines
solana-sdk
Rust SDK for the Solana blockchain, used by on-chain programs and the Agave validator.
Upgrading from v2 to v3
solana-sdk
The following modules have been removed, please use their component crates directly:
address_lookup_table->solana_address_lookup_table_interfacealt_bn128->solana_bn254bpf_loader_upgradeable->solana_loader_v3_interfaceclient->solana_client_traitscommitment_config->solana_commitment_configcompute_budget->solana_compute_budget_interfacedecode_error->solana_decode_errorderivation_path->solana_derivation_pathed25519_instruction->solana_ed25519_programexit->solana_validator_exitfeature_set->agave_feature_setfeature->solana_feature_gate_interfacegenesis_config->solana_genesis_confighard_forks->solana_hard_forksloader_instruction->solana_loader_v2_interfaceloader_upgradeable_instruction->solana_loader_v3_interface::instructionloader_v4->solana_loader_v4_interfaceloader_v4_instruction->solana_loader_v4_interface::instructionnonce->solana_noncenonce_account->solana_nonce_accountpacket->solana_packetpoh_config->solana_poh_configprecompiles->agave_precompilesprogram_utils->solana_bincode::limited_deserializequic->solana_quic_definitionsrent_collector->solana_rent_collectorrent_debits->solana_rent_debitsreserved_account_keys->agave_reserved_account_keysreward_info->solana_reward_inforeward_type->solana_reward_infosdk_ids->solana_sdk_idssecp256k1_instruction->solana_secp256k1_programsecp256k1_recover->solana_secp256k1_recoverstake->solana_stake_interfacestake_history->solana_stake_interface::stake_historysystem_instruction->solana_system_interface::instructionsystem_program->solana_system_interface::programsystem_transaction->solana_system_transactiontransaction_context->solana_transaction_contextvote->solana_vote_interface
solana-program
The following modules have been removed, please use their component crates directly:
address_lookup_table->solana_address_lookup_table_interfacebpf_loader_upgradeable->solana_loader_v3_interfacedecode_error->solana_decode_errorfeature->solana_feature_gate_interfaceloader_instruction->solana_loader_v2_interfaceloader_upgradeable_instruction->solana_loader_v3_interface::instructionloader_v4->solana_loader_v4_interfaceloader_v4_instruction->solana_loader_v4_interface::instructionmessage->solana_messagenonce->solana_nonceprogram_utils->solana_bincode::limited_deserializesanitize->solana_sanitizesdk_ids->solana_sdk_idsstake->solana_stake_interfacestake_history->solana_stake_interface::stake_historysystem_instruction->solana_system_interface::instructionsystem_program->solana_system_interface::programvote->solana_vote_interface
Building
1. Install rustc, cargo and rustfmt.
curl https://sh.rustup.rs -sSf | sh
source $HOME/.cargo/env
rustup component add rustfmt
2. Download the source code.
git clone https://github.com/anza-xyz/solana-sdk.git
cd solana-sdk
When building the master branch, please make sure you are using the version
specified in the repo's rust-toolchain.toml by running:
rustup show
This command will download the toolchain if it is missing in the system.
3. Test.
cargo test
For Agave Developers
Patching a local solana-sdk repository
If your change to Agave also entails changes to the SDK, you will need to patch your Agave repo to use a local checkout of solana-sdk crates.
To patch all of the crates in this repo for Agave, just run:
./scripts/patch-crates-no-header.sh <AGAVE_PATH> <SOLANA_SDK_PATH>
Publishing a crate from this repository
Unlike Agave, the solana-sdk crates are versioned independently, and published as needed.
If you need to publish a crate, you can use the "Publish Crate" GitHub Action.
Simply type in the path to the crate directory you want to release, ie.
program-entrypoint, along with the kind of release, either patch, minor,
major, or a specific version string.
The publish job will run checks, bump the crate version, commit and tag the bump, publish the crate to crates.io, and finally create GitHub Release with a simple changelog of all commits to the crate since the previous release.
Testing
Certain tests, such as rustfmt and clippy, require the nightly rustc
configured on the repository. To easily install it, use the ./cargo helper
script in the root of the repository:
./cargo nightly tree
Basic testing
Run the test suite:
cargo test
Alternatively, there is a helper script:
./scripts/test-stable.sh
Formatting
Format code for rustfmt check:
./cargo nightly fmt --all
The check can be run with a helper script:
./scripts/check-fmt.sh
Clippy / Linting
To check the clippy lints:
./scripts/check-clippy.sh
Benchmarking
Run the benchmarks:
./scripts/test-bench.sh
Code coverage
To generate code coverage statistics:
./scripts/test-coverage.sh
$ open target/cov/lcov-local/index.html
Code coverage requires llvm-tools-preview for the configured nightly
toolchain. To install the component, run the command output by the script if it
fails to find the component:
rustup component add llvm-tools-preview --toolchain=<NIGHTLY_TOOLCHAIN>
Dependencies
~0.4–7MB
~25K SLoC