I am running a private blockchain using geth as the client. I want to save some custom variables in my chain. I know there is a practical limitation on the storage capabilities as it would require ether. How can I write data to the blocks as they are created and then retrieve the data later?
I suggest that you follow the basic tutorial which shows exactly that. I would advise you to not bother with infrastructure and running your own node at first. You can use the entirely browser-based Solidity IDE called Remix to test what you are doing and interact with your contract. You could copy-paste the greeter example that I linked above into Remix (you can overwrite the Ballot example, it's fairly complex for beginners), click on the top right onto
Contract, then click on the
create button but before that write a greeting into the text box on the right, e.g.
"Hello World" (dont forget the quotes (
") or you will get a weird error message.
In this example you are writing some data (here a string but it could be other more complex data), this is then written into the blockchain and you can later retrieve it via the
greet function that reads the data back to you.
So if you have a private blockchain with something like Geth, it stores the data on your local hard disk in your home folder. However I think more specifically you are talking about smart contract storage. When you deploy solidity applications onto your private blockchain, internally they have storage variables, that get modified each time you send a transaction into it. Private blockchains you can have unlimited amounts of ether since you control it. If you want here is a piece of sample code which interacts with variables https://ethfiddle.com/lOvRUBOJso