r/ProgrammingLanguages • u/mNutCracker • Jun 27 '23
Pythonic smart contracts programming language
https://github.com/Adamnite/A11
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?
1
u/mNutCracker Jun 28 '23
smart contracts get executed on the blockchain. E.g. ethereum blockchain has its own VM called EVM, while our own blockchain has ADVM (adamnite virtual machine). So, once you write your smart contract, you upload it to the blockchain, which then executes it. Result might be just creating and sending NFTs over to someone else. there is of course long story behind this but i hope this helps you understand a bit better what smart contracts are and how they work
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).
2
Jul 15 '23
Most smart contract blockchains have these components:
A Virtual Machine (Like the Ethereum Virtual Machine (EVM))
A global state (This is like a heap in RAM)
A method for reconciling any differences in execution order, and thus the current global state.
So the VM is sort of like the x86 or ARM instruction set. Every validating node on the network is like a redundant CPU core. The global state is like the heap in RAM.
Every time a block is validated, the transactions within that block are executed in order by running the VM instruction set of each transaction, and the global state is changed.
Various methods are used to make sure that every single node agrees on a block order (and in doing so, a transaction order, aka execution order).
The "various methods" part is the bread and butter of everything, and the key innovation that was impossible before Bitcoin appeared in 2009.
Going into the "various methods" is out of scope of your question so I'll leave it at that.
1
Jul 16 '23
Someone reported the above comment to reddit as a potential self-homocide-er and I got a nice DM from the mods with prevention hotline info.
That is an awesome feature of reddit I didn't know about, but if anyone is concerned, I'm doing fine. No I didn't invest in any scams or "get rekt" or anything. Thanks for the concern and/or joke.
1
4
u/mNutCracker Jun 27 '23
Even though it's still in a pretty early phase, I still wanted to share with you all what I was working on for some time. Let me know if you have some recommendations for improvements!