Expand description
Stylus WASM smart contract runtime.
Provides the execution pipeline for Stylus programs: WASM compilation and caching, ink metering, host I/O functions, and EVM interop.
Re-exports§
pub use cache::InitCache;pub use config::CompileConfig;pub use config::StylusConfig;pub use error::MaybeEscape;pub use error::StylusError;pub use evm_api::EvmApi;pub use evm_api_impl::StylusEvmApi;pub use ink::Gas;pub use ink::Ink;pub use meter::MachineMeter;pub use meter::MeteredMachine;pub use meter::STYLUS_ENTRY_POINT;pub use native::NativeInstance;pub use native::compile_module;pub use run::RunProgram;
Modules§
- cache
- config
- env
- error
- Error types raised by the Stylus runtime.
- evm_api
- evm_
api_ impl - host
- ink
- meter
- middleware
- multi_
gas - Per-host-call multi-gas dimension assignment for Stylus execution: each host
op contributes the same per-dimension gas as the equivalent EVM opcode.
Framework gas (host ink, the EVM-API surcharge, the per-call storage cache)
is left undimensioned here and falls into the
WasmComputationresidual. - native
- pricing
- run
- trace
- Host-I/O trace buffer for
debug_traceTransactionon Stylus programs.
Structs§
- Stylus
Root - A parsed Stylus root program. The on-chain layout is
[0xEF, 0xF0, 0x02, dict, decompressed_len(4, big-endian), addr×20...], where each 20-byte address points to a fragment holding part of the compressed WASM.
Constants§
- STYLUS_
DISCRIMINANT - Prefix bytes that identify a Stylus WASM program in contract bytecode.
- STYLUS_
FRAGMENT_ DISCRIMINANT - Fragment prefix:
[0xEF, 0xF0, 0x01]. - STYLUS_
ROOT_ DISCRIMINANT - Root Stylus program prefix:
[0xEF, 0xF0, 0x02].
Functions§
- activate_
program - Activate a Stylus program.
- compress_
classic_ program_ code - Compress raw WASM into classic Stylus contract bytecode.
- decompress_
wasm - Decompress a Stylus WASM program from its contract bytecode.
- fragment_
read_ gas - Gas charged for reading one fragment of
code_sizebytes during activation, matchingfragmentReadGasCost: a cold (or warm) account access plus the per-word copy cost. The fragment-read charger uses this for both the preflight affordability check (against the max code size) and the actual per-fragment charge. - get_
wasm_ from_ root - Reconstruct the WASM of a root Stylus program: read each fragment’s deployed
bytecode via
read_code, strip its prefix, concatenate the compressed payloads, and decompress with the root’s dictionary. Whenenforceis set (i.e. activation), the decompressed-length and fragment-count limits are applied; reads otherwise only reconstruct the program. - is_
stylus_ classic - Returns
trueif the bytecode is a classic Stylus program ([0xEF, 0xF0, 0x00, ...]). - is_
stylus_ component - Returns
trueif the bytecode is a deployable Stylus component: a classic or root program, or (at the contract-limit version) a fragment. Used to permit storing such code despite its0xEFprefix, mirroringIsStylusComponentPrefix. - is_
stylus_ deployable - Returns
trueif the bytecode is a deployable Stylus program. - is_
stylus_ fragment - Returns
trueif the bytecode is a Stylus fragment ([0xEF, 0xF0, 0x01, ...]). - is_
stylus_ program - Returns
trueif the bytecode is a Stylus WASM program. - is_
stylus_ root - Returns
trueif the bytecode is a Stylus root program ([0xEF, 0xF0, 0x02, ...]). - is_
stylus_ runnable - Returns
trueif the bytecode is a runnable Stylus program: a classic or a root program (a fragment is not runnable on its own). Root code can only have been deployed at the contract-limit version, so no version gate is needed here. - strip_
stylus_ prefix - Strips the 4-byte Stylus prefix from contract bytecode.