<!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>Towards Detecting Semantic Events on Blockchains</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Abhisha Bhattacharyya</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Rahul Iyer</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Kemafor Anyanwu</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>North Carolina State University</institution>
          ,
          <addr-line>Raleigh NC 27695</addr-line>
          ,
          <country country="US">USA</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>Blockchains maintain information about transactions creating and transferring digital assets. "Smart contracts" which are arbitrary, immutable code executable on a blockchain, can be used to implement complex business rules that govern transactional behavior as well as raise events which external applications can be noti ed about. However, the arbitrary and imperative nature of smart contracts and the events they raise, make their discoverability and reuse challenging. Further, events represented merely as function signatures limit the ability for more complex, semantic event detection which require richer representations such as semantic rules. In this paper, we motivate and describe our e orts towards support for semantic event detection on blockchains that are founded on (i.) a declarative, semantic data, transaction and event model and (ii.) an integrated blockchain-streaming application execution architecture. We overview our selected implementation strategy that builds on the BigChainDB blockchain engine and Apache Kafka, a large-scale streaming platform.</p>
      </abstract>
      <kwd-group>
        <kwd>Semantic Events</kwd>
        <kwd>Blockchains</kwd>
        <kwd>Declarative transactions</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>
        Blockchains typically maintain information about transactions that create or
transfer ownership of digital assets. To enable business applications with complex
business logic for governing such transactions, the concept of "smart contracts"
was introduced by blockchain platforms like Ethereum [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ] and HyperLedger [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ].
Smart contracts, which are arbitrary, immutable code executed on blockchains
are also able to raise events which external applications can consume. Until
very recently, limited interaction models were permitted with respect to events
e.g. smart contracts cannot detect events raised by other smart contracts since
they cannot read directly from the blockchain. Fortunately, a recent Ethereum
extension Eventeum[
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] now provides a connection between smart contracts and
middleware layer via a message bus containing details of the event emitted.
However, there are still major limitations with the state-of-the art in smart
contracts and blockchain event models as illustrated using the following example.
|||||||||||||||{
Copyright © 2019 for this paper by its authors. Use permitted under Creative
Commons License Attribution 4.0 International (CC BY 4.0).
      </p>
      <p>Abhisha Bhattacharyya, Rahul Iyer, and Kemafor Anyanwu</p>
      <p>
        Imagine a digital service marketplace that allows consumers to request for
bids for speci c services and service providers to o er service bids. This scenario
can be useful in domains such as Manufacturing that are increasingly becoming
more Cloud-oriented. In large-scale or bespoke manufacturing for example, it is
common to need to outsource the manufacturing of some components. However,
in high-capital domains, a signi cant degree of con dence and trust in
capabilities and capacities of service providers is required by the service requestor. Some
ideas on using the blockchain for maintaining historical records of bids, their
fulllment, performance, etc to be leveraged for mediating automatic agreements,
has been proposed in [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]. These ideas have been explored using Ethereum smart
contracts resulting in the following lessons learned:
      </p>
      <p>Lack of Reusability: Each request-for-bid - rfb (and similarly bid) is a
non-traditional blockchain transaction which would need to be implemented as
a separate smart contract, even when rfbs have similarities or overlapping
behavior. This is because program reuse is more challenging with imperative
representations given that semantics is implicit in program behavior. The immutability
of smart contracts also implies that if business conditions evolve even slightly,
modifying the smart contract to capture new business logic is a major challenge.</p>
      <p>Discoverability: In our example, a service provider would need to be aware
of the existence of a smart contract requesting for a bid on services that they
provide. This requires either (i.) some standardized token contract interfaces for
representing speci c protocols (analogous to ERC20/721) or (ii.) some registry of
smart contracts indexed by standardized metadata. However, it is unlikely that
a xed set of function interfaces that comprise a token will be general enough to
capture such protocols, given the variability in possible request and bid
requirements (unless perhaps organized into very narrow vertical segments). Another
approach that can be used to discover requests is via the events raised by smart
contracts. Such events may be routed through a publish/subscribe platform like
Apache Kafka (such as is done by Eventeum). However, subscribing to events
requires apriori knowledge of event de nition. Unfortunately, each smart
contract raises events using a function signature of its choosing. Consequently, the
same event could be represented using di erent signatures which cannot all be
known apriori. Secondly, how to map such events into an appropriate
publishsubscribe event detection model is unclear. This is because the semantics of an
event may be implicit and complex. For example, a request for bid transaction
that has parameters Material as "PolyCarbonate" and Quantity as "10" can
be mapped to "3D Printing" event. Such terms and relationships would need
to be captured in an ontology and semantic rule engine.</p>
      <p>
        Our preliminary investigation leads us to the conclusion that there are two
key requirements needed to enable detection of semantic events on blockchains:
(i.) The use of a declarative and semantic data, transaction and event model
that allows new transaction (e.g. bids) and event classes to be introduced in
a straightforward manner. The semantic-awareness requirement allows
reasoning about semantic relationships between transaction and event types. (ii.) A
processing architecture that integrates blockchains with a semantic rule engine
and publish and subscribe mechanisms, enabling detection of complex semantic
events. We are currently developing these ideas in the context of a project called
SmartChainDB. SmartChainDB extends a blockchain platform BigChainDB [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]
that has a semi-structured data model, enable signi cant exibility in
extensibility.
      </p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          <article-title>1. An introduction to hyperledger</article-title>
          .
          <source>Tech. rep., The Linux Foundation</source>
          , https://www.hyperledger.org/wpcontent/uploads/2018/07/HL Whitepaper IntroductiontoHyperledger.pdf
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <article-title>Listening to ethereum events with eventeum</article-title>
          . https://kauri.io/article/90dc8d911f1c43008c7d0dfa20bde298/listening
          <article-title>-toethereum-events-with-eventeum</article-title>
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          <article-title>3. A next-generation smart contract and decentralized application platform</article-title>
          .
          <source>Tech. rep., Ethereum</source>
          , https://github.com/ethereum/wiki/wiki/White-Paperethereum
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          <article-title>4. Bigchaindb 2.0 the blockchain database</article-title>
          .
          <source>Tech. rep</source>
          .,
          <source>BigchainDB GmbH</source>
          , Berlin, Germany (May
          <year>2018</year>
          ), https://www.bigchaindb.com/whitepaper/bigchaindbwhitepaper.pdf
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Angrish</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Craver</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Hasan</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Starly</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          :
          <article-title>A case study for blockchain in manufacturing:fabrec: A prototype for peer-to-peer network of manufacturing nodes</article-title>
          .
          <source>Procedia Manufacturing</source>
          <volume>26</volume>
          ,
          <issue>1180</issue>
          {
          <fpage>1192</fpage>
          (
          <year>2018</year>
          )
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>