Crate leo_bindings

Crate leo_bindings 

Source
Expand description

§leo-bindings

Rust bindings for interacting with Leo programs.

§Documentation

Documentation is available at: https://henrikkv.github.io/leo-bindings/leo_bindings

§Deploying to devnet

Start the devnet with:

leo devnet --snarkos-features test_network --clear-storage --yes --consensus-heights 0,1,2,3,4,5,6,7,8,9 --snarkos ~/.cargo/bin/snarkos --tmux

Run tests with:

RUSTFLAGS="-Zmacro-backtrace" RUST_BACKTRACE=full cargo test --release -- --nocapture

The --release flag slows down compile times and speeds up proving times. It is not needed for the interpreter.

§Generating bindings

§Quick setup with CLI

leo-bindings update

Install leo-bindings with cargo install --path . and run leo-bindings update in the top level of the Leo project. Run again if program.json changes to update the generated files. Keep this workspace as it was generated, and import it in another package.

The generated bindings are available at projectname_bindings::projectname::* in rust. See how to create accounts and use credits.aleo in the token example. The trait ProjectnameAleo<N> is implemented by network::ProjectnameNetwork<N> and interpreter::ProjectnameInterpreter. Type aliases ProjectnameTestnet, ProjectnameMainnet, ProjectnameCanary, and ProjectnameInterpreter are available. See how to use the trait in the dev example.

cargo doc --open can be used to explore the generated code. credits.aleo documentation

§Generated Crates

The credits bindings can be imported to interact with credits.aleo.

  • credits_bindings - leo-bindings-credits/

The documentation from the examples show what the macro expands to.

  • token_bindings - examples/token/leo/
  • dev_bindings - examples/dev/leo/
  • delegated_proving_test_bindings - examples/delegated/leo/

Re-exports§

pub use utils::DelegatedProvingConfig;
pub use aleo_std;
pub use anyhow;
pub use http;
pub use indexmap;
pub use leo_ast;
pub use leo_errors;
pub use leo_interpreter;
pub use leo_package;
pub use leo_parser;
pub use leo_span;
pub use rand;
pub use serde_json;
pub use snarkvm;
pub use ureq;
pub use walkdir;

Modules§

delegated
deployment_summary
generator
generator_interpreter
interpreter_cheats
shared_interpreter
signature
types
utils

Macros§

generate_bindings
Generates Rust bindings for a Leo program.

Structs§

ArrayInfo
FunctionBinding
InputParam
MappingBinding
MemberDef
OutputType
SharedInterpreterState
SimplifiedBindings
StructBinding

Traits§

FromValue
Converts SnarkVM types to Rust types.
InterpreterExtensions
ToValue
Converts Rust types to SnarkVM types.

Functions§

generate_program_module
generate_records
generate_structs
get_rust_type
get_rust_type_with_network
get_signatures
initialize_shared_interpreter
parse_array_type
print_deployment_stats
Pretty‑print deployment statistics without a table, using the same UI conventions as print_deployment_plan.
print_execution_stats
Pretty‑print execution statistics without a table, using the same UI conventions as print_deployment_plan.
with_shared_interpreter