From 3bef7fa636168e40752f0432f13f22080c063060 Mon Sep 17 00:00:00 2001 From: Artem Chystiakov Date: Thu, 19 Mar 2026 13:13:10 +0200 Subject: [PATCH] fix example --- README.md | 3 +- examples/basic/Cargo.lock | 28 ++++++--- examples/basic/Cargo.toml | 4 +- examples/basic/README.md | 59 +++++++++++++++++++ examples/basic/Simplex.toml | 2 +- .../tests/{draft_test.rs => example_test.rs} | 6 +- 6 files changed, 87 insertions(+), 15 deletions(-) create mode 100644 examples/basic/README.md rename examples/basic/tests/{draft_test.rs => example_test.rs} (91%) diff --git a/README.md b/README.md index 1ffdc83..51b5429 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,8 @@ Simplex is a Rust-based, comprehensive development framework for [Simplicity](ht ## Installation ```bash -curl -L https://smplx.simplicity-lang.org | bash && simplexup +curl -L https://smplx.simplicity-lang.org | bash +simplexup ``` See the [simplexup manual](simplexup/README.md) for more details. diff --git a/examples/basic/Cargo.lock b/examples/basic/Cargo.lock index 6600e58..9248952 100644 --- a/examples/basic/Cargo.lock +++ b/examples/basic/Cargo.lock @@ -393,14 +393,6 @@ dependencies = [ "crypto-common", ] -[[package]] -name = "draft_example" -version = "0.1.0" -dependencies = [ - "anyhow", - "smplx-std", -] - [[package]] name = "dyn-clone" version = "1.0.20" @@ -1161,6 +1153,14 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +[[package]] +name = "simplex_example" +version = "0.1.0" +dependencies = [ + "anyhow", + "smplx-std", +] + [[package]] name = "simplicity-lang" version = "0.7.0" @@ -1210,6 +1210,8 @@ dependencies = [ [[package]] name = "smplx-build" version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "405636c8a7d0d9a87822faddc04215bb7919d590cf3dff78a1495458e311103d" dependencies = [ "glob", "globwalk", @@ -1227,6 +1229,8 @@ dependencies = [ [[package]] name = "smplx-macros" version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ec9275ef5dff18aa65009f2ac42892f5cf0d409746da57eae842a7bee1c5a20" dependencies = [ "smplx-build", "smplx-test", @@ -1236,6 +1240,8 @@ dependencies = [ [[package]] name = "smplx-regtest" version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "407bc1cb6dddd30a5fc7859a129db39d3b021ecb1db14db9d0d287e5b26cf7c3" dependencies = [ "electrsd", "serde", @@ -1247,6 +1253,8 @@ dependencies = [ [[package]] name = "smplx-sdk" version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29977f9989db6b89180fd1d7ce4b57820f1bd93bbc42b9e215db81f42602102f" dependencies = [ "bip39", "bitcoin_hashes", @@ -1265,6 +1273,8 @@ dependencies = [ [[package]] name = "smplx-std" version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25684233ca96852fdc72ad1afe732b77582e1ab65ac4093eb594e1f8e25fc567" dependencies = [ "either", "serde", @@ -1277,6 +1287,8 @@ dependencies = [ [[package]] name = "smplx-test" version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bcf316dc5fe2a283708006ca6f28c361ed81347504e0bcf75ba6b551b54e7fd" dependencies = [ "electrsd", "proc-macro2", diff --git a/examples/basic/Cargo.toml b/examples/basic/Cargo.toml index d7251fa..f3f57fd 100644 --- a/examples/basic/Cargo.toml +++ b/examples/basic/Cargo.toml @@ -1,10 +1,10 @@ [package] -name = "draft_example" +name = "simplex_example" edition = "2024" rust-version = "1.91.0" version = "0.1.0" [dependencies] -smplx-std = { path = "../../crates/simplex" } +smplx-std = { version = "0.0.1" } anyhow = { version = "1.0.101" } diff --git a/examples/basic/README.md b/examples/basic/README.md new file mode 100644 index 0000000..cfaf573 --- /dev/null +++ b/examples/basic/README.md @@ -0,0 +1,59 @@ +# Basic Simplex Example + +This is an example project to get started with Simplex. The project assumes that the framework has already been successfully installed via [`simplexup`](../../simplexup/README.md). + +## Overview + +The repository structure is the following: + +```ml +root +├── simf — Simplicity smart contracts source directory +├── src — The project's Rust code (witness and transaction builders) +│ └── artifacts — Simplicity artifacts generated by Simplex (gitignored) +├── tests — Simplex integration tests directory +├── Cargo.toml — The project's Rust configuration +└── Simplex.toml — The project's Simplex configuration +``` + +### Build + +In order to see Simplex in action, first run the build command to generate Simplicity artifacts: + +```bash +simplex build +``` + +You will see that Simplex has generated a new `artifacts` directory in the `src` directory. Think of these artifacts as "rust typization" helpers for individual simplicity smart contracts in the project. + +Please note that this new module gets declared in the `lib.rs` file. + +### Test + +Once the artifacts are generated, let's run Simplex integration test `example_test.rs`: + +```bash +simplex test run --tests "example_test" --nocapture +``` + +You will see the test passing. + +Under the hood, Simplex spins up a local Electrs + Elements regtest, establishes the connection, prefunds the signer specified in the `simplex.toml`, and runs the test marked via macros `#[simplex::test]`. + +You are free to experiment with the other simplicity contracts provided in the example. + +### Regtest + +If you wish to keep the blockchain's state between the integration tests, you will need to spin un a local regest separately: + +```bash +simplex regtest +``` + +This command sets up the standalone nodes that can be connected to via simplex configuration. + +Update the `simplex.toml` file with the necessary URLs and credentials, then run the test again. You will see that the state gets preserved. + +## Disclaimer + +GLHF! diff --git a/examples/basic/Simplex.toml b/examples/basic/Simplex.toml index b571f40..b6e701e 100644 --- a/examples/basic/Simplex.toml +++ b/examples/basic/Simplex.toml @@ -1,4 +1,4 @@ -# TEST CONFIG +# DEFAULT CONFIG # [build] # src_dir = "./simf" diff --git a/examples/basic/tests/draft_test.rs b/examples/basic/tests/example_test.rs similarity index 91% rename from examples/basic/tests/draft_test.rs rename to examples/basic/tests/example_test.rs index a007cbc..0291e35 100644 --- a/examples/basic/tests/draft_test.rs +++ b/examples/basic/tests/example_test.rs @@ -6,8 +6,8 @@ use simplex::transaction::{ }; use simplex::utils::tr_unspendable_key; -use draft_example::artifacts::p2pk::P2pkProgram; -use draft_example::artifacts::p2pk::derived_p2pk::{P2pkArguments, P2pkWitness}; +use simplex_example::artifacts::p2pk::P2pkProgram; +use simplex_example::artifacts::p2pk::derived_p2pk::{P2pkArguments, P2pkWitness}; fn get_p2pk(context: &simplex::TestContext) -> (P2pkProgram, Script) { let signer = context.get_signer(); @@ -17,7 +17,7 @@ fn get_p2pk(context: &simplex::TestContext) -> (P2pkProgram, Script) { }; let p2pk = P2pkProgram::new(tr_unspendable_key(), arguments); - let p2pk_script = p2pk.get_program().get_script_pubkey(*context.get_network()).unwrap(); + let p2pk_script = p2pk.get_program().get_script_pubkey(context.get_network()).unwrap(); (p2pk, p2pk_script) }