It’s important to note that this concept is difficult to scale, as the necessary scaling mechanisms were not envisaged at the outset.
So, how can this sort of construct come in useful? The best example is for adopting a social contract between two or more parties. This is where the term 'smart contract' comes from. The parties commit to an agreement and the terms for a scenario of how relations between them may develop, and they use a programming language to write them, so that when specific events occur they automatically result in predefined actions.
A classic example of this type of contract, described back in1996 by Nick Szabo, was that of a vending machine that always operates to a strict set of rules: a customer inserts money and selects what they want, and the machine dispenses the appropriate item. After the client inserts their money, they can’t change their mind and ask for a refund. In the case of a smart contract, the code becomes law, as it were: it cannot be contested; it will always be executed when the required conditions occur.
It should be pointed out here that the current implementations of smart contracts are essentially confined to a blockchain environment (below, we will speak about the Ethereum network). What does this mean? You can’t write a contract that will receive data from the external world (e.g. from weather information services) and implement their logic on this data. Of course, there are
oracles for that (they require a certain level of trust), or, for example, Microsoft is working on the concept of
cryptlets, though there is still a lot of room for improvement there.
Therefore, I will offer a different example of a smart contract that is completely confined to blockchain — a lottery that is absolutely honest and transparent. You send a transaction to the address of a smart contract, and it makes a decision based on a predefined logic (let us assume it is some sort of randomizer) about whether you win or not. If you win, then you receive the entire accumulated bank; if you lose, then your transaction is added to the bank for future players.
All the examples so far are relatively simple and not that interesting. If we take a serious approach to them, what benefits can be gained from smart contracts? Based on the concept of verifiable code execution, we can build systems that were unavailable before, or whose creation was highly complex (e.g. online polls).
Now I would like to show how this works in the case of Polys, online voting platform.
Let’s assume there’s a community that needs to reach a decision via a vote. This is an extremely important decision, and the community is not disposed to trust its individual members. How can this be done? One option is for the entire community to meet in one place and conduct the vote. The result of the voting will be visible to everybody, so trust will be ensured. But what if the community is large and its members live in different places? Online voting may be the next option. Let’s assume the community uses a service to gather its members’opinions. This method of voting works well, up to a point. But what is that point? How can the community control the operator and ensure transparency?
This is where smart contracts come in. We could introduce an online watcher role into the online voting process — that role would be filled by a trusted and respected member of that community; or, alternatively, that right can be given to all competing candidates. The watchers will receive the participants' votes and record them, keeping this process in sync with other watchers. After counting the votes using smart contracts, we arrive at a result that has been verified and approved by all parties. In that way, the geographically distributed community will be able to achieve a level of trust internally without resorting to a central body.
Yes, smart contracts are not readily scalable in their current implementations, as this scalability was not envisaged in their designs. However, even now heavy computations can be done outside of the smart contract environment, with only certain reference points being formalized — something that the parties can agree on beforehand — while ensuring the required operational speed for certain scenarios.