Since reading on the Blockchain does not need performance of other nodes, I wonder how I can get values from a Smart Contract without any transactions. I have created a little example contract:
contract Test {
uint x;
function Test() { //to init the contract I definitely need a transaction
x = 0;
}
function inc() returns (uint) { //here I need a transaction too since I change the value
x = x + 1;
return x;
}
function get() returns (uint) { //I am not sure what is about this function
return x;
}
}
I want to check my understanding and have some questions:
- Which functions need a transaction to trigger?
- Do I even need a function to get a value from a smart Contract when I am a full node? Couldn't I just read it?
- What happens when
inc()
is called with a transaction but not inserted in a Block and I read an old value? Is this an important point or can it be ignored? - When do I get a/the return value? Instantly or when the transaction in placed in a block?
I appreciate any answers :)