Crate linera_sdk

Source
Expand description

This module provides an SDK for developing Linera applications using Rust.

A Linera application consists of two WebAssembly binaries: a contract and a service. Both binaries have access to the same application and chain specific storage. The service only has read-only access, while the contract can write to it. The storage should be used to store the application state, which is persisted across blocks. The state can be a custom type that uses linera-views, a framework that allows lazily loading selected parts of the state. This is useful if the application’s state is large and doesn’t need to be loaded in its entirety for every execution.

The contract binary should create a type to implement the Contract trait. The type can store the ContractRuntime and the state, and must have its implementation exported by using the contract! macro.

The service binary should create a type to implement the Service trait. The type can store the ServiceRuntime and the state, and must have its implementation exported by using the service! macro.

§Examples

The examples directory contains some example applications.

Re-exports§

pub use self::contract::ContractRuntime;
pub use self::service::ServiceRuntime;
pub use self::views::KeyValueStore;
pub use self::views::ViewStorageContext;
pub use bcs;
pub use serde_json;

Modules§

abi
This module defines the notion of Application Binary Interface (ABI) for Linera applications across Wasm and native architectures.
abis
Common ABIs that may have multiple implementations.
contract
Types and macros useful for writing an application contract.
ethereum
Support for Linera applications that interact with Ethereum or other EVM contracts.
graphql
GraphQL traits for generating interfaces into applications.
http
Types used when performing HTTP requests.
linera_base_types
Types reexported from linera_base.
service
Types and macros useful for writing an application service.
test
Helper types for writing integration tests for WebAssembly applications.
util
Module with helper types and functions used by the SDK.
views
Helper types for using linera_views to store application state.

Macros§

contract
Declares an implementation of the Contract trait, exporting it from the Wasm module.
ensure
A macro for asserting that a condition is true, returning an error if it is not.
service
Declares an implementation of the Service trait, exporting it from the Wasm module.

Structs§

ContractLogger
A logger that uses the system API for contracts.
DataBlobHash
Hash of a data blob.
Resources
Resources that an application may spend during the execution of transaction or an application call.
SendMessageRequest
A request to send a message.
ServiceLogger
A logger that uses the system API for services.

Traits§

Contract
The contract interface of a Linera application.
FromBcsBytes
Extension trait to deserialize a type from a vector of bytes using bcs.
Service
The service interface of a Linera application.
ToBcsBytes
Extension trait to serialize a type into a vector of bytes using bcs.