📖 This HIP is in the review stage. It is subject to changes and feedback is appreciated.

HIP-478: Interoperability Between Smart Contracts and the HCS Source

AuthorJohn Conway, Walter Hernandez
Discussions-Tohttps://github.com/hashgraph/hedera-improvement-proposal/discussions/479
StatusReview
Needs Council ApprovalNo
TypeStandards Track
CategoryApplication
Created2022-05-17
Updated2022-09-14, 2022-09-16

Abstract

Enable smart contract interaction with the Hedera Consensus Service, by allowing contracts to create, read, and write to HCS topics.

Motivation

Interoperability between the HCS and smart contracts would enable developers to leverage HCS-stored data in their dApps.

Rationale

  1. By enabling smart contracts to interact with the HCS, this would allow the creation of HCS-based Oracles. For example, a smart contract could subscribe to a private or public topic in order to read its external data, such as the prices of crypto-assets.

  2. This would also enable topic-based NFT minting rights. A smart contract could ingest an HCS topic to calculate the user’s available NFTs. Then, after minting the NFT and transferring it to the user, the smart contract could update that same HCS topic. Currently, this process is only achievable via a centralized, server-based chain of events (such as on https://hashandslash.io).

  3. Any other Oracle use case could be repurposed by the HCS.

User stories

As a developer, I want to be able to read HCS topics from my smart contracts.

As a developer, I want to be able to send HCS topic messages from my smart contracts.

As a developer, I want to be able to create HCS topics from my smart contracts.

Specification

Enabling smart contracts to interact with HCS topics would follow the same approach as the https://hips.hedera.com/hip/hip-206.

Security Implications

With regards to signing transactions from within a smart contract, the main concern is storing private keys in-state. So, some possible solutions are:

  1. Give a different kind of permission to deployed smart contracts for interacting with certain topics. This could function similarly to how AWS differentiates between key-based permissions and role-based permissions.
  2. Follow the same approach from the https://hips.hedera.com/hip/hip-206 to signing transactions and interacting with topics.

References

https://hedera.com/blog/use-cases-for-hcs-based-records-in-play-to-earn-nft-gaming

https://hashandslash.io

Copyright/license

This document is licensed under the Apache License, Version 2.0 – see LICENSE or (https://www.apache.org/licenses/LICENSE-2.0)

Citation

Please cite this document as: