Crate soroban_sdk
source ·Expand description
Soroban SDK supports writing programs for the Soroban smart contract platform.
Docs
See soroban.stellar.org for documentation.
Examples
use soroban_sdk::{contractimpl, symbol, vec, BytesN, Env, Symbol, Vec};
pub struct HelloContract;
#[contractimpl]
impl HelloContract {
pub fn hello(env: Env, to: Symbol) -> Vec<Symbol> {
vec![&env, symbol!("Hello"), to]
}
}
#[test]
fn test() {
let env = Env::default();
let contract_id = env.register_contract(None, HelloContract);
let client = HelloContractClient::new(&env, &contract_id);
let words = client.hello(&symbol!("Dev"));
assert_eq!(words, vec![&env, symbol!("Hello"), symbol!("Dev"),]);
}
More examples are available at https://soroban.stellar.org/docs/category/examples.
Re-exports
pub use accounts::AccountId;
Modules
Accounts contains types for accessing accounts in the current ledger.
Data contains types for storing data for the currently executing contract.
Deploy contains types for deploying contracts.
Events contains types for publishing contract events.
Ledger contains types for retrieving information about the current ledger.
Logging contains types for logging debug events.
testutils
testutils
Utilities intended for use when testing.
Macros
Assert a condition and panic with the given error if it is false.
Import a contract from its WASM file, generating a constant holding the
contract file.
Import a contract from its WASM file, generating a client, types, and
constant holding the contract file.
Log a debug event.
Panic with the given error.
Structs
Bytes is a contiguous growable array type containing
u8
s.BytesN is a contiguous fixed-size array type containing
u8
s.Error type indicating a failure to convert some type to another; details
of the failed conversion will typically be written to the debug log.
Map is a ordered key-value dictionary.
Raw value of the Soroban smart contract platform that types can be converted
to and from for storing, or passing between contracts.
Symbol reprents strings up to 10 characters long with a
a-zA-Z0-9_
alphabet encoded into a 60-bit space between 10 characters long.Vec is a sequential and indexable growable collection type.
Enums
Address is all the types that can be the invoker of a contract.
Traits
Used to do conversions between values in the Soroban environment.
Used to do conversions between values in the Soroban environment.
Used to do conversions between values in the Soroban environment.
Used to do conversions between values in the Soroban environment.
Attribute Macros
Generates a client for a contract trait.
Generates conversions from the repr(u32) enum from/into a
Status
.Exports the publicly accessible functions to the Soroban environment.
Generates conversions from the struct/enum from/into a
RawVal
.