0

I need to code something quite complex compared to my experience. Just for academic purpose, I'm supposed to have a lightweight blockchain that connects a group of nodes; in this blockchain every node ask and send informations to each other through a smart contract. By ignoring the problem of how to set up this kind of blockchain, my only duty is to program a test code for the smart contract and the Client (using Python) that will be run by every node.

My problems start when i have to ask informations to a node from the smart contract: Let's suppose that our contract has a function "getDataFrom(address)" which can be called by a node when he needs to get specific data from another node. How will this code be structured? The only thing that comes to my mind is to make a transaction from the smart contract to the address, but even in this case how much ETH should be used? Then, if this approach is correct, i think that in the Client code there will be a function that handles a received transaction and then calls a "returnData(data)" from the smart contract, right?

I don't know if that's correct or not, so please i'd be very grateful if someone can help me. Another thing i wanted to ask, is if exists some way to make the Client functions usable from the Smart Contract without sending a generic transaction, i think that this would stop all of my problems.

0
0

A smart-contract is a passive software object that, on its own initiative, cannot request anything from anyone. A smart-contract is activated by a transaction sent to its address. The smart-contract cannot directly request anything on the Node, but it can emit an Event containing the request required for the smart-contract. The corresponding Node catch the Event and, having processed it, sends a transaction with the necessary data to the smart-contract.

For detail see https://stackoverflow.com/a/65528527/6459192 (а more complex case is described there, when an additional proxy contract is used for the request, but the principle, I think, is clear)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.