Skip to content

cartesi/state-fold

Repository files navigation

State Fold Picture

State Fold

A collection of libraries with GRPC server and client for reading custom-defined state at any position on the Ethereum blockchain accessed via any Ethereum JSON-RPC API provider.

Description

Whether you want to reach for historical blocks / states or subscribe to get the latest blocks / states as they are added to the network, both of these use-cases were considered when designing State Fold.

State Fold Server Library has methods to read state and analogous ones to read blocks. You can read in bulk and way back in the history, but also subscribe to receive new states, or analogously blocks, as they get added on the blockchain.

The structural definition of state is up to the developer that is using this library. The type definition propagates all the way up to the server and client libraries, i.e. to the API schema. Design of this approach uses DRY attitude. That means we just want you to write the type once and make everything generic so that you get the server for no extra effort.

Developer also defines the behavior of syncing and folding to read state, where sync means calculating state based on hard-coded initial state and fold means calculating state based on previous state.

Requirements

Installation

Add one or more State Fold crates into your Cargo.toml like so:

[dependencies]
# Common crate for all other crates
eth-state-fold-types = { version = "0.7" }

# Libraries for state-fold core logic
eth-block-history = { version = "0.7" }
eth-state-fold = { version = "0.7" }

# Common crate for server/client
eth-state-server-common = { version = "0.7", features = ["server"] }

# Libraries for state-fold GRPC interfaces
eth-state-server-lib = { version = "0.7" }
eth-state-client-lib = { version = "0.7" }

Usage

Local development environment

Build all targets of all crates:

cargo build --all-targets --all-features

Run all tests:

cargo test

Format code:

cargo fmt --all

Documentation

License

The library is licensed under Apache-2.0.