The developer tool to use in this chapter is the BUIDL IDE. Just click on the link below from any browser!
In the contract tab.
pragma solidity >=0.4.0 <0.6.0;
contract SimpleStorage {
uint storedData;
function set(uint x) public {
storedData = x;
}
function get() public view returns (uint) {
return storedData;
}
}
In the dapp -> JS tab.
...
/* Don't modify */
var instance = null;
window.addEventListener('web3Ready', function() {
var contract = web3.ss.contract(abi);
instance = contract.at(cAddr);
});
document.querySelector("#s").addEventListener("click", function() {
var n = window.prompt("Enter the number:");
n && instance.set(n);
});
document.querySelector("#g").addEventListener("click", function() {
instance.get(function(e,d) {
console.log(d.toString());
alert(d.toString());
});
});In the dapp -> HTML tab.
<button id="s">Set Data</button>
<button id="g">Get Data</button>This optional. In the dapp -> CSS tab.
button {
background-color: #000;
color: #fff;
border: 0;
font-size: 1em;
}