This is the contract code.
pragma solidity ^0.4.2;
contract SimpleStorage {
uint storedData;
function set(uint x) {
storedData = x;
}
function get() constant returns (uint retVal) {
return storedData;
}
}
This is the javascript code used (index.js)
var addToLog = function(txt) {
$(".logs").append("<br>" + txt);
};
$(document).ready(function() {
$("button.set").click(function() {
var value = parseInt($("input.text").val(), 10);
SimpleStorage.set(value);
addToLog("SimpleStorage.set(" + value + ")");
});
$("button.get").click(function() {
SimpleStorage.get().then(function(value) {
$(".value").html(value.toNumber());
});
addToLog("SimpleStorage.get()");
});
});
This is the code for html file(index.html)
<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 value in the blockchain</h3>
<div class="form-group form-inline">
<input type="text" class="text form-control" >
<input type="text" class="text form-control">
<button class="set btn btn-primary">Set Value</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 Value</button>
</div>
<h3> 3. Contract Calls </h3>
<div class="logs">
<p>Javascript call being made: </p>
</div>
</body>
</html>
I am trying to integrate ipfs for storing 'x' in ipfs.I am using embark framework for developing the dapp.
I have installed ipfs-api using npm as follows.
npm install --save ipfs-api
Then i have updated the above index.js with following lines
var ipfsAPI = require('ipfs-api')
// connect to ipfs daemon API server
var ipfs = ipfsAPI('localhost', '5001', {protocol: 'http'})
what are the further modifications required in index.js and index.html files for storing and retrieving the value using ipfs?