I have a private chain and I am running own archiving node. The node connected with --fast cache=1024
option.
For example I have a set function on my smart contract.
contract smartContract {
uint value;
function set(uint input) returns (bool success) {
value = input;
}
function getValue() public view
returns (uint)
{
return value;
}
}
This function is called at block number 100 and 200.
smartContract.set(10) //deployed at block number 100
smartContract.set(20) //deployed at block number 200
At this point. if our blockchain is sync, as we know, when we call smartContract.get()
it returns 20.
Here mentions that smart contact can only see the current state.
A contract can only see the current state when it executes, not previous states. This restriction allows validating nodes to work only with the current state, rather than needing to store and be able to access all the previous states.
Here we can get previous blocks data. Since we can obtain previous block data, we could obtain the previous states.
[Q] Could web3 retrieve state of a value from previous block numbers instead of returning the its latest state value?
If we provide the block number such as 100, smartContract.get() at 100
; somehow can web3 return value
's value at block number 100 instead at latest
?
web3.py
? @Henk