Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
28 changes: 20 additions & 8 deletions examples/basic/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions examples/basic/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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" }
59 changes: 59 additions & 0 deletions examples/basic/README.md
Original file line number Diff line number Diff line change
@@ -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!
2 changes: 1 addition & 1 deletion examples/basic/Simplex.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# TEST CONFIG
# DEFAULT CONFIG

# [build]
# src_dir = "./simf"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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)
}
Expand Down