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 --tmuxRun tests with:
RUSTFLAGS="-Zmacro-backtrace" RUST_BACKTRACE=full cargo test --release -- --nocaptureThe --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 updateInstall 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§
- Array
Info - Function
Binding - Input
Param - Mapping
Binding - Member
Def - Output
Type - Shared
Interpreter State - Simplified
Bindings - Struct
Binding
Traits§
- From
Value - Converts SnarkVM types to Rust types.
- Interpreter
Extensions - 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