Variables used in contracts do they get stored in Blockchain?
If so does it require ether? If not how is persistent where is it stored?
Variables used in contracts do they get stored in Blockchain?
If so does it require ether? If not how is persistent where is it stored?
The global (state) variables are stored in 'storage' so they are in the blockchain. The function's parameters and return value are stored in the memory, and so are reseted after a function call.
e.g
contract C {
uint256 id;
function f(uint256 m) returns (uint256 r) {
uint256 v; //pointer to storage
}
}
id and v are in the storage.
m and r are in the memory.
However you can declare in solidity whether the variable should be stored in memory or in storage by using the keywords memory and storage;
e.g function f(uint[] storage _data, uint _value)