local net

This commit is contained in:
Daniel Pollithy
2017-08-30 18:05:16 +02:00
parent c317875405
commit 1dff45ff43
3 changed files with 12 additions and 16 deletions
+5 -5
View File
@@ -6,9 +6,9 @@ if (process.argv.length < 5) {
}
// 1) get commandline argument: Is the drone's ethereum address
var drone_eth_address = process.argv[2];
var station_eth_address = process.argv[3];
var station_owner_eth_address = process.argv[4];
var drone_eth_address = process.argv[2].toLowerCase();
var station_eth_address = process.argv[3].toLowerCase();
var station_owner_eth_address = process.argv[4].toLowerCase();
@@ -116,8 +116,8 @@ contract.stopCharging({from: station_owner_eth_address}, (e, r) => {
var chargingStopped = contract.ChargingStopped();
chargingStopped.watch(function(error, result){
console.log(error, result);
var addr_station = result.args["_station"];
var addr_drone = result.args["_drone"];
var addr_station = result.args["_station"].toLowerCase();
var addr_drone = result.args["_drone"].toLowerCase();
if (addr_drone == drone_eth_address && addr_station == station_owner_eth_address) {
console.log("This is my booking (correct drone and station)");
process.exit(0);
+3 -7
View File
@@ -5,8 +5,8 @@ if (process.argv.length < 4) {
}
// 1) get commandline argument: Is the drone's ethereum address
var drone_eth_address = process.argv[2];
var station_eth_address = process.argv[3];
var drone_eth_address = process.argv[2].toLowerCase();
var station_eth_address = process.argv[3].toLowerCase();
@@ -19,10 +19,6 @@ web3 = new Web3(new Web3.providers.HttpProvider("http://192.168.1.120:8545"));
web3.personal.unlockAccount(drone_eth_address, "123", '0x249F0');
//'0x772dcb53b59fc61410aa0514bebce8a9bb1e8ed6'
var contractAddress = '0x3f629cee69c94b4e83b3b98ac129022a26ccc478';
var ABI = [{
"constant": true,
"inputs": [],
@@ -115,7 +111,7 @@ contract.register({from: drone_eth_address}, (e, r) => {
var registered = contract.Registered();
registered.watch(function(error, result){
console.log(error, result);
var addr_drone = result.args["_drone"];
var addr_drone = result.args["_drone"].toLowerCase();
var success = result.args["result"];
if (addr_drone == drone_eth_address) {
console.log("This is my booking");
+4 -4
View File
@@ -5,8 +5,8 @@ if (process.argv.length < 4) {
}
// 1) get commandline argument: Is the drone's ethereum address
var drone_eth_address = process.argv[2];
var station_eth_address = process.argv[3];
var drone_eth_address = process.argv[2].toLowerCase();
var station_eth_address = process.argv[3].toLowerCase();
@@ -110,8 +110,8 @@ contract.startCharging({from: drone_eth_address}, (e, r) => {
var chargingStarts = contract.ChargingStarts();
chargingStarts.watch(function(error, result){
console.log(error, result);
var addr_station = result.args["_station"];
var addr_drone = result.args["_drone"];
var addr_station = result.args["_station"].toLowerCase();
var addr_drone = result.args["_drone"].toLowerCase();
if (addr_drone == drone_eth_address && addr_station == station_eth_address) {
console.log("This is my booking (correct drone and station)");
process.exit(0);