I just started learning about Ethereum development.
I am trying to display values from a contract using the dappsforbeginners tutorial as a reference. It was stated that i must "grab the contracts address" from the pending pane. There were several addresses listed, i'm guessing the "contracts address" is the one under "Creates" right?
e.g. var contractAddress = "0x7AF909A9F6E5BFC0F3F45F25C13D300A86D186661D10FFF26AD5D32EE11328E0";
However, the following code returns nothing...
var contractString = JSON.stringify(web3.eth.storageAt(contractAddress));
Without JSON.stringify i am able to return an object (although i am unable to extract any useful info from it).
I looked at the API docs and i couldn't find the storageAt() method. Although i did find getStorageAt(). I assume getStorageAt() is out of date as it returns "TypeError: undefined is not a constructor". Is that right?
I'm confused. Any ideas what i can try?
Your advice would be greatly appreciated.
----------------------------------------
EDIT: I seem to get the error message "TypeError: undefined is not a constructor..." on many of the API calls.
Thanks Ken. Although i'm having issue getting any of the new api calls to work. I get "TypeError: undefined is not a constructor..." when i log it to the console. Is there something important that i'm missing?
Thanks Ken. Although i'm having issue getting any of the new api calls to work. I get "TypeError: undefined is not a constructor..." when i log it to the console. Is there something important that i'm missing?
I'm aware of the second argument. Thanks. The issue appears to be more general as i get the same error on most API calls. May i ask...are you able to get the API calls working?
I have been trying something like this...
var contractString = web3.eth.getStorageAt("0x42629d656cc04c77100b1ac794fc66183701b9f8", 0); document.getElementById('contractString').innerText = contractString;
BTW...if the documentation is outdated, any chance you could provide some kind of notice? Something big and bold perhaps?
@linagee You mentioned on a different thread that you had "abandoned trying to get alethzero working". Can you elaborate on this please? Why have you abandoned alethzero? By "go-ethereum", you're talking about Mist/Geth right?
Your assistance would be greatly appreciated. I really need something concrete to work with. If you give me something to learn, i can learn it. If you give me something which may become obsolete if the wind changes direction, then i'll give up and move on.
does anyone have any info? I'm assuming some test dapps have been developed and deployed right? so how did you do it? what tools did you use? can someone please guide me through some kind of "hello world" app where i am able to write the to the block chain and the pull it back out. Thanks!
However, I'm trying to display all variable values in the contract. There may not be getter functions in my case.
getStorageAt() works for number data types, but for strings, it's giving me the length of the string. How can I retrieve the actual value of the string?
Comments
I am working on updated tutorials - but they take time. In the meantime here is the API documentation:
https://github.com/ethereum/wiki/wiki/JavaScript-API
If not, a bit of code to replicate the error you were getting would help.
I have been trying something like this...
var contractString = web3.eth.getStorageAt("0x42629d656cc04c77100b1ac794fc66183701b9f8", 0);
document.getElementById('contractString').innerText = contractString;
BTW...if the documentation is outdated, any chance you could provide some kind of notice? Something big and bold perhaps?
@linagee You mentioned on a different thread that you had "abandoned trying to get alethzero working". Can you elaborate on this please? Why have you abandoned alethzero? By "go-ethereum", you're talking about Mist/Geth right?
Your assistance would be greatly appreciated. I really need something concrete to work with. If you give me something to learn, i can learn it. If you give me something which may become obsolete if the wind changes direction, then i'll give up and move on.
Normally, I'd write a getter in my contract and call that to return the value of a specific variable. Maybe that's all you need @givemecredit. See the SimpleStorage contract at https://github.com/iurimatias/embark-framework
However, I'm trying to display all variable values in the contract. There may not be getter functions in my case.
getStorageAt() works for number data types, but for strings, it's giving me the length of the string. How can I retrieve the actual value of the string?
I'm still curious if it's possible to retrieve string values using the getStorageAt() function in the web3 api?