DEV Community

Cover image for Ethereum Blockchain platform: What are the restrictions of Smart Contracts and how to bypass them?
Diana Maltseva
Diana Maltseva

Posted on

Ethereum Blockchain platform: What are the restrictions of Smart Contracts and how to bypass them?

Smart contracts are an essential part of Ethereum network and its key peculiarity. Ethereum is a distributed Blockchain platform, for which programmers can create any computable function.

Solidity programming language was released exactly for that purpose. Like Java, PHP, Python and other popular programming languages, Solidity refers to the Turing-complete group. Also, its syntax is similar to one of JavaScript.

Thus, a smart contract is a program, compiled and recorded in Blockchain, with its own network address. With the help of this address, we can call smart contract code, while a smart contract will be run on one of the nodes, a part of Ethereum network.

Unlike traditional programs, smart contracts run in a distributed Ethereum network and have some distinctive peculiarities and restrictions

While Blockchain and Ethereum are at their peak, one can get somewhat of wrong expectations of what they’re supposed to do. Here are some cases that cannot be resolved with smart contracts.

1).Transaction initiated after a certain time

The main idea is that once initiated and recorded in Blockchain, a smart contract receives an address (along with the account’s one), and by using it we can call its code (public methods), as well as a smart contract, can perform certain actions.

Thus, to run a smart contract we always need an external impact, a call from a network member who has the appropriate launch rights.

We can set up a time check in a smart contract when we can call the method initiating the payment, but here the following problem arises: we can’t attach to the block timestamp within the contract, as it can be changed by the miner, and thus disrupt the contract or make its completion result unpredictable.

Also, this peculiarity can be used for intentional manipulation of smart contract behavior.

The only guaranteed way to make a deferred call of a smart contract is to link current time check to the number of generated blocks.

We know an average block generation speed and we can get the exact number of generated blocks (but an average block generation speed can vary).

We need to periodically run a smart contract: when the number of blocks is greater or equal to the specified value – the code will be executed.

Anyway, a smart contract can’t be launched on its own – for that we need a third-party service that will perform this operation at certain intervals.

Security note:

A smart contract must not send Ether during the activities completion as sending Ether can call another smart contract, which in turn may fail (for example, in the case of an incorrect address of Ether sending).

We will only record the number of Ether, which will take an address and implement a function, which translates the recorded amount of Ether to the address of the person who requested it. This pattern for smart contracts is called Pull Payment.

2). Transactions that occur at certain intervals

Here we face the same problem as in the previous example. A smart contract can’t be launched on its own, therefore, for the operation of periodic transactions we need an external service which will periodically run the smart contract code.

When the payment terms are met, a smart contract will transfer the funds to the previously written address.

For example, we want to create a smart contract that would do employees payroll once a month. We want to keep payout addresses, payment amount, and frequency within the smart contract. We will store payment periodicity in the number of blocks that must be created before wages.

The main goal of the smart contract is to keep the account of the created blocks from the beginning of smart contract work to the last payment, that will be updated once a day thanks to the launch of a third-party service.

Find out other effective ways to avoid smart contract restrictions, with intelligent schemes and illustrations.

Top comments (0)