Converted to node module
Converted to npm package Added brower Added browserify with minification Updated Readme
This commit is contained in:
42
example/index.html
Normal file
42
example/index.html
Normal file
@ -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>
|
16
example/node-app.js
Normal file
16
example/node-app.js
Normal file
@ -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);
|
||||
});
|
Reference in New Issue
Block a user