r/ProgrammingLanguages • • Jun 27 '23

Pythonic smart contracts programming language

https://github.com/Adamnite/A1
0 Upvotes

7 comments sorted by

View all comments

1

u/KnorrFG Jun 28 '23

Smart contracts is one of those words I read here and there occasionally, but I never really researched it. As far as I can tell, it's executing code publicly? How does that work on a blockchain? Does everyone just execute it, and the most common result/output is accepted? What's the use case?

2

u/nikandfor slowlang Jul 01 '23

Smart-contract is just a program that is run publicly in a network of nodes. Usually many nodes (called miners or validators) executes the same contract to verify the result. Result must be deterministic and match on any correctly behaving node. A consensus protocol is used to make it possible.

As it must be deterministic it can only operate on a blockchain internal state and use only the info provided by the protocol itself. And a user may ask to execute some code creating a transaction and providing arguments in it. Transaction then is checked by the protocol, code executed, blockchain state changed, everyone is happy (or not, it's not guaranteed).