13.06.2017 Views

Whitepaper - Ethereum Classic With Cover

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Ethereum</strong> <strong>Classic</strong> Documentation, Release 0.1<br />

Editing backend contract file<br />

By default, a new project contains a contract “Contract” for backend development on the blockchain using the<br />

Solidity language and the “index.html” for the frontend. Check the Solidity tutorial for references.<br />

Edit the empty default contract “Contract”, e.g.<br />

contract Rating {<br />

function setRating(bytes32 _key, uint256 _value) {<br />

ratings[_key] = _value;<br />

}<br />

mapping (bytes32 => uint256) public ratings;<br />

}<br />

Check the Solidity tutorial for help getting started with the solidity programming language.<br />

Save changes<br />

Editing frontend html files<br />

Select default index.html file and enter the following code<br />

.... <br />

function getRating() {<br />

var param = document.getElementById(“query”).value;<br />

var res = contracts[“Rating”].contract.ratings(param);<br />

document.getElementById(“queryres”).innerText = res;<br />

}<br />

function setRating() {<br />

var key = document.getElementById("key").value;<br />

var value = parseInt(document.getElementById("value").value);<br />

var res = contracts["Rating"].contract.setRating(key, value);<br />

}<br />

<br />

<br />

<br />

Ratings<br />

<br />

Store:<br />

<br />

<br />

Save<br />

<br />

<br />

Query:<br />

<br />

<br />

<br />

<br />

<br />

Then it is possible to add many contract files as well as many HTML, JavaScript, css files<br />

Scenarios Editor<br />

Scenarios can be used to test and debug contracts.<br />

A scenario is effectively a local blockchain where blocks can be mined without PoW – otherwise testing would be<br />

quite slow ;).<br />

A scenario consists of a sequence of transactions. Usually, a scenario would start with the contract creation<br />

scenarios of the dapp. In addition, further transactions can be added to test and debug the dapp. Scenarios can be<br />

90 Chapter 1. Contents

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!