Since reading on the Blockchain does not need performance onof other nodes, I wonder how I can get values from a Smart Contract without any transactions. Therefore, I have created a little example Contractcontract:
Contractcontract Test {
uint x;
function Test() { //to init the contract I definatelydefinitely 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 do not know if the code is correct, but I hope you will getwant to check my point, I just have an understanding problem here I think and raisedhave 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 :)