#soroban #env #host

bin+lib soroban-env-host

Soroban contract host environment

8 stable releases

20.2.2 Feb 13, 2024
20.1.1 Jan 24, 2024
20.0.2 Dec 20, 2023
20.0.0-rc2 Sep 18, 2023
0.0.3 Jul 29, 2022

#593 in Magic Beans

Download history 465/week @ 2023-11-03 444/week @ 2023-11-10 469/week @ 2023-11-17 644/week @ 2023-11-24 1341/week @ 2023-12-01 1074/week @ 2023-12-08 1349/week @ 2023-12-15 678/week @ 2023-12-22 497/week @ 2023-12-29 1143/week @ 2024-01-05 1497/week @ 2024-01-12 1338/week @ 2024-01-19 744/week @ 2024-01-26 1631/week @ 2024-02-02 1725/week @ 2024-02-09 1864/week @ 2024-02-16

6,078 downloads per month
Used in 40 crates (13 directly)


38K SLoC


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.


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.


~684K SLoC