26 releases (stable)

new 22.1.0 Nov 18, 2024
22.0.0-rc.3 Oct 22, 2024
21.2.2 Oct 24, 2024
21.2.0 Jul 16, 2024
0.0.3 Jul 29, 2022

#261 in Magic Beans

Download history 4059/week @ 2024-07-30 2174/week @ 2024-08-06 1787/week @ 2024-08-13 2872/week @ 2024-08-20 3438/week @ 2024-08-27 2078/week @ 2024-09-03 2429/week @ 2024-09-10 1950/week @ 2024-09-17 2534/week @ 2024-09-24 2716/week @ 2024-10-01 2586/week @ 2024-10-08 1657/week @ 2024-10-15 2325/week @ 2024-10-22 2942/week @ 2024-10-29 4009/week @ 2024-11-05 4129/week @ 2024-11-12

13,748 downloads per month
Used in 61 crates (14 directly)

Apache-2.0

2MB
47K SLoC

rs-soroban-env

Rust contract-environment interface and (optional) host implementation for Soroban.

The soroban-env-common crate contains elements of the shared environment-interface between smart contract guest and host: the Env trait that defines the set of available environment functions as well as the Val type that can pass back and forth through the WASM calling convention. Additionally small wrappers around subtypes of Val are included: Object, Symbol, Error, etc.

The soroban-env-guest crate contains the guest-side stub implementation of the environment interface called Guest dependent on extern fns provided by the host implementation. This can be used in a WASM runtime that provides the extern fns.

The soroban-env-host crate contains the host-side full implementation of the environment interface called Host. This can be used either in the real blockchain host, or for local testing in the SDK.


lib.rs:

This crate mainly exists to provide the Soroban [Host] type, which is the implementation of the [Env] interface between guest contract code and the host it runs within.

This crate also re-exports all of the content of the [soroban_env_common] crate for use by host (or contract local-testing) code. Most of the type and module definitions visible here are actually defined in the common crate.

When unit-testing contracts natively (not using wasm), developers may also wish to enable the "testutils" feature, which enables an interface on [Host] for registering other test contracts by ID.

The [Host] type provides some facilities above and beyond just the [Env] trait, including:

  • The [budget] module which is responsible for measuring and limiting execution costs in terms of CPU and memory.
  • The [storage] module which is responsible for providing an interface between contracts and their durable storage.

Dependencies

~20–48MB
~791K SLoC