Smart contracts are event driven programs which cannot execute autonomously.
All the functions defined in a smart contract need to be triggered either by a transaction from the
external account or another smart contract to execute other than the functions that provide regular
services to users.
Some functions need to run asynchronously from regular user interaction, for example, to clean up
the expired records or make dividend payouts.
We require the automatic execution.
Such functions usually involve a time after which the function should start.
Users of a smart contract have no direct benefit from calling the accessor functions.
If a public blockchain is used, executing these functions costs extra monetary cost.
Some essential functions are expensive to execute.
Incentive execution design pattern provides a solution for the same where we incorporate a reward to
the caller of the contract function for invoking the execution.
Some of the forces which led to the creation of incentive execution pattern are completeness.
The regular services provided by a smart contract are supported by some accessorial functions, and
these accessorial functions have some cost associated with them.
By providing an incentive approach for those accessorial functions, we are reducing the burdens on
the users who are making the function calls.
Another force, which led to the creation of incentive execution pattern is about cost.
Execution of essential functions causes extra cost for the users, and by providing incentive for those
accessorial functions, we are helping the users to tackle the cost.
The solution provided by incentive execution pattern is related to provision of rewards for the callers
who are calling the functions defined in the smart contract for invoking the execution.
For example, we can send back a percentage of payout to the caller to reimburse the execution cost
for the transaction.
Some of the benefits for incentive execution pattern are related to completeness.
The execution of the Accessorial functions helps to complete the regular services provided by the Smart
contract, and users don't have any idea about the cost associated with the functions.
The second benefit provided by this design pattern is related to cost.
The users who spends extra to execute the essential functions are compensated by the reward associated
with the execution.
There are also some drawbacks related to incentive execution pattern.
One of the major drawback is related to Ungranted execution.
Execution cannot be guaranteed even with incentive.
Thus, another option is to be embedded with the logic of Accessorial functions into other regular functions
that users have the call to use the services.
One of the known implementations for incentive execution pattern is Regis.
Regis is an In-browser tool for developers to create smart contracts representing registries on Ethereum.
The functions that clean up the expired records provide incentive for users to execute them.
Another known implementation for incentive execution pattern is with Ethereum Alarm Clock, which is
a service provided by a smart contract running on Ethereum.
It facilitates scheduling function calls for a specified block in the future and provides incentive
for users to execute the scheduled function.
In this image, you can see the incentive execution pattern in action.
On the left hand side, we have onchain services and on the right hand side we have option services.
In the Onchain services, we have the factory contract who has different functions associated with it.
It could be that you have normal functions to calculate some logic processing for your business applications.
It could also be related to maintenance function where you are cleaning out the data or other extra
tokens related to the contract.
The user is present often who is going to call the functions.
All the function calls present inside Smart contract has to be triggered by some event or user.
The user here is receiving the incentive for calling up the maintenance function, although the user
is making the function call and paying in the transaction cost for the maintenance function.
In return, we are providing the tokens to the user where the users can exchange these tokens for monetary
value.
So in this way we are granting an incentive for users who are going to call the maintenance function
and they will receive some kind of reward by calling those functions.
Thus, we are creating an automated approach by providing incentive to the users.
So that was about the design patterns related to blockchain application.
If you take the blockchain as a fundamental building block of a large scale, decentralized software
system for effective use of blockchain, to this end, patterns are needed that show how to make good
use of the blockchain in the design of systems and applications.
In this course we have covered a pattern collection for blockchain based applications.
Our pattern collection includes three patterns about interaction between blockchain and external world
for data management patterns three security pattern and five contract structural patterns.
The Pattern collection provides an architectural guidance for developers and blockchain architects to
build applications on blockchain.
Some patterns are designed specifically for blockchain based applications, considering the unique properties
of blockchain, others are variants of existing software patterns applied to smart contracts.
You can use these design patterns to implement some specific blockchain platforms and also create real
world applications which could be integrated with enterprise solutions.
In the next lecture, we are going to conclude and summarize the course, and we are also going to give
you some key points which will help you to learn more with blockchain and use blockchain under your
enterprise or legacy systems.
If you have any queries, feel free to contact us at info at rate.
Weblogs.com.
Thank you.