aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Kotewicz <marek.kotewicz@gmail.com>2015-02-02 18:52:56 +0800
committerMarek Kotewicz <marek.kotewicz@gmail.com>2015-02-02 18:52:56 +0800
commit011fdd91df02abd7ee88bdef183186fe95eeeb18 (patch)
tree58e3bc08e0bd7271734ec59d09a03c9bcf5addce
parentd5166918e9ad5158ddd2f76866adb21b59393b96 (diff)
downloadgo-tangerine-011fdd91df02abd7ee88bdef183186fe95eeeb18.tar
go-tangerine-011fdd91df02abd7ee88bdef183186fe95eeeb18.tar.gz
go-tangerine-011fdd91df02abd7ee88bdef183186fe95eeeb18.tar.bz2
go-tangerine-011fdd91df02abd7ee88bdef183186fe95eeeb18.tar.lz
go-tangerine-011fdd91df02abd7ee88bdef183186fe95eeeb18.tar.xz
go-tangerine-011fdd91df02abd7ee88bdef183186fe95eeeb18.tar.zst
go-tangerine-011fdd91df02abd7ee88bdef183186fe95eeeb18.zip
event_inc example
-rw-r--r--example/event_inc.html66
1 files changed, 66 insertions, 0 deletions
diff --git a/example/event_inc.html b/example/event_inc.html
new file mode 100644
index 000000000..17df9d681
--- /dev/null
+++ b/example/event_inc.html
@@ -0,0 +1,66 @@
+<!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('http://localhost:8080'));
+
+ var source = "" +
+ "contract Contract { " +
+ " event Incremented(bool indexed odd, uint x); " +
+ " function Contract() { " +
+ " x = 69; " +
+ " } " +
+ " function inc() { " +
+ " ++x; " +
+ " Incremented(x % 2 == 1, x); " +
+ " } " +
+ " uint x; " +
+ "}";
+
+ var desc = [{
+ "type":"event",
+ "name":"Incremented",
+ "inputs": [{"name":"odd","type":"bool","indexed":true},{"name":"x","type":"uint","indexed":false}],
+ }, {
+ "type":"function",
+ "name":"inc",
+ "inputs": [],
+ "outputs": []
+ }];
+
+ var address;
+ var contract;
+
+ var update = function (x) {
+ document.getElementById('result').innerText = JSON.stringify(x);
+ };
+
+ var createContract = function () {
+ address = web3.eth.transact({code: web3.eth.solidity(source)});
+ contract = web3.eth.contract(address, desc);
+ contract.Incremented({odd: true}).changed(update);
+
+ };
+
+ var callContract = function () {
+ contract.call().inc();
+ };
+
+
+ </script>
+ </head>
+
+ <body>
+ <div>
+ <button type="button" onClick="createContract();">create contract</button>
+ </div>
+ <div>
+ <button type="button" onClick="callContract();">test1</button>
+ </div>
+ <div id="result">
+ </div>
+ </body>
+</html>