# How to make smart contracts work in a small network?

Suppose we have a small computer network, there are 30 random people who have provided their computers to perform any computational tasks on them. Let's call these 30 computers nodes. We can access any of these 30 nodes arbitrarily, but by the condition of the problem, we do not know whether the node is honest. That is, we can not guarantee that the node will execute exactly the f (x) that we send to it, or that the node will certainly give us the correct answer.

Also, we have, by condition, A and B that want to conclude a smart contract with each other. A smart contract is a code (usually a small one, 15-25 lines long), whose body will certainly execute when a certain condition is set in the code.

In our case, the smart contract says that if event E1 occurs, B will pay A from its account, and if event E2 occurs, then A will pay B (how exactly will the payment in details not be discussed, it will occur within this network, using conventional cryptocurrency algorithms in the classic blockchain, for example).

The problem is that neither A nor B can guarantee if they entrust the execution of the smart contract code to a random node from our network that it will be executed correctly. One node can execute the received code in reverse or not execute at all. So which cryptographic algorithm A and B can use to ensure (statistically) the correct execution of the concluded smart contract? As already mentioned, they can use the services of any of the 30 nodes as you like.

I thought about dividing the smart contract into small parts and dividing them one by one into each of the 30 nodes, but how would this help if some dishonest nodes still execute their code incorrectly? We can easily find a dishonest node and exclude it, but a smart contract must be executed correctly the first time - that is, certainly, and not after the selection of honest nodes. When one of the nodes behaves incorrectly, the entire smart contract will already be executed incorrectly.

One approach is to use a system like Ethereum, Truebit, or their successors. In Ethereum, every node checks that the smart contract was executed correctly. In Truebit, there is a sophisticated way to assign the contract to untrusted nodes and check that they executed it correctly.

Another approach is to use trusted hardware, like SGX.

There are probably other options as well.

I suggest reading up on those systems. There's lots written on them.

• I know that in the Ethereum every node verifies the correctness of the execution of the smart contract. But I do not understand to the end. What if the first node that gets a smart contract just executes it incorrectly? I know that my question is trivial. May 25, 2018 at 16:19
• The node found an incorrectly executed smart contract. What does she do next? Maybe the point is that the node that does the smart contract incorrectly can not harm anyone? May 25, 2018 at 16:27
• @DegegneDow., this site doesn't work well for follow-up questions in the comments or for interactive back-and-forth. I suggest that you spend some time reading about how Ethereum handles that, as that's a pretty basic element of Ethereum and should be explained in many places and there's not much point in repeating it here. If you're still confused, head over to Ethereum Stack Exchange and ask there about it.
– D.W.
May 25, 2018 at 16:57