I am using Embark Framework.I am trying to store a string value in IPFS and then to retrieve that string using the hash.
Contract Code (simple_storage.sol) :-
pragma solidity ^0.4.7;
contract SimpleStorage {
string public storedData;
function SimpleStorage() {
storedData = "hello world";
}
function set(string x) {
storedData = x;
}
function get() constant returns (string x) {
return storedData;
}
}
Index.html Code :-
<html>
<head>
<title>Embark - SimpleStorage Demo</title>
<link rel="stylesheet" href="css/app.css">
<script src="js/app.js"></script>
</head>
<body class="container">
<h3>Embark - SimpleStorage Demo</h3>
<h3> 1. Set the string in the blockchain</h3>
<div class="form-group form-inline">
<input type="text" class="text form-control">
<button class="set btn btn-primary">Set String</button>
</div>
<h3> 2. Get the current value</h3>
<div class="form-group">
<div>
current value is <span class="value"></span>
</div>
<button class="get btn btn-primary">Get String</button>
</div>
</body>
</html>
Index.js Code :-
EmbarkJS.Messages.setProvider('orbit',{server: 'localhost', port: '5001'});
$(document).ready(function() {
$("button.set").click(function() {
var value = $("input.text").val();
EmbarkJS.Storage.saveText(value).then(function(hash) {
SimpleStorage.set(hash);
});
});
$("button.get").click(function() {
SimpleStorage.get().then(function(hash) {
EmbarkJS.Storage.get(hash).then(function(content) {
$(".value").html(content);
});
});
});
});
I am given a string as input and it returns string as output correctly.How can i verify the values stored in orbit db?
I have tried using 'ipfs' instead of 'orbit'.But the code won't get worked?What is the issue?