Open greenhat opened 7 months ago
@bitwalker @bobbinth What do think?
I think that's a great idea! I'm guessing these would be different from rust-templates - right?
Regarding the name: I wonder if rust-examples
is too generic for this. Maybe something like contract-examples
would be better?
Btw, as the first example, we could probably put a Rust equivalent of BasicWallet in there.
I'm guessing these would be different from rust-templates - right?
Yes, that's correct. rust-templates
is intended to be a collection of templates for creating new Miden projects via the cargo miden new
command. So when user runs cargo miden new my_wallet
our extension downloads the folder from the repo and fills my_wallet
in the Cargo.toml
.
We provide a hello-world type of source code in the src/lib.rs
file, so in a way this is also an example, and I'm intended to use as an entry point into our ecosystem by heavy use of comments with links, extra source code, etc. But the new repo would be a collection of more complex examples that demonstrate how to use the Miden SDK in Rust.
Regarding the name: I wonder if
rust-examples
is too generic for this. Maybe something likecontract-examples
would be better?
Sounds great! contract
here is more specific and gives a better idea of what the examples are about. I was thinking that we would want to also put the non rollup specific examples in the future as well, but we can always create a new repo for that. Omitting the rust
prefix also makes sense, since the Rust is the only high-level language we support at the moment.
Btw, as the first example, we could probably put a Rust equivalent of BasicWallet in there.
Yep, my thoughts exactly, it would be the first one. Here is how BasicWallet Rust code curruntly looks like in tests - https://github.com/0xPolygonMiden/compiler/blob/581f639c6bf0bc8f6f508d970ee799f135b5798f/tests/rust-apps-wasm/wit-sdk/basic-wallet/src/lib.rs#L20-L29
It would look be a bit different for Alpha (no mod bindings
, explicit #[no_mangle]
attributes, etc.) since we will not have WIT support until the Beta release.
contract-examples repo created!
Here is how BasicWallet Rust code currently looks like in tests
Looks great! We may want to hide things like setting the allocator, panic handler etc. behind some macro. Similarly, we may want to shorten import paths - e.g., miden::tx::create_note
instead of bindings::miden::base::tx::create_note
. But no need to do this now - we can do it further down the road.
Besides the developer's guide/book it is essential to provide some examples of Miden projects (accounts, note scripts, etc.) written in Rust.
I'd like to create a separate repo for them (
rust-examples
?). So that users could clone the repository, run the examples, tinker with them and use them as a starting point in their own projects.The README in the new repo will provide an entry point starting with prerequisites, a list of examples, and how to build and run them. Plus, the links to the guide/book in the compiler repo.
Each example should be a standalone Rust project in its own folder. The folder should contain a
README.md
file with a brief description of the example, and instructions on how to build and run it.