Getting string value from a contract on a private ethereum network,

bryankim0199bryankim0199 Member Posts: 4
edited December 2015 in web3-js
var source = "contract SimpleStorage { string storedData; function set(string x) { storedData = x; } function get() constant returns (string) { return storedData; } }";

I have a code that allows a webpage to create a contract with the source above, and successfully mined the contract but when try to store and retrieve with the code.
function setExampleContract() { // this should be generated by ethereum var param = document.getElementById('value').value; // call the contract document.getElementById('status').innerText = "transaction sent, waiting for confirmation"; myContract.set(param, {data: code, gas: 1000000}, function (err, contract) { if(err) { console.error(err); return; // callback fires twice, we only want the second call when the contract is deployed } else if(contract.address){ myContract = contract; console.log('address: ' + myContract.address); document.getElementById('status').innerText = 'Mined!'; document.getElementById('call').style.visibility = 'visible'; document.getElementById('detail').innerText = contract.address; } }); } function getExampleContract() { var res = myContract.get(); document.getElementById('result').innerText = res; }
the code works when getting a uint data type (what i mean by this is to totally change the source and change all the data type with uint rather than string), but when trying to retrieve string it doesn't show the result? can anyone give me an advice on this or link me to a documentation for these kinds of projects
Sign In or Register to comment.