Page 1 of 8

Advances in Social Sciences Research Journal – Vol. 8, No. 3

Publication Date: March 25, 2021

DOI:10.14738/assrj.83.9911. Sabbagh, P. (2021). Proposing an Optimized Cost-Effective Data Carrier Mechanism for Smart Contracts and Transactions in

Blockchain with ACO Algorithm. Advances in Social Sciences Research Journal, 8(3) 579-586.

Proposing an Optimized Cost-Effective Data Carrier Mechanism for

Smart Contracts and Transactions in Blockchain with ACO

Algorithm

Dr. Parisa Sabbagh

Ph.D. on Big Data Management, Department of Management & Innovation Systems

University of Salerno Fisciano, Italy

ABSTRACT

In this article, a new optimal cost-effective data carrier architecture

for smart contracts in the blockchain-enabled IoT environment

proposed. This method requires communication with external off- chain data. Three steps consist of this model such as Mission

Manager, Task Publisher, and Worker which formulated with the ACO

algorithm. Based on this method, some of the best solutions for

filtering smart contract events and decoding event logs to fit different

requirements are presented adequately. The proposed system is

designed to minimize contract deployment costs and monitor

contract events without subscribing to any filter at the Ethereum

node. In the evaluation, we show that it will save about 21USD

deployment costs for average by our data carrier system.

Keywords: Blockchain, Internet of Things (IoT), Smart Contract, Off-Chain

Data, Ant Colony Algorithm (ACO).

INTRODUCTION

Blockchain technology has shown promising application prospects which is a distributed means

of securing data in a way that is auditable, immutable, and fault-resistant. Blockchain introduced

in 2009 [1] which debut of Bitcoin which served a functional proof-of-concept and removed any

necessary access for trusted third parties in the transaction with any strange people in the world.

These transactions need to validate from banks, but Blockchains carried out by a network peer.

Blockchains are based on trust which created in a trust-less platform to act as rules. When it

created, Bitcoin had some faults which occurred by heavy cost on computation, power, and

memory for every full participant in a wide network of peers. As of May 2018, the Bitcoin ledger

size surpassed 196 GB [2]. Also, other Bitcoin limits are well-documented in works such as [3-5].

These works and references notice that Bitcoin is very slow to process any transactions and it is

not scalable when participants grow and may still susceptible to a number of different attacks.

On the other hand, the number of smart devices with wireless communication capabilities has

risen to a scale of billions [6]. These kinds of growth to occur the manufacturing costs of

electronics and will develop a smart device with sensors connected to the Internet. These sensors

have a lot of tasks by using the Internet, but these sensors nodes which defined and determined

in smart devices have some limitations such as processing power, preventing them from running

Page 2 of 8

Advances in Social Sciences Research Journal (ASSRJ) Vol. 8, Issue 3, March-2021

Services for Science and Education – United Kingdom

CPU intensive tasks locally, privacy policy and security. Because of this limitation, these sensor

nodes can offload their processing tasks to run in a cloud area server which can be faced with

some other challenges such as delay and low access and response time to users. This challenge

can be solved by defining some edge devices as an intermediary between the end-users nodes

which use smart devices and cloud. These edge devices can bring the local connection to the

smart devices and challenges such as delay and low access and respond time to users run in local

when other tasks are offloading to the cloud. For solving this problem, a cloud and edge

computing model should be improved to optimize delay and low access and respond to time to

users. “Blocks” on the blockchain are made up of digital pieces of information. Specifically, they

have three parts:

1) Blocks store information about transactions like the date, time, and dollar amount of the

most recent purchase.

2) Blocks store information about who is participating in transactions.

3) Blocks store information that distinguishes them from other blocks.

LITERATURE REVIEW

The name “blockchain” itself refers to the structure of the block chain’s data can be thought of as

an immutable chain of events. Data, mostly in the form of transactions, are grouped together in a

block. This block is then packaged with a reference to the previous block, which contains a

reference to the block before that, etc. block chain is “distributed” because every participant in

the network holds a copy of this append-only ledger. All participants, or peers, must agree on the

state of the ledger and unauthorized changes to that ledger must be reasonably detectable. In

reality, blockchain technology requires (1) a distributed ledger among peers, (2) a consensus

protocol to ensure that all peers have the same copy, and (3) a cryptographic infrastructure.

Every other detail is determined by the desired application [1].

Smart contract enabled by Ethereum blockchain technology which is a contract implemented,

deployed and executed within EVM. The smart contract is a set of commitments that are defined

in digital form, including the agreement on how contract participants shall fulfill these

commitments. The smart contract can be considered as a programmable application consisting

of stock management functions performed online. The user can create an instance of the contract

and invoke functions to view and update the contract data as well as execute some logic [7].

EVM is a virtual machine and runtime environment for executing coding on Ethereum smart

contracts. This is the basic consensus mechanism for the atrium. It is sandboxed and completely

isolated from the network, file system or other processes of the host computer system. The EVM

implementation runs on the Ethereum node on the network and executes the same instructions

[8].

Some recent methods in blockchain proposed a new idea for smart contracts. For example in [9],

a new elastic and cost-effective data carrier architecture proposed for the smart contracts in the

blockchain which does not require a predefined standard on data format in blockchain-enabled

IoT environment. Also in [10], smart contracts proposed for applications in business life such as

smart supply chains with IoT-enabled systems. Similarly, in [11] smart contracts used for smart

supply chains with the tracking processes to harvest blockchain benefits. This method

overshadows business applications that may significantly affect our digital life in the near future.

Page 3 of 8

Sabbagh, P. (2021). Proposing an Optimized Cost-Effective Data Carrier Mechanism for Smart Contracts and Transactions in Blockchain with ACO

Algorithm. Advances in Social Sciences Research Journal, 8(3) 579-586.

581

5

URL: http://dx.doi.org/10.14738/assrj.83.9911

A new method for smart contracts with blockchain technology proposed in [12] which named

Filter-based Secure Framework for Ethereum smart Contract (FSFC). It is an input filter-based

secure framework for the smart contract which can be deployed and evaluate its utility using

real-world smart contracts with known integer vulnerability. Some issues of these articles are

based on [13] which watched over by machines of loving grace with a critical look at smart

contracts in blockchain technology. In [14], efficient shipment management proposed for the

smart contract-based approach to multi-echelon and multi-party settings to ensure shipment

tracking. One of the most usable technology for the smart contract with blockchain IoT-enabled

system proposed in [15] which named LSC that is an online auto-update smart contracts for

fortifying blockchain-based log systems.

PROPOSED MODEL

In this section, a new method will be introduced for data carrier architecture with smart

contracts in the blockchain-enabled IoT environment to interact with the outside data sources.

The overview of the proposed architecture and details of each component will be illustrated

accordingly based on Fig. 1.

Fig. 1. The interactions of the proposed data carrier

Fig. 1 represented the interactions of the proposed data carrier system. At the very beginning, it

is responsible for the register of the original smart contract developers, including constructing

missions and registering missions. After that, the data carrier system would monitor the

corresponding Ethereum smart contract that needs external off-chain data. Once being activated

by any transaction, the managed smart contract will fetch off-chain data from the external

Page 4 of 8

Advances in Social Sciences Research Journal (ASSRJ) Vol. 8, Issue 3, March-2021

Services for Science and Education – United Kingdom

environment and callback the fetched results to smart contracts through the Ethereum node.

Generally, there are two kinds of off-chain data that need to be handled in the data carrier service

for smart contract. The first one is the general data provided by the external data source, and the

other one is the results that computed in computation source.

After that, modeling the mission manager is important. The mission manager consists of a front- end and back-end mechanism. The front-end is mainly responsible for constructing mission and

registering mission to the back-end. The data source information collected by the frontend of the

Mission Manager is the mission requisition template (MRT). Front-end will transform MRT into

mission and send it to the back-end via HTTP post to register mission. Then it is necessary to

notice to task publishers. Task publisher will perform four phases action for each block pended,

including collect transactions on Ethereum node, filter out the unconcerned transaction, fetch

argument in the event, and send generated task to specific Worker.

The filter module uses a vital role in this method. The filter module is triggered when every new

block header comes in to find out whether the managed Ethereum smart contract is activated by

any address. In order to know when we can check the new block on the Ethereum blockchain, it

subscribes Ethereum node with a web3 package. Block header information retrieved from

Ethereum node can be used as a timer to check for changes on the blockchain. After retrieving

the block header, we could know the number of newest blocks pended to the blockchain. After

that, we could get the detailed block information by web3 method “web3.eth.getBlock”. The block

information contains a transaction hash, which is the hash of the signed transaction object.

It is unique for each transaction, and by which, Ethereum user can trace their transaction. With

this transaction hash, the “target address” of the transaction will be retrieved from the Ethereum

node. The target address is the address of the transaction receiver if the transaction is used to

trigger smart contract function, the target address will be the smart contract address. After that,

we can already know which smart contract in Ethereum is triggered, and could know whether

the smart contract hosted by our system has been triggered or not by checking Key “contract

address” in the mission database. Since each transaction can trigger multiple events in the smart

contract, we can further use the key “event has” store in the mission database to filter out the

event we are responsible for.

Decoding is the last part of the proposed method for smart contracts. The goal of the decoding

module is to decode the arguments in the filtered event from the filter module and generate task

for Worker. Since we don't qualify the user's event record arguments sequence and type, we need

the event interface to perform decode event. At the very beginning, the decoding module will

obtain the filtered event from the filter module and the mission from the database. In mission,

we can additionally know the message queue channel that is responsible for the event. The key

“event interface” of the mission, which is part of a contract application binary interface, will be

used to decode the event’s log arguments. After that, the decoded content will replace the

“command” of the mission into an actual comment of the task.

After replacing command and generating tasks, we should push the task to the message queue

according to the “messageQueueChannel” of mission in the database. In practice, rabbitMQ [16]

is used to implement through the Rabbit.js package, which provides a simple, socket-oriented

Page 5 of 8

Sabbagh, P. (2021). Proposing an Optimized Cost-Effective Data Carrier Mechanism for Smart Contracts and Transactions in Blockchain with ACO

Algorithm. Advances in Social Sciences Research Journal, 8(3) 579-586.

583

5

URL: http://dx.doi.org/10.14738/assrj.83.9911

API for messaging in Node.JS. The message queue mode we use is PUSH/WORKER mode.

WORKER socket will receive a share of the messages and require calling of acknowledgment

function to acknowledge that each message has been processed. Any messages left

unacknowledged when the socket closes, or crashes will be required and delivered to another

connected socket. A WORKER socket is read-only, and has the additional method which

acknowledges the oldest unacknowledged message, and must be called once only for each

message.

The worker is responsible for retrieving data according to the task sent by Task Publisher,

encoding data with application binary interface, and making function call transaction as the

event’s callback. Worker consists of an execution module, transaction module, fetching agent that

could fetch external data, and computing agents that provide external computation

Now, a smart contract modeled with ACO algorithm which uses any worker as an initial

population of ants. The ants-inspired optimization method is based on random search methods

and population production. In this biological system, the ants are interconnected and each ant

provides an answer to the problem. The ants rush out of the nest to find food and have different

paths to reach the food, but the ants seek the shortest possible path [17]. The presence of

pheromones secreted by ants increases the likelihood of choosing a path. Thus, pathways leading

to food are marked. The shortest path leads to the largest pheromone and thus the potential for

ants to grow. On the other hand, the amount of pheromone in a pathway cannot increase

indefinitely because the pheromone evaporates. The probability of moving from a location like

�" to a neighborhood such as �$ is defined in Equation (1).

�"$(�) =)

*+,-(.)/

0

.*ƞ,-(.)/

3

∑ *+,-(.)/

0

.*ƞ,-(.)/

3

5-∈7889:;<

�� �$ ∈ �

0 ��h������

(1)

Where �"$(�) is the branch weight (pheromone values) between �" and �$ at moment �. α and β

are two parameters with positive values. ƞ",$ is the distance between �" and �$ and contains the

algorithm's heuristic information. Also, �$ ∈ � is a set of neighboring places that have not been

experienced by any ants and is a member of the mutual distance. In the transfer process, the

location experienced in a memory structure is recorded from one neighborhood to another by

the name of the Tabu list. Branch weights are updated when all the ants, exploration and quests

are completed. The branch weight update is shown in Equation (2).

�"$(� + 1) = �. �"$(�) + ∆. �"$(�,� + 1) (2)

Where �"$(�) and �"$(� + 1) are the pheromones of paths (�", �$) before updating. � is the

pheromone evaporation constant and is between zero and one. ∆. �"$(�,� + 1) is the updated

pheromone value as defined in equation (3) below.

∆. �"$ (�,� + 1)=∑ ∆�"$

M N (�,� + 1) MOP (3)

Page 6 of 8

Advances in Social Sciences Research Journal (ASSRJ) Vol. 8, Issue 3, March-2021

Services for Science and Education – United Kingdom

Where � is the number of ants and ∆�"$

M(�,� + 1) is the pheromone value updated by our � ant

between the interval �" and �$ in the repeat �, and is defined in Equation (4).

∆�"$

M(�,� + 1) = S

P

TU

�� �h� ��h ��� ���� ���� �" �� �$

0 ��h������

(4)

Finally, P

TU

is the numerical distance along the path or, in other words, the amount of path cost

experienced by the � ant. The ant colony optimization algorithm is very successful in forming the

pheromone matrix, but it does not perform well in the updating and decision-making process

due to the use of probability law and coincidence. That is the ant moves randomly and operates

on the basis of the probability of how much pheromone the track has in the iteration and

updating stages. So in high detail areas, it won't be very accurate, because along the path with

details that are workers and decoding is low, ants will have to prefer the more pheromone paths

and those filter modules that are transactions but lower decoding does not see it as a workers,

and the pheromone effect remains weak there, and in the decision-making process the parts with

high pheromones are selected. On the other hand, these paths are highly dependent on

pheromone evaporation and need to be fine-tuned to improve searchability and prevent

premature convergence, which necessitates many manual adjustments in different images. So

the process is not good in terms of updating and decision making, but the pheromone and markup

matrix is very useful (because a flaw related to the ACO algorithm is premature convergence

resulting from an inadequate balance mechanism between local and global search, and searching

for first duplicates is preferred and helps improve performance). Finally, the probability and

coincidence process in terms of computational cost requires much more time to execute than a

linear equation. It is for these reasons that the ACO algorithm acts to linearize the problem,

eliminating probability and accident-based decision- making processes and introducing a

definitive process instead. The linear equation can have less runtime and computation and detect

more detail at the task publisher. The purpose of this work is to increase the speed and accuracy

of the ACO algorithm for cost-effective and optimal data carrier mechanism for smart contracts.

Increasing speed means lowering computational cost and reducing minimum mathematical

formulation so that the quality and accuracy of smart contracts are enhanced in greater detail.

Also, it is necessary to set some initialization parameters for the ACO algorithm. So, 100 ants with

0.2 pheromones in any 1 step track new area to find optimal deployment in 500 iterations to fit

the off-chain data.

RESULTS

To create an optimal smart contract with block chain technology in off-chain data, ACO algorithm

applied to components such as workers, mission manager, decoding and filter module. MATLAB

environment used for creating a new platform for doing this job. When smart contract opened

and run, an analysis of the input off-chain data represented which is in Fig. 2.

Page 7 of 8

Sabbagh, P. (2021). Proposing an Optimized Cost-Effective Data Carrier Mechanism for Smart Contracts and Transactions in Blockchain with ACO

Algorithm. Advances in Social Sciences Research Journal, 8(3) 579-586.

585

5

URL: http://dx.doi.org/10.14738/assrj.83.9911

Fig. 2. Smart contract in runtime with input off-chain data

After applying components and also ACO algorithm, another part analyzed which is shown in Fig.

3. In this output, it is clear that the proposed model can reduce 21USD in deployment.

Fig. 3. Smart contract after applying components and ACO algorithm to reduce the costs

CONCLUSION

One of the most promising technology for the Internet of Things (IoT) is blockchain which can

help to secure transactions and contracts. Because some features of blockchain are not enabling

to fetch in off-chain data, so it is necessary to provide and enable smart contracts in blockchain

based-IoT environment. This work can help to communicate smart contracts such as Ethereum,

Tether, Litecoin and etc. outside of the IoT platform. Three components, namely Mission

Manager, Task Publisher, and Worker, are presented in the data carrier architecture which can

interact with contract developer, smart contract, Ethereum node, Tether node, Litecoin node, and

off-chain data sources. Representing new solutions for smart contract filtering with a new

decoding event log due to fitting some requirements applied for optimization which use Ant

Page 8 of 8

Advances in Social Sciences Research Journal (ASSRJ) Vol. 8, Issue 3, March-2021

Services for Science and Education – United Kingdom

Colony Algorithm (ACO). Reducing the cost of deployment about 21USD on average for any smart

contract is the strength of the method which is efficient and has good performance.

References

[1] S. Nakamoto. Bitcoin: A peer-to-peer electronic cash system. Tech. rep., bitcoin.org, October 2008.

[2] Bitcoin (btc) statistics - price, blocks count, difficulty, hashrate, value. 2018. https://bitinfocharts.com/bitcoin/.

[3] K. Croman, C. Decker, I. Eyal, A. E. Gencer, A. Juels, A. Kosba, A. Miller, P. Saxena, E. Shi, E. Goun Sirer, D. Song, R.

Wattenhofer. On Scaling Decentralized Blockchains. Berlin, Heidelberg: Springer Berlin Heidelberg, 2016, Pages 106–125.

[4] M. Vukolic. The quest for scalable blockchain fabric: Proof-of-work vs. bft replication. In Proceedings of the IFIP WB

11.4 Workshop, iNetSec 2015 (J. Camenisch and D. Kesdogan, eds.), Springer International Publishing, December 2015,

Volume. 9591, Pages 112–125,

[5] I. Eyal, E. G. Sirer. Majority is not enough: Bitcoin mining is vulnerable. in Eighteenth International Conference on

Financial Cryptography and Data Security (FC’14), November 2013.

[6] Gartner says 6.4 billion connected “things” will be in use in 2016, up 30 percent from 2015. November 2015.

https://www.gartner.com/newsroom/id/3165317.

[7] Zibin Zheng, Shaoan Xie, Hong-Ning Dai, Weili Chen, Muhammad Imran. An overview on smart contracts: Challenges,

advances and platforms. Future Generation Computer Systems, Volume 105, April 2020, Pages 475-491.

[8] Faris Elghaish, Sepehr Abrishami, M. Reza Hosseini, Soliman Abu-Samra, Mark Gaterell. Integrated project delivery

with BIM: An automated EVM-based approach. Automation in Construction, Volume 106, October 2019, Article 102907.

[9] Xiaolong Liu, Khan Muhammad, Jaime Lloret, Yu-Wen Chen, Shyan-Ming Yuan. Elastic and cost-effective data carrier

architecture for smart contract in block chain. Future Generation Computer Systems, Volume 100, November 2019, Pages

590-599.

[10] Gunnar Prause. Smart Contracts for Smart Supply Chains. IFAC-PapersOnLine, Volume 52, Issue 13, 2019, Pages 2501-

2506.

[11] Shuchih Ernest Chang, Yi-Chian Chen, Ming-Fang Lu. Supply chain re-engineering using blockchain technology: A case

of smart contract based tracking process. Technological Forecasting and Social Change, Volume 144, July 2019, Pages 1-

11.

[12] Zeli Wang, Weiqi Dai, Kim-Kwang Raymond Choo, Hai Jin, Deqing Zou. FSFC: An input filter-based secure framework

for smart contract. Journal of Network and Computer Applications, Volume 154, 15 March 2020, Article 102530.

[13] Andres Guadamuz. All watched over by machines of loving grace: A critical look at smart contracts. Computer Law &

Security Review, Volume 35, Issue 6, November 2019, Article 105338.

[14] Haya Hasan, Esra AlHadhrami, Alia AlDhaheri, Khaled Salah, Raja Jayaraman. Smart contract-based approach for

efficient shipment management. Computers & Industrial Engineering, Volume 136, October 2019, Pages 149-159.

[15] Wei Shao, Zhi Wang, Xiaolu Wang, Kefan Qiu, Chong Jiang. LSC: Online auto-update smart contracts for fortifying

blockchain-based log systems. Information Sciences, Volume 512, February 2020, Pages 506-517.

[16] Rabbitmq, Available online: www.rabbitmq.com (22 08 2018).