aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/mist/assets/ext/example/contract.html
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-01-28 17:58:56 +0800
committerobscuren <geffobscura@gmail.com>2015-01-28 17:58:56 +0800
commit94976d63ca7d12983aa75ed8cf04d4210a818b33 (patch)
treecbcc5af9d5109282ee2466467931aa3fd80592b3 /cmd/mist/assets/ext/example/contract.html
parentad5894e486f0c78606453a6aba38c6670b791a92 (diff)
parentcb47a9e97ff3f2dcd2d2e6f1a3d39709d6d6a24d (diff)
downloadgo-tangerine-94976d63ca7d12983aa75ed8cf04d4210a818b33.tar
go-tangerine-94976d63ca7d12983aa75ed8cf04d4210a818b33.tar.gz
go-tangerine-94976d63ca7d12983aa75ed8cf04d4210a818b33.tar.bz2
go-tangerine-94976d63ca7d12983aa75ed8cf04d4210a818b33.tar.lz
go-tangerine-94976d63ca7d12983aa75ed8cf04d4210a818b33.tar.xz
go-tangerine-94976d63ca7d12983aa75ed8cf04d4210a818b33.tar.zst
go-tangerine-94976d63ca7d12983aa75ed8cf04d4210a818b33.zip
Merge branch 'develop' into qt5.4
Diffstat (limited to 'cmd/mist/assets/ext/example/contract.html')
-rw-r--r--cmd/mist/assets/ext/example/contract.html73
1 files changed, 73 insertions, 0 deletions
diff --git a/cmd/mist/assets/ext/example/contract.html b/cmd/mist/assets/ext/example/contract.html
new file mode 100644
index 000000000..dccd1a64f
--- /dev/null
+++ b/cmd/mist/assets/ext/example/contract.html
@@ -0,0 +1,73 @@
+<!doctype>
+<html>
+
+<head>
+<script type="text/javascript" src="js/bignumber.js/bignumber.min.js"></script>
+<script type="text/javascript" src="../dist/ethereum.js"></script>
+<script type="text/javascript">
+
+ var web3 = require('web3');
+ web3.setProvider(new web3.providers.HttpSyncProvider());
+
+ // solidity source code
+ var source = "" +
+ "contract test {\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)",
+ "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.transact({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);
+
+ // call the contract
+ var res = contract.call().multiply(param);
+ document.getElementById('result').innerText = res.toString(10);
+ }
+
+</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" onkeyup='callExampleContract()'></input>
+ </div>
+ <div id="result"></div>
+</body>
+</html>
+