Python library is called Herapy (AERGO contribu-
tors, 2019) .
We first analyze Heraj which provides fea-
tures and functionality to interact with the Aergo
blockchain and with the development and the execu-
tion of smart contracts. Next we will have a look at
how Heraj could be used to deploy a Lua smart con-
tract.
Aergo Smart Contracts. Aergo allows to develop
and run smart contracts using LUA language and
Athena-Ide, which is an extension of the Atom
text editor. In addition Aergo provides a testnet
blockchain in which it is possible to run and test de-
centralized applications without spending real Aergo.
By following the instructions given by the company
available at (AERGO team, 2019) everyone can ob-
tain an Aergo wallet and an Aergo account. Aergo
provides Aergo Connect, which is a blockchain bridge
that allows to connect to the Aergo blockchain with-
out installing a blockchain node. It is very similar to
the more famous Ethereum’s metamask. Thanks to
Aergo Connect it is possible to chose to work in the
Aergo main net or in the testnet. We worked using
the Aergo test net because it is free. Aergo provides
a tool to require tokens spendable only on the testnet.
This tool provides an amount of five AERGO, which
is more than necessary to build up our smart contract.
Aergo use a particular set up for Lua language, in-
deed the use of some default libraries like the ”os”
one is not allowed for security purposes, and it pro-
vides a type Map which is not of the original Lua.
This type, is like a Java Hash-Map but keys are al-
lowed to be only strings, while values are allowed to
be of any type.Inside the state.var scope we define
our global variables, and inside the constructor() we
set up variables.
As represented in Fig 2, on the left panel we can
notice the Athena-Ide interface, which is very simi-
lar to Remix environment for Solidity smart contracts
development. Indeed, we can see that is possible to
import an Aergo account, compile contracts and make
the contract deploy to append it on Aergo blockchain;
also, is possible to select if we want to work locally,
on test net or on main net.
3.4 The Document Timestamping
We now describe the implementation of a blockchain
based system for document timestamping we devel-
oped during the Document management project.
Given a document, we want to use the blockchain
to associate a timestamp to this document exploiting
the Aergo blockchain. The timestamp must be im-
mutable, so once the document is timestamped, it can
not be timestamped again.
In the following we describe functions and vari-
ables defined in the implementation. In the Appendix
of this paper we we provide the complete source code
of our smart contract.
Global Variables. We used two global variables,
document prove and document id. document prove
is a Map type, and it stores the document id and the
associate timestamp. document id is an integer which
represents the document id.
Function set time. This functions should work
only if the one to call them is the owner of the con-
tract. Thanks to the ”system” library provided by
Aergo, we can call functions like getCreator() and
getSender() which allows us to make those types of
controls; so, if the contract is called by the owner we
can set a new document id.
As before, we check that owner and sender coincide,
and so if this is the case, we check that for a particular
document id a timestamp has not been associated yet;
if this is the case, then we associate a timestamp to
that document else we return an alert message.
Function get timestamp of a document. As ever
we check that the one which is calling the function is
the owner of the contract. If the owner is calling the
function then the associated timestamp to the docu-
ment id given in input will be returned. Else, if the
function is not called by the owner, an alert message
will be printed.
3.5 System Integration
As we said previously, Aergo provides SDK to inter-
act with the blockchain. Heraj is the library provided
by Aergo for Java language; this library allows to in-
terface Java with Aergo blockchain. This type of in-
teraction with Java and Aergo allows the development
of decentralized applications (dAPPs). Heraj makes
the development and the execution of smart contracts
very simple and efficient. To use the library, we can
take the advantages provided by tools such as Gradle
(https://gradle.org/) or Maven (https://maven.apache.
org/). In the collaborative document management sys-
tem, the platform ALFRESCO is modified to include
the Heraj library. This allows the interfacing of the
software with the Aergo blockchain in order to use
the smart contracts deployed in it such as the times-
tamping one. To given an example, when we want
to modify a document, ALFRESCO could execute a
Blockchain Certification and Granular Editing Permissions in Document Management System
303