-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
40 lines (29 loc) · 1 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/**
* EXPANSE BLOCKNOTIFY
* Created by Christopher Franko on 12/18/2015.
* This nodejs app mimics bitcoins blocknotify, for expanse.
*/
//load modules
var requestify = require('requestify');
var Web3 = require('web3');
var web3 = new Web3();
var apiurl = 'http://yourcallbackurl';
//set expanse node
web3.setProvider(new web3.providers.HttpProvider('http://localhost:9656'));
var coinbase = web3.eth.coinbase;
console.log("coinbase: " + coinbase);
var balance = web3.eth.getBalance(coinbase);
console.log("balance: " + balance.toString(10));
var eth = web3.eth;
web3.eth.filter('latest').watch(function(error, block) {
if(error) {
console.log("watch err:", error);
return;
}
//send the block to the exp.life api
//TODO: make this dynamic based on if its expanse or ethereum
requestify.get( apiurl + block).then(function(response) {
// Get the response body (JSON parsed - JSON response or jQuery object in case of XML response)
response.getBody();
});
});