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 = BytesN::from_array(&env, &[0; 32]);
    env.register_contract(&contract_id, 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.

Modules

Deploy contains types for deploying contracts.

Iterators for use with collections like Map, [Set], Vec.

Serialize and deserialize values to and from Bytes.

testutilstestutils

Utilities intended for use when testing.

Macros

Create a BigInt with an integer, hex, bits, or an array.

Create a Bytes with an array, or an integer or hex literal.

Import a contract from its WASM file.

Create a Map with the given key-value pairs.

Create a Symbol with the given string.

Create a Vec with the given items.

Structs

Account references a Stellar account and provides access to information about the account, such as its thresholds and signers.

BigInt is an arbitrary sized signed integer.

Bytes is a contiguous growable array type containing u8s.

BytesN is a contiguous fixed-size array type containing u8s.

ContractData stores and retrieves data for the currently executing contract.

Error type indicating a failure to convert some type to another; details of the failed conversion will typically be written to the debug log.

The Env type provides access to the environment the contract is executing within.

Events publishes events for the currently executing contract.

Ledger retrieves information about the current ledger.

Map is a 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 contiguous growable array type.

Enums

Sign is the sign of a BigInt.

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.

Type Definitions

BinaryDeprecated
FixedBinaryDeprecated

Attribute Macros

Exports the publicly accessible functions in the implementation.

Generates conversions from the struct/enum from/into a RawVal.