Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

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.

Overview

The repository structure is the following:

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 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:

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 test "basic_test" inside basic_test.rs:

simplex test basic_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].

Check out confidential_test.rs to learn how to issue and spend confidential UTXOs!

Regtest

If you wish to keep the blockchain's state between the tests, you will need to spin un a local regest separately:

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!