diff options
author | Marian Oancea <contact@siteshop.ro> | 2014-11-06 01:46:01 +0800 |
---|---|---|
committer | Marian Oancea <contact@siteshop.ro> | 2014-11-06 01:46:01 +0800 |
commit | 4be4db5e6cfdde4ba5c1243b2bafeb6bbae3643c (patch) | |
tree | c368675984eb642f13334f2e61f6401d58776863 /example | |
parent | 3e174a08790ca009a2107a3564b179ae1f036c33 (diff) | |
download | dexon-4be4db5e6cfdde4ba5c1243b2bafeb6bbae3643c.tar dexon-4be4db5e6cfdde4ba5c1243b2bafeb6bbae3643c.tar.gz dexon-4be4db5e6cfdde4ba5c1243b2bafeb6bbae3643c.tar.bz2 dexon-4be4db5e6cfdde4ba5c1243b2bafeb6bbae3643c.tar.lz dexon-4be4db5e6cfdde4ba5c1243b2bafeb6bbae3643c.tar.xz dexon-4be4db5e6cfdde4ba5c1243b2bafeb6bbae3643c.tar.zst dexon-4be4db5e6cfdde4ba5c1243b2bafeb6bbae3643c.zip |
Converted to node module
Converted to npm package
Added brower
Added browserify with minification
Updated Readme
Diffstat (limited to 'example')
-rw-r--r-- | example/index.html | 42 | ||||
-rw-r--r-- | example/node-app.js | 16 |
2 files changed, 58 insertions, 0 deletions
diff --git a/example/index.html b/example/index.html new file mode 100644 index 000000000..87bc360fd --- /dev/null +++ b/example/index.html @@ -0,0 +1,42 @@ +<!doctype> +<html> + +<head> +<script type="text/javascript" src="js/es6-promise/promise.min.js"></script> +<script type="text/javascript" src="../dist/ethereum.min.js"></script> + +<script type="text/javascript"> +if (window.Promise === undefined) { + window.Promise = ES6Promise.Promise; +} +var web3 = require('web3'); + +//web3.setProvider(new web3.providers.QtProvider()); +web3.setProvider(new web3.providers.HttpRpcProvider("http://localhost:8080")); +// web3.setProvider(new web3.providers.WebSocketProvider("ws://localhost:40404/eth")); + +function testSnippet() { + web3.eth.watch({altered: web3.eth.coinbase}).changed(function() { + web3.eth.balanceAt(web3.eth.coinbase).then(function (balance) { + console.log(parseInt(balance,16)); + console.log(typeof balance); + document.getElementById("result").innerText = +balance; + }); + }); +} + +</script> +</head> + +<body> + +<h1>std::name_reg</h1> +<input type="text" id="name"></input> +<button type="button" onClick="testSnippet();">test snippet</button> + +<div></div> +result: <div id="result"></div> + +</body> + +</html> diff --git a/example/node-app.js b/example/node-app.js new file mode 100644 index 000000000..f63fa9115 --- /dev/null +++ b/example/node-app.js @@ -0,0 +1,16 @@ +#!/usr/bin/env node + +require('es6-promise').polyfill(); + +var web3 = require("../index.js"); + +web3.setProvider(new web3.providers.HttpRpcProvider('http://localhost:8080')); + +web3.eth.coinbase.then(function(result){ + console.log(result); + return web3.eth.balanceAt(result); +}).then(function(balance){ + console.log(web3.toDecimal(balance)); +}).catch(function(err){ + console.log(err); +});
\ No newline at end of file |