2

I am trying to log all access operations on a file storage in Ethereum. The access operations are read, write, update and delete. Every time, a user does any of these operations on the file storage, I would like to log that into Ethereum. Since Ethereum and file storage are two disparate systems, the only way I can do this is by triggering a call to smart contract for every access event that happens in the file storage.

Q1: Is it possible to call a smart contract from an external system?

Q2: Is there a better architecture to achieve the same results?

Rob Hitchens
  • 55,151
  • 11
  • 89
  • 145
user6488
  • 123
  • 2

1 Answers1

2

Q1 Yes. An external system can interact through Web3 (JavaScript), one of the other client-side libraries, or jsonRPC. Think of the external system as a full participant with knowledge of private key for signing transactions from an externally owned account.

Q2 It's a very broad question. You can probably find some good information researching the topic of "Oracles" for Ethereum Smart Contracts. "Oraclize" and "Reality Keys". An Oracle provides information from the world outside the strictly deterministic blockchain.

Hope it helps.

Rob Hitchens
  • 55,151
  • 11
  • 89
  • 145
  • External system should also run the light-client within self in order to connect into the public or private blockchain right? @RobHitchens – alper Apr 15 '17 at 17:11
  • 1
    Hard to say. Maybe look a Infura for "Light Client" - includes IPFS and Ethereum. For IoT, have a look Project Oaken for ideas. – Rob Hitchens Apr 15 '17 at 19:49
  • @RobHitchens For Q2, is storing the access log in a mapping the best option? Do you think Ethereum events can be used for this purpose? I'm thinking this might be a typical application but can't find any reference architecture. – user6488 Apr 16 '17 at 17:26
  • @Avatar Question is too broad. Too many use-cases to guess what your application is about.Can't begin to guess at design ideas without knowing the purpose of the application. – Rob Hitchens Apr 16 '17 at 21:20
  • @RobHitchens The application is about logging access events of file storage. The idea is to share a bunch of files with a group of people and track all the access using blockchain. As an example, let's say we share a sensitive document with a group of people and want to track who all have accessed that document. By storing the access log in blockchain, we can provide an incontrovertible record of who all have read the document. – user6488 Apr 17 '17 at 14:46
  • You might consider arranging the app so all I/O goes 'through' a web server (e.g. nodeJS). I think that might simplify detection considerably. It can coordinate SC updates and object storage. Have you looked at uPort? They have offchain storage organized by entity address. Example might give you ideas about how to approach it. – Rob Hitchens Apr 17 '17 at 15:18
  • In the answer, could you change Q2 to Q1 in the first line. – user6488 Apr 17 '17 at 20:51
  • I am a bit confused about how to use Web3 to access a deployed a contract. To begin with, we know the contract name and the contract address. How do we build a contractInstance from this information? I tried web3.eth.contract(HelloWorld.abi).at("0xc1281b4c59ae01f27df099199407bb5152591ss7") but it gives an error message about unresolved HelloWorld. I assume we need to initialize it somehow. Any pointers? – user6488 Apr 17 '17 at 20:53
  • It's a matter of taste, but I prefer the way Truffle takes care of a lot of details. There are a lot of steps in the CLI process. This answer looks pretty good. https://ethereum.stackexchange.com/questions/2751/deploying-the-greeter-contract-via-the-geth-cli-is-not-registering-in-my-private – Rob Hitchens Apr 17 '17 at 21:32