1

I am considering trying to use or implementing some form of light Ethereum node that only needs access the most recent version of data stored in smart contract storage on the blockchain and trying to only download pertinent blocks. In this consideration, I am looking for more information about how a contract's memory is kept. I imagine that the initial state of all of a contracts persistent variables is stored in the same block that the contract is mined into.

Is there a way to know the block number/block data that contains the transaction that causes the change in state (most recent version) of this persistent contract storage?

1

Ethereum contract has runtime memory, when a program downs, all data in contract (example simple counter), counters, variables will be removed. In case when you use transfer or send, you track info in log data, but this function need to be payable to do this (it will kept in transaction).

You can track all transactions which belongs to some contract. First you need to create a filter with object.

https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_newfilter.

After you can take from node queue transactions (in/out) by polling

https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getfilterchanges.

For inner transactions, you need to see log section

https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getlogs

  • Just so I understand, you are saying that there is no persistent memory for the actual contract, rather that information is stored in a block, and every time that information changes (due to the contract being executed) it is stored in the form of a transaction that will belong to the contract. In my system I don't play on sending ether to the contract. Otherwise, thank you for the response I beleive I have a good starting point now. – Cameron Jul 24 '17 at 22:33
  • Yes, they don't have persistent memory. For saving data, use db) If you need some info from contract (amount, etc), you may use contract events, send to them what you want from contract. – DeV1doR Jul 25 '17 at 8:48
  • Please take a look at this page as I believe it contradicts your understanding: ethereum.stackexchange.com/questions/1232/… – Cameron Jul 26 '17 at 13:32

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.