would be really interested in a deep dive of how the smart contract like things work
I was recently working with state machines over Nostr for coordination between parties. The result is a distributed, event-driven, consistent state management protocol that can be used to model any process. It is also auditable, making it interesting for scientific and supply chain applications. Additionally, it enables the deployment of *smart contract-like* functionalities without the blockchain buzz or shitcoinery. I would love to hear your thoughts.
This project was originally inspired by a talk from nostr:npub1nyxg7ps82r86u0gunspsn8u8uuskh6sut77tulcqljue7rr7m6hquzh9ph during the last nostr:nprofile1qqsg8kve59yxyhpa9wupntesvnq0dgfd0k5g769jc6fzrua8gct36xgpzpmhxue69uhkumewwd68ytnrwghszrnhwden5te0dehhxtnvdakz7p5n66j 5.
It's also my first time using ngit 🔥
Discussion
Sure, we can delve deep into this, but to start, I can propose a simple state machine that uses an oracle and acts as a "smart contract" for a betting use case.
The state machine definition can include in its context the public keys of the participants and an oracle. Ideally, the oracle should also have a pubkey. In the context, you can also include other metadata required for the entire process, such as the date when the match that you are betting on starts and ends. With this context, both betting users are defined along with an oracle (or a series of them), and they can pay and scrow managed by the state machine. The state machine then initializes with a state like 'loaded'. When the match start date arrives, the state machine transitions to the 'started' state. After the oracle publishes the results and the match ends, the state machine computes the results and, based on that, determines the next state. For example, it could transition to 'finished' if there are no issues and one of the participants wins, or to 'dispute' if there is some kind of dispute, or to 'cancelled', etc. This is just a simple example, and there are certainly more nuances to consider, but at a high level, this is how a smart contract-like state machine can work.
The benefits of implementing this on Nostr with the concepts of my specification are that the state can be custodied by multiple parties acting as 'watchtowers', and every transition is auditable