I'm new in Ethereum. And I'm trying to develop contracts using Azure's cluster (I have trial account). I connected using geth to my network from machine in Azure:
gethadmin@XXXXXX-tx0:~$ geth attach http://ether2ore.eastus.cloudapp.azure.com:8545
Then I initialize variable
>var test_var = 555
undefined
>test_var
555
It's - OK.
But when I tried to connect to same point from my laptop:
C:\Users\boris>geth attach http://ether2ore.eastus.cloudapp.azure.com:8545
I tried to check this variable:
> test_var
ReferenceError: 'test_var' is not defined
at <anonymous>:1:1
I see that it's not defined.
On both consoles I see same accounts:
From - C:\Users\boris>
eth.accounts ["0xab14c61930343149c2f54044054cd46b90c0dee6", "0x7cc276b28bfdbb57151ed3b5552aafb2f2592964", "0xc9b8b9d57219b2c0935d8c28d4d2247fe70232f3", "0x2aed463fd54aa41fed898a9629bee6f0935b74fb"]
From - gethadmin@XXXXXX-tx0
eth.accounts ["0xab14c61930343149c2f54044054cd46b90c0dee6", "0x7cc276b28bfdbb57151ed3b5552aafb2f2592964", "0xc9b8b9d57219b2c0935d8c28d4d2247fe70232f3", "0x2aed463fd54aa41fed898a9629bee6f0935b74fb"]
Command admin.peers on both consoles gives me same results So, it's same networks.
Maybe I don't understand how it should works, but I suspect that, if I define variable in same network it must be visible from all consoles. Is not it? Same situation with contracts. I compiled contract in first console and can operate with it, but it's not reachable from another console.
Please, can you explain me why this situation happens or give me proper links to get answer on this question. Many thanks
The variables you are instantiating are local variables within the console. Each time you connect, a new JavaScript Console with the web3 API exposed is created locally and it wraps the ethereum function calls so that you can use them within JS rather than having to write the raw calls.
To persist data on the network you would need to deploy a contract with storage. You could then fetch the data from the contract storage without executing a transaction using a getStorageAt or call and the signature of your public variable. However, you will need to execute a transaction calling a contract function (similar to the example in the solidity documentation above) in order to update the data stored in the contract.