0

When we get the execution result of a function in the smart contract, has this result been verified by the entire network? In other words, when the user obtains the execution result of the smart contract function, whether the result of the function has been verified by other nodes.

Hope you can give me some help, thanks!

1

If you are using a transaction (and not a local call) you can trust the result. Or if you use a local call you can trust it if you trust the node you are using.

A transaction to produce results it needs to be mined by a miner. When a miner mines it (and solves the PoW puzzle successfully) he broadcasts the result and other nodes will verify it. If it's valid they accept it and broadcast it forward, otherwise it's ignored and it basically just dies away. The entire network verifies the result at some point, but may take a while due to latency issues.

However this does not mean that the result (inside a block) would necessarily stay as part of the canonical chain. The network's consensus mechanisms may still decide to discard the block, but that doesn't mean that its results would be invalid - it was just unlucky.

5
  • Thank you for your reply! Does it mean that every time a smart contract is called, we can only get the result of the call after more than half of the nodes in the entire network have verified the authenticity?
    – wei wang
    Dec 9 '20 at 8:09
  • No, you can get the result as soon as it's mined in a block. Dec 9 '20 at 8:34
  • Does it mean that when I get the result of the smart contract function call, because the result has not been verified, the result may theoretically be false.
    – wei wang
    Dec 9 '20 at 8:36
  • An interesting question. I guess in theory it could be false. But in that case the miner loses the mining reward. And in any case all immediate results should be treated with caution as the block may get dropped in near future - so in theory you always need to wait some amount of blocks to be sure that the block stays Dec 9 '20 at 8:38
  • Thank you for your reply, it has benefited me a lot.
    – wei wang
    Dec 9 '20 at 8:40

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.