-
Notifications
You must be signed in to change notification settings - Fork 3
/
server.js
34 lines (30 loc) · 916 Bytes
/
server.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
var Web3 = require('web3')
var jsonfile = require('jsonfile');
if (typeof web3 !== 'undefined') {
web3 = new Web3(web3.currentProvider);
} else {
web3 = new Web3(new Web3.providers.HttpProvider("http://192.168.27.101:8545"));
// web3 = new Web3(new Web3.providers.HttpProvider("http://eth.lightrains.com"));
}
var file = 'data/simple.geojson.json'
jsonfile.readFile(file, function(err, obj) {
for (var i = 0; i < obj.features.length; i++) {
var feature = obj.features[i];
saveGeojsonFeature(feature);
}
})
function saveGeojsonFeature (info) {
var txhash = web3.eth.sendTransaction({
from: process.env.COINBASE,
to: process.env.TOADDRES,
value: 1111,
data: web3.toHex(info)
});
console.log(txhash);
readGeojsonFeature(txhash);
}
function readGeojsonFeature(txhash) {
web3.eth.getTransaction(txhash, function(err, log) {
console.log(web3.toAscii(log.input));
})
}