PflowDSL: a little language

Pflow.xyz is an SDK for constructing petri-net smart contracts.

This article explores some features of the PflowDSL – which is an internal DSL to build models embedded in solidity code.

This is an excerpt from a demo model deployed to sepolia-optimism testnet. The above model contains every term that the language allows for, here’s a translation to petri-net terminology.

Some additional attributes of the language:

Declarative Style: Using the DSL is essentially describing the structure of the Petri net (places, transitions, arcs) rather than providing step-by-step instructions on how to build it.

Syntax:

Altogether, the Pflow SDK provides a way to enrich the syntax of your contract using another derived App-specific language.

Notice that in animation below -

The labels of the model can be used to visualize the state of the contract —also including a red/green coloring to indicate the ‘fireable-ness’ of the transition.

In conclusion

Pflow.xyz, with its internal PflowDSL, offers a novel and expressive approach to building Petri-net smart contracts. By enabling a declarative, functional, and data-centric construction of complex state machines, it enhances the clarity and maintainability of your Solidity code.

Learn more about how to make these models! Explore the solidity API: in the pflow.xyz docs. Or, view source code for the demo on sepolia-optimism testnet block explorer.