To wrap my around what happens when I where, I tried to visualize it. In order to be able to show the interaction between two different systems generating transactions, I have a Generator A and Generator B.
In short:
- some dev writes and compiles a script (smart contract)
- that smart contract must be deployed, I suppose this is done by transacting it to the blockchain
- if a Tx generator (someone/something making and submitting transactions) wants to make a transaction, it needs the script, so it has to fetch it from a location the dev has put that script. The script (smart contract) itself is not on the blockchain. The generator also may need a redeemer and some context. The Tx can be tested locally before sending it to the network.
- if another Tx generator wants to use the same script, but one or more blocks later, it will need the datum (previous state of the script), which must be exposed by the previous generator somehow.
Inside the nodes:
- Txs are received and batched. The 'winning' node may validate all the Txs, reject the invalid ones and add the valid ones to a new block. If that's done, the whole block is broadcasted (and each node checks the validity of the block).
- validation of a Tx means that for each spending (E)UTxO the according address must 'approve' that transaction. The node validates the approvals by:
- normal address: the transaction is signed (by using the private key of the corresponding public address). Validation is done by checking the hash (generated with the private key) and validating the hash with the public key.
- script address: validation is done be executing the script giving the context (UTxOs), redeemer (some additional data added by the generator) and the datum (previous state of the script).
The blockchain itself only stores hashes (of script, datum etc), but not actual data (except for amount of Ada or other tokens), although there seems to be an option to add metadata (which, for the sake of clarity, don't take into account)
Am I understanding it correctly, or do I miss something (or many things :) )?
Thanks!