<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Ontology Aided Smart Contract Execution for Unexpected Situations</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Farhad Mohsin</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Xingjian Zhao</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Zhuo Hong</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Geeth de Mel</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Lirong Xia</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Oshani Seneviratne</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>IBM Research</institution>
          ,
          <addr-line>Hursley Park, Hursley SO212JN</addr-line>
          ,
          <country country="UK">UK</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Rensselaer Polytechnic Institute</institution>
          ,
          <addr-line>Troy NY 12180</addr-line>
          ,
          <country country="US">USA</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>We describe an oracle for smart contracts for strengthening the functionality of their execution, thus making them amenable to any future changes that may be critical for sustained use. The oracle is supported by an ontology|speci cally, constraints for transactions can be represented by semantic rules, and as such, this ontology-based oracle can help resolve break glass in case of emergency type scenarios that require going beyond pre-de ned rules in the smart contracts that are already deployed in the distributed ledger platform. The issue of resolving an unexpected situation that was not explicitly considered in the code can be thought of as dynamic changes to attributes of assets and participants involved in a smart contract, which is equivalent to changing rules for a transaction. One way to implement such changes could be by having users vote on di erent proposals to change the rule. In our case, such a change can be invoked using the ontology and contextual information associated with the smart contract itself. The ontology also helps constrain the voting system itself, imposing a form of access control to allow only valid changes in rules.</p>
      </abstract>
      <kwd-group>
        <kwd>Blockchain Smart Contracts Ontology Semantic Rules Unexpected Situations</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>A decentralized application (DApp) does not require an arbitrator due to
the implicit trust properties guaranteed by the immutable nature of the
distributed ledger framework. Typically, DApps employ smart contracts to execute
a particular set of rules in a trusted way. However, smart contracts are usually
immutable, and thus requires prior consideration for di erent unexpected
situations that may require change in rules. For example, in a decentralized course
selection system spanning multiple schools, there may be speci c rules for
student enrollment in courses. A professor might employ a smart contract to reduce
the class size for the Summer semester, but there could be a capacity of students
Copyright c 2019 for this paper by its authors. Use permitted under Creative
Commons License Attribution 4.0 International (CC BY 4.0).
needing to nish the course during the Summer since they are to start a work
placement in the Fall. Therefore, in the absence of a central authority, smarter
contracts with exible structure are needed to manage unexpected situations.</p>
      <p>
        Liu et al. [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] suggest smart contracts with a voting mechanism for users to
vote to resolve such situations. However, the approach could only deal with a
subset of situations by changing some asset attributes related to the transaction
that led to the situation. While voting easily gives a valid decentralized way to
select new attribute values, a more generalized solution is required to resolve
more complex situations.
      </p>
      <p>We propose an ontology-based oracle, where transaction constraints are
dened by semantic rules. Since all participant and asset classes have structured|
and associated semantic de nitions, we can execute complex rules and also
modify the rules when necessary. The main contribution of this work is a solution
where unexpected situations of complex nature can still be resolved by voting.
Aggregating user votes on a new set of proposed rules, we can select a new
consistent rule that may resolve the situation.
2</p>
    </sec>
    <sec id="sec-2">
      <title>Related Work</title>
      <p>
        There have been attempts to de ne a formal ontology for blockchain and smart
contracts [
        <xref ref-type="bibr" rid="ref3 ref4">3, 4</xref>
        ]; others have attempted ontology-driven design of blockchain for
speci c use cases such as provenance tracking [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]. Our work with ontologies is
similar to the method for auto-generating smart contracts from domain-speci c
ontology models and semantic rules by Choudhury et al. [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ]. In contrast to
the aforementioned work, we propose a dynamic ontology-aided oracle, that
extends the solution in [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] to adapt smart contracts when faced with unexpected
situations.
3
3.1
      </p>
    </sec>
    <sec id="sec-3">
      <title>Preliminaries</title>
      <sec id="sec-3-1">
        <title>Ontologies and Semantic Rules</title>
        <p>
          An ontology contains de nitions of concepts, properties, and relationships among
them for a particular domain|or system; an ontology also provides a
common vocabulary among stakeholders, thus enabling data share and reuse. By
incorporating formal rules to such models (e.g., Semantic Web Rule Language
(SWRL) [
          <xref ref-type="bibr" rid="ref6">6</xref>
          ]) we can increase the model expressivity. Smart contracts essentially
enable DApps on blockchains to work based on pre-de ned rules, and our
proposal is to make the rules be executed based on an ontology.
3.2
        </p>
      </sec>
      <sec id="sec-3-2">
        <title>Oracles in Blockchain</title>
        <p>A smart contract executes completely deterministic transactions and then
update the blockchain in an according way. Thus, communicating with an external
system becomes problematic as it is not possible to verify all external data in a
deterministic way. Oracles solve this problem by providing a trusted system for
information transfer. While an oracle may seem like a centralized component,
a mutable ontology-based oracle for holding transaction rules actually aids our
solution for decentralized handling of unexpected situations.
4</p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>Ontology for Smart Contract Execution</title>
      <p>
        Though smart contracts are useful in implementing decision rules in
decentralized applications, it might be desirable to some to keep intricate and complex
logic o -chain for ease of design[
        <xref ref-type="bibr" rid="ref7">7</xref>
        ]. Moreover, smart contracts are immutable,
which also makes it di cult to implement changes in logic, which can sometimes
be expected. Motivated by the barrier to change the logic in smart contracts,
we instead take the approach of implementing such logic o -chain on an Oracle,
building on a domain-speci c ontology.
      </p>
      <p>As depicted by Figure 1, the main idea is as follows: the blockchain itself
will act as a veri able data structure, but most of the logic for each transaction
will be performed o -chain in this model. This is achieved by implementing an
oracle with a domain-speci c ontology which holds all relations, and the rules of
transactions with respect to the semantic concepts found in the said ontology.
Each time a transaction is attempted by a user or a smart contract on the
network, a query will be made to the oracle about present constraints for the
particular transaction. The oracle will be provided with information about the
participants and assets involved in a given transaction, and an instance will be
created. The semantic rule de ned for that transaction will then verify whether
this transaction will be completed or not.
We demonstrate our model with the example case of a decentralized course
selection system. A registrar's o ce usually acts as a governing body for the case
of students' course selection. But in a decentralized system, there would be no
such system. If we implement a smart contract for this, conditions like
prerequisites for a student joining a course or capacity for a course may be de ned
by semantic rules. Figure 2 shows a section of the ontology on a decentralized
course selection (dcs) namespace. A basic transaction for the smart contract is
AddCourse, which a student uses to enroll in a course, if they ful ll necessary
prerequisites. Now, we can have a SWRL rule like the following to de ne this
condition.</p>
      <p>Student(?s)^hasGP A(?s; ?g)^hasY ear(?s; ?y)^Course(?c)^hasRequiredGP A(?c; ?rg)^
hasRequiredY ear(?c; ?ry)^hasM axCapacity(?c; ?mc)^hasCurrentSize(?c; ?curr)^
swrlb : greaterT hanOrEqual(?g; ?rg)^swrlb : greaterT hanOrEqual(?y; ?ry)^
swrlb : lesserT han(?curr; ?mc) ! canAddCourse(?s; ?c)
When trying to execute an addCourse transaction, the smart contract would
query to the oracle about whether the conditions meet. The oracle in turn queries
the necessary data from the blockchain and receive data in triples. For the
instance in Figure 3, the oracle would receive triples: student1 : hasGP A : 3:8,
student1 : hasY ear : 1, course1 : hasRequiredGP A : 3:0 etc. With these
triples, the query can be evaluated and a True/False value returned to the smart
contract for the AddCourse transaction.</p>
      <p>In a case when a student does not have su cient GPA, the professor may
consider their grade point in some speci c course and modify the rules with
an alternate prerequisite. This could have been unforeseen while writing the
contract. In our solution, this can be resolved by updating the SWRL rule in
the oracle. Since changing the condition for a transaction shall impact other
participants than just the one professor and one student, any such change should
be made in a fair manner. To ensure this, we implement a voting system to
update the rules.
4.2</p>
      <sec id="sec-4-1">
        <title>Voting Mechanism</title>
        <p>We give a sketch of the voting mechanism here, Figure 4 depicting the basic
ow. The voting system itself would be explicitly guided by the ontology as it
would not be tractable to allow all users to vote on all proposal or make all
attributes changeable by voting. A form of access control is implemented on the
voting system, again utilizing the semantic rules with respect to the ontology
so that concerns like who could invoke a startVote transaction, how proposals
are gathered or how proposals are aggregated to a single desirable outcome can
be addressed properly. The voting mechanism may initiate transactions that
request new proposals and votes from users.
5</p>
      </sec>
    </sec>
    <sec id="sec-5">
      <title>Implementation Challenges and Future Work</title>
      <p>We present speci c implementation considerations, drawing examples from the
course selection scenario when necessary.</p>
      <p>{ The ontology will help maintain the extent to which rules and attributes are
changeable. For example, while attributes such as course.MaxCapacity may
be changeable, student.GPA cannot be changed, overriding proper rules for
updating student grades, by voting.
{ For privacy concerns, the oracle would receive data necessary for forming
instances for each transaction and never store a complete knowledge graph.
{ The oracle consists of both an ontology and a reasoner that helps respond
to queries. Updates on the rules should only occur from the smart contract,
each transfer of data will also need to ensure that the oracle has not been
externally tampered, using a mechanism like change signatures.
Having some rules o -chain may pose a modicum of new security threats that
we would like to investigate. Also, we understand that the implementation may
also lead to growth in transaction completion time, so a complexity analysis is
also due. Another point of interest would be di erent ways to aggregate propose
rules based on di erent voting rules.
Our proposal of an ontology-based oracle not only makes execution of complex
logic in smart contracts easier, but coupled with the voting system, also allows
for a way to update the contracts. Empowered with the ontology, we could make
use of the data that from update requests for the rules. The voting data may be
leveraged towards learning preferences of voters, and proper utilization of this
may lead towards creating smarter contracts able to auto-generate proposals for
voting or have intelligent proxies for voters to speed up the updating process.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Liu</surname>
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Mohsin</surname>
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Xia</surname>
            <given-names>L.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Seneviratne</surname>
            <given-names>O.</given-names>
          </string-name>
          :
          <article-title>Strengthening Smart Contracts to Handle Unexpected Situations</article-title>
          .
          <source>In: 2019 Proceedings of IEEE International Conference on Decentralized Applications</source>
          and Infrastructures, CA, USA (
          <year>2019</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Choudhury</surname>
            <given-names>O.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Rudolph</surname>
            <given-names>N.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Sylla</surname>
            <given-names>I.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Fairoza</surname>
            <given-names>N.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Das</surname>
            <given-names>A.</given-names>
          </string-name>
          :
          <article-title>Auto-Generation of Smart Contracts from Domain-Speci c Ontologies and Semantic Rules</article-title>
          .
          <source>In: 2018 Proceedings of IEEE International Conference on Internet of Things and IEEE Green Computing and Communications and IEEE Cyber</source>
          ,
          <article-title>Physical and Social Computing and IEEE Smart Data</article-title>
          , Halifax,
          <string-name>
            <surname>NS</surname>
          </string-name>
          , Canada,
          <year>2018</year>
          , pp.
          <fpage>963</fpage>
          -
          <lpage>970</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>de Kruij</surname>
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Weigand</surname>
            <given-names>H.</given-names>
          </string-name>
          :
          <article-title>Understanding the Blockchain Using Enterprise Ontology</article-title>
          . In: Dubois E.,
          <string-name>
            <surname>Pohl</surname>
            <given-names>K</given-names>
          </string-name>
          . (eds)
          <article-title>Advanced Information Systems Engineering</article-title>
          .
          <source>CAiSE 2017. Lecture Notes in Computer Science</source>
          , vol
          <volume>10253</volume>
          . Springer, Cham
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>de Kruij</surname>
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Weigand</surname>
            <given-names>H.</given-names>
          </string-name>
          :
          <article-title>Ontologies for Commitment-Based Smart Contracts</article-title>
          . In: Panetto H. et al. (
          <article-title>eds) On the Move to Meaningful Internet Systems</article-title>
          .
          <source>OTM 2017 Conferences. OTM 2017. Lecture Notes in Computer Science</source>
          , vol
          <volume>10574</volume>
          . Springer, Cham
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Kim</surname>
            ,
            <given-names>HM</given-names>
          </string-name>
          , Laskowski,
          <string-name>
            <surname>M.</surname>
          </string-name>
          :
          <article-title>Toward an ontologydriven blockchain design for supplychain provenance</article-title>
          .
          <source>Intell Sys Acc Fin Mgmt</source>
          .
          <year>2018</year>
          ; vol
          <volume>25</volume>
          : pp
          <fpage>18</fpage>
          <lpage>27</lpage>
          . https://doi.org/10.1002/isaf.1424
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <surname>Horrocks</surname>
            ,
            <given-names>I.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Patel-Schneider</surname>
            ,
            <given-names>P.F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Boley</surname>
            ,
            <given-names>H.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Tabet</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Grosof</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          and
          <string-name>
            <surname>Dean</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <year>2004</year>
          . SWRL:
          <article-title>A semantic web rule language combining OWL and RuleML</article-title>
          . W3C Member submission,
          <volume>21</volume>
          (
          <issue>79</issue>
          ), pp.
          <fpage>1</fpage>
          -
          <lpage>31</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <surname>Desrosiers</surname>
            <given-names>L.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Olivieri</surname>
            <given-names>R.</given-names>
          </string-name>
          ,
          <year>2018</year>
          .
          <article-title>Extend your blockchain smart contracts with o -chain logic</article-title>
          . https://developer.ibm.com/articles/cl
          <article-title>-extend-blockchain-smartcontracts-trusted-oracle/</article-title>
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>