I know smart contract has 2 main feature.
- It has to be stored on the blockchain and each node has that copy
- Code has to be executed independently by every node
I can achieve the point one but I am unable to achieve point two.
Scenario
I have a scenario like this. I have a stream called products. on webapp when a user creates product, it calls backend api and backend creates create product_id as key and product will be like {name:'product_name'} and then backend calls multichain raw apis to save that product in products stream.
now whenever new product is saved in products stream my backend will execute particular code which exist in smartcontract stream. this code transfer few quantity of native asset to the user who created product. the reason I put the code in smartcontract stream so that anyone can see that code. but the execution of the code is still in our control which looks centralized opposed to the nature of blockchain.
can you please give me the idea of how can that code be executed by all the nodes in the network independently.