marlowe_lang 0.3.2

experimental parser lib for Cardano Marlowe DSL
Documentation

An experimental implementation of the Marlowe language for Cardano smart contracts.

Its primary use-case is for creating smart contracts in Rust rather than directly using Marlowe, and instead be able to export the contracts into Marlowe programatically.

Grammars

This crate uses Pest.rs!

Example usage

use marlowe_lang::types::marlowe::*;
use marlowe_lang::{
deserialization::marlowe::deserialize,
serialization::marlowe::serialize,
};

let my_contract = Contract::When {
when: vec![
Some(PossiblyMerkleizedCase::Raw { 
case: Some(Action::Notify { 
notify_if: Some(Observation::True)
}), 
then: Some(Contract::Close) })
],
timeout: Some(Timeout::TimeParam("test".into())),
timeout_continuation: Some(Contract::Close.boxed()),
};

let serialized = serialize(my_contract);
let deserialized : Contract = deserialize(&serialized).unwrap().contract;
println!("{serialized}");

Where 'println!("{serialized}")' would output this:

When [ Case (Notify (True)) Close ] (TimeParam "test") Close