mirror of https://github.com/status-im/web3.js.git
removed natspec example, added namereg example
This commit is contained in:
parent
cd773fc92a
commit
60c9bf8176
|
@ -0,0 +1,41 @@
|
|||
<!doctype>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<script type="text/javascript" src="../dist/web3.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
var web3 = require('web3');
|
||||
web3.setProvider(new web3.providers.HttpProvider("http://localhost:8545"));
|
||||
|
||||
function onAddressKeyUp() {
|
||||
var address = document.getElementById('address').value;
|
||||
document.getElementById('nameOf').innerText = web3.eth.namereg.nameOf(address);
|
||||
};
|
||||
|
||||
function onNameKeyUp() {
|
||||
var name = document.getElementById('name').value;
|
||||
document.getElementById('addressOf').innerText = web3.eth.namereg.addressOf(name);
|
||||
};
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Namereg</h1>
|
||||
<h3>Search for name</h3>
|
||||
<div>
|
||||
<text>Address: </text>
|
||||
<input type="text" id="address" onkeyup='onAddressKeyUp()'></input>
|
||||
<text>Name: </text>
|
||||
<text id="nameOf"></text>
|
||||
</div>
|
||||
<h3>Search for address</h3>
|
||||
<div>
|
||||
<text>Name: </text>
|
||||
<input type="text" id="name" onkeyup='onNameKeyUp()'></input>
|
||||
<text>Address: </text>
|
||||
<text id="addressOf"></text>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,76 +0,0 @@
|
|||
<!doctype>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<script type="text/javascript" src="../dist/web3.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
var web3 = require('web3');
|
||||
web3.setProvider(new web3.providers.HttpProvider());
|
||||
|
||||
// solidity source code
|
||||
var source = "" +
|
||||
"contract test {\n" +
|
||||
" /// @notice Will multiply `a` by 7. \n" +
|
||||
" function multiply(uint a) returns(uint d) {\n" +
|
||||
" return a * 7;\n" +
|
||||
" }\n" +
|
||||
"}\n";
|
||||
|
||||
// contract description, this will be autogenerated somehow
|
||||
var desc = [{
|
||||
"name": "multiply(uint256)",
|
||||
"type": "function",
|
||||
"inputs": [
|
||||
{
|
||||
"name": "a",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "d",
|
||||
"type": "uint256"
|
||||
}
|
||||
]
|
||||
}];
|
||||
|
||||
var contract;
|
||||
|
||||
function createExampleContract() {
|
||||
// hide create button
|
||||
document.getElementById('create').style.visibility = 'hidden';
|
||||
document.getElementById('source').innerText = source;
|
||||
|
||||
// create contract
|
||||
var address = web3.eth.sendTransaction({code: web3.eth.solidity(source)});
|
||||
contract = web3.eth.contract(address, desc);
|
||||
document.getElementById('call').style.visibility = 'visible';
|
||||
}
|
||||
|
||||
function callExampleContract() {
|
||||
// this should be generated by ethereum
|
||||
var param = parseInt(document.getElementById('value').value);
|
||||
|
||||
// transaction does not return any result, cause it's not synchronous and we don't know,
|
||||
// when it will be processed
|
||||
contract.sendTransaction().multiply(param);
|
||||
document.getElementById('result').innerText = 'transaction made';
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>contract</h1>
|
||||
<div id="source"></div>
|
||||
<div id='create'>
|
||||
<button type="button" onClick="createExampleContract();">create example contract</button>
|
||||
</div>
|
||||
<div id='call' style='visibility: hidden;'>
|
||||
<input type="number" id="value"></input>
|
||||
<button type="button" onClick="callExampleContract()">Call Contract</button>
|
||||
</div>
|
||||
<div id="result"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
Reference in New Issue