solana_sdk/
lib.rs

1//! The Solana host and client SDK.
2//!
3//! This is the base library for all off-chain programs that interact with
4//! Solana or otherwise operate on Solana data structures. On-chain programs
5//! instead use the [`solana-program`] crate, the modules of which are
6//! re-exported by this crate, like the relationship between the Rust
7//! `core` and `std` crates. As much of the functionality of this crate is
8//! provided by `solana-program`, see that crate's documentation for an
9//! overview.
10//!
11//! [`solana-program`]: https://docs.rs/solana-program
12//!
13//! Many of the modules in this crate are primarily of use to the Solana runtime
14//! itself. Additional crates provide capabilities built on `solana-sdk`, and
15//! many programs will need to link to those crates as well, particularly for
16//! clients communicating with Solana nodes over RPC.
17//!
18//! Such crates include:
19//!
20//! - [`solana-client`] - For interacting with a Solana node via the [JSON-RPC API][json].
21//! - [`solana-cli-config`] - Loading and saving the Solana CLI configuration file.
22//! - [`solana-clap-utils`] - Routines for setting up the CLI using [`clap`], as
23//!   used by the Solana CLI. Includes functions for loading all types of
24//!   signers supported by the CLI.
25//!
26//! [`solana-client`]: https://docs.rs/solana-client
27//! [`solana-cli-config`]: https://docs.rs/solana-cli-config
28//! [`solana-clap-utils`]: https://docs.rs/solana-clap-utils
29//! [json]: https://solana.com/docs/rpc
30//! [`clap`]: https://docs.rs/clap
31
32#![cfg_attr(docsrs, feature(doc_auto_cfg))]
33
34// Allows macro expansion of `use ::solana_sdk::*` to work within this crate
35extern crate self as solana_sdk;
36
37#[deprecated(since = "2.2.0", note = "Use `solana-message` crate instead")]
38pub use solana_message as message;
39#[cfg(feature = "borsh")]
40pub use solana_program::borsh1;
41#[cfg(not(target_os = "solana"))]
42pub use solana_program::program_stubs;
43pub use solana_program::{
44    account_info, big_mod_exp, blake3, bpf_loader, bpf_loader_deprecated, clock, config,
45    custom_heap_default, custom_panic_default, debug_account_data, declare_deprecated_sysvar_id,
46    declare_sysvar_id, ed25519_program, epoch_rewards, epoch_schedule, fee_calculator,
47    impl_sysvar_get, incinerator, instruction, keccak, lamports, msg, native_token, program,
48    program_error, program_option, program_pack, rent, secp256k1_program, serialize_utils,
49    slot_hashes, slot_history, stable_layout, syscalls, sysvar, unchecked_div_by_const,
50};
51#[cfg(feature = "full")]
52#[deprecated(since = "2.2.0", note = "Use `solana-signer` crate instead")]
53pub use solana_signer::signers;
54pub mod entrypoint;
55pub mod entrypoint_deprecated;
56pub mod example_mocks;
57pub mod hash;
58pub mod log;
59pub mod native_loader;
60pub mod pubkey;
61#[cfg(feature = "full")]
62#[deprecated(since = "2.2.0", note = "Use `solana-shred-version` crate instead")]
63pub use solana_shred_version as shred_version;
64pub mod signature;
65pub mod signer;
66pub mod transaction;
67pub mod transport;
68
69#[deprecated(since = "2.1.0", note = "Use `solana-account` crate instead")]
70pub use solana_account as account;
71#[deprecated(
72    since = "2.1.0",
73    note = "Use `solana_account::state_traits` crate instead"
74)]
75pub use solana_account::state_traits as account_utils;
76#[deprecated(since = "2.2.0", note = "Use `solana-epoch-info` crate instead")]
77pub use solana_epoch_info as epoch_info;
78#[deprecated(
79    since = "2.2.0",
80    note = "Use `solana-epoch-rewards-hasher` crate instead"
81)]
82pub use solana_epoch_rewards_hasher as epoch_rewards_hasher;
83#[deprecated(since = "2.2.0", note = "Use `solana-fee-structure` crate instead")]
84pub use solana_fee_structure as fee;
85#[deprecated(since = "2.1.0", note = "Use `solana-inflation` crate instead")]
86pub use solana_inflation as inflation;
87#[deprecated(
88    since = "2.2.0",
89    note = "Use `solana_message::inner_instruction` instead"
90)]
91pub use solana_message::inner_instruction;
92#[cfg(feature = "full")]
93#[deprecated(since = "2.2.0", note = "Use `solana-offchain-message` crate instead")]
94pub use solana_offchain_message as offchain_message;
95#[deprecated(since = "2.1.0", note = "Use `solana-program-memory` crate instead")]
96pub use solana_program_memory as program_memory;
97#[deprecated(since = "2.1.0", note = "Use `solana_pubkey::pubkey` instead")]
98/// Convenience macro to define a static public key.
99///
100/// Input: a single literal base58 string representation of a Pubkey
101///
102/// # Example
103///
104/// ```
105/// use std::str::FromStr;
106/// use solana_program::{pubkey, pubkey::Pubkey};
107///
108/// static ID: Pubkey = pubkey!("My11111111111111111111111111111111111111111");
109///
110/// let my_id = Pubkey::from_str("My11111111111111111111111111111111111111111").unwrap();
111/// assert_eq!(ID, my_id);
112/// ```
113pub use solana_pubkey::pubkey;
114#[deprecated(since = "2.1.0", note = "Use `solana-sanitize` crate instead")]
115pub use solana_sanitize as sanitize;
116/// Same as `declare_id` except report that this id has been deprecated.
117pub use solana_sdk_macro::declare_deprecated_id;
118/// Convenience macro to declare a static public key and functions to interact with it.
119///
120/// Input: a single literal base58 string representation of a program's id
121///
122/// # Example
123///
124/// ```
125/// # // wrapper is used so that the macro invocation occurs in the item position
126/// # // rather than in the statement position which isn't allowed.
127/// use std::str::FromStr;
128/// use solana_sdk::{declare_id, pubkey::Pubkey};
129///
130/// # mod item_wrapper {
131/// #   use solana_sdk::declare_id;
132/// declare_id!("My11111111111111111111111111111111111111111");
133/// # }
134/// # use item_wrapper::id;
135///
136/// let my_id = Pubkey::from_str("My11111111111111111111111111111111111111111").unwrap();
137/// assert_eq!(id(), my_id);
138/// ```
139pub use solana_sdk_macro::declare_id;
140/// Convenience macro to define multiple static public keys.
141pub use solana_sdk_macro::pubkeys;
142#[deprecated(since = "2.2.0", note = "Use `solana-serde` crate instead")]
143pub use solana_serde as deserialize_utils;
144#[deprecated(since = "2.1.0", note = "Use `solana-serde-varint` crate instead")]
145pub use solana_serde_varint as serde_varint;
146#[deprecated(since = "2.1.0", note = "Use `solana-short-vec` crate instead")]
147pub use solana_short_vec as short_vec;
148#[deprecated(since = "2.2.0", note = "Use `solana-time-utils` crate instead")]
149pub use solana_time_utils as timing;
150#[cfg(feature = "full")]
151#[deprecated(
152    since = "2.2.0",
153    note = "Use `solana_transaction::simple_vote_transaction_checker` instead"
154)]
155pub use solana_transaction::simple_vote_transaction_checker;
156
157pub extern crate bs58;