6

Is this assumption correct ?

There is absolutely no way an ethereum contract can send data to the external world. It can only modify its state variables (later stored in the new block)and send messages to other contracts. States can only be obtained by off-chain / offline apps , that simulate contract and read from any of the blocks in local copy of blockchain/states.

2

Yes, this is correct. Everything on the blockchain is public, but only the current state is visible to smart contracts.

Interestingly, using a Merkel proof, you can prove to a contract that another contract has or had a particular value during any block in the past 256 blocks, since the contract can access the past 256 blockhashes.

One little correction: contracts update their state variables during the execution of a block, not in a later block. This can be tricky, since contracts can be called in an arbitrary order decided by the miner, so depending on the order of execution, contracts can do different things.

  • Has anyone made an implementation of getting data from a previous block to a contract and proving it with a merkel proof? What does / would the gas usage look like? – Edmund Edgar Sep 30 '16 at 0:35
  • I'm not quite sure what this would achieve. The execution of the code itself would only apply to the chainn on which the block is being mined. For example you could have an identical contract on ETC as on ETH chains, both could theoretically grab block data from the past, and conduct a successful proof (although the block hashes may be different if the contract was created after the Hard Fork). – T9b Oct 4 '16 at 8:11
  • The block hashes would be different, and it would be extremely difficult to do PoW verification. The better use case is for proving things about the ETH chain, like that a contact's storage contains a particular value, despite that value not being "public" – Tjaden Hess Oct 4 '16 at 11:28
2

In the context of your question, you can think of the blockchain as a database. A database on its own cannot "send data to the external world" - it requires some script to query the database and then make the information that is returned available for example via a web interface to the rest of the world.

Your interface with the world, may be hosted centrally or locally, but the underlying database is not generally unless you are talking about a private chain.

  • Thanks for the comments. Just read about events and logs. These seem to be ways for contract code to send data out - outside of state variables. Can someone throw some light please? – RajCherla Sep 30 '16 at 11:08
  • You can log events. These are stored by nodes, but not accessible by contracts. You can make an external process to watch the blockchain for particular events and do something (send email, hit a URL etc) if it sees something you're interested in. However, as with contract state, that process needs to be running and connected to a node. – Edmund Edgar Oct 1 '16 at 3:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.