rudrakhp / KYC-chain

A blockchain based KYC registry prototype
MIT License
71 stars 36 forks source link

Unable to execute on Windows 10 #2

Open muhahassan opened 6 years ago

muhahassan commented 6 years ago

Hi, Configured all the prerequisites, node v = 9.5, npm v= 5.6.0 when I am trying to invoke the "node init.js" command from the root directory then facing the below issue:


PS C:\Hassan\Working Directory\Blockchain\KYC-chain-master\root> node -v v9.5.0 PS C:\Hassan\Working Directory\Blockchain\KYC-chain-master\root> npm -v 5.6.0 PS C:\Hassan\Working Directory\Blockchain\KYC-chain-master\root> node init.js C:\Hassan\Working Directory\Blockchain\node_modules\solc\soljson.js:1 (function (exports, require, module, filename, dirname) { var Module;if(!Module)Module=(typeof Module!=="undefined"?Module:null)||{};var moduleOverrides={};for(var key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var ENVIRONMENT_IS_WEB=typeof window==="object";var ENVIRONMENT_IS_WORKER=typeof importScripts== ="function";var ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof require==="function"&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;var ENVIRONMENT_IS_SHELL=!ENVIRONMEN T_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;if(ENVIRONMENT_IS_NODE){if(!Module["print"])Module["print"]=function print(x){process["stdout"].write(x+"\n")};if(!Mo dule["printErr"])Module["printErr"]=function printErr(x){process["stderr"].write(x+"\n")};var nodeFS=require("fs");var nodePath=require("path");Module["read"]=function read (filename,binary){filename=nodePath"normalize";var ret=nodeFS["readFileSync"](fi

TypeError: Cannot read property ':kyc' of undefined at Timeout.afterDelay [as _onTimeout] (C:\Hassan\Working Directory\Blockchain\KYC-chain-master\root\init.js:16:50) at ontimeout (timers.js:458:11) at tryOnTimeout (timers.js:296:5) at Timer.listOnTimeout (timers.js:259:5) PS C:\Hassan\Working Directory\Blockchain\KYC-chain-master\root>

Really appreciate your support.

Regards, Hassan

rudrakhp commented 6 years ago

Hey! I see your environment is set up alright. Could you try something I am going to suggest so that I get a better insight into the issue, because I think that before the compilation is done (line no. 8), the instance contract is being called (line no 16). Actually that is the reason I have introduced delays so that such issues don't come up. Instead of running the init.js file, try running the code in the node console, executing each line in order as given below. Respond with the results, the error if it's unsuccessful.

Cheers šŸ˜ƒ

var web3 = require('web3');
var fs = require('fs');
var solc  = require('solc');

web3 = new web3(new web3.providers.HttpProvider("http://localhost:8545"));
code = fs.readFileSync('kyc.sol').toString();
contract = solc.compile(code);

abiDefinition = JSON.parse(contract.contracts[':kyc'].interface);
byteCode = contract.contracts[':kyc'].bytecode;
kycContract = web3.eth.contract(abiDefinition);
deployedContract = kycContract.new({data: byteCode, from: web3.eth.accounts[0], gas: 4700000});
contractInstance = kycContract.at(deployedContract.address);
console.log(contractInstance.address);
muhahassan commented 6 years ago

Hello,

It seems that there is solidity compiler issue. I printed the log after the compiler call and it returns the error. First see the env setup:


PS C:\Hassan\Working Directory\Blockchain\KYC-chain-master\root> node -v v9.5.0 PS C:\Hassan\Working Directory\Blockchain\KYC-chain-master\root> npm -v 5.6.0 PS C:\Hassan\Working Directory\Blockchain\KYC-chain-master\root> npm list solc C:\Hassan\Working Directory\Blockchain -- truffle-solidity-loader@0.0.8 +-- ether-pudding@3.2.0 | +-- ethereumjs-testrpc@2.2.7 | |-- web3-provider-engine@8.6.1 | | -- *solc@0.4.19 extraneous* |-- solc@0.3.6 -- truffle@2.1.2 -- solc@0.4.8 extraneous

npm ERR! extraneous: solc@0.4.19 C:\Hassan\Working Directory\Blockchain\node_modules\web3-provider-engine\node_modules\solc npm ERR! extraneous: solc@0.4.8 C:\Hassan\Working Directory\Blockchain\node_modules\truffle\node_modules\solc PS C:\Hassan\Working Directory\Blockchain\KYC-chain-master\root>


Now, see the log printed, before invoking, I changed the version in kyc.sol from 0.4.4 to 0.4.19

-----------------------------------------------1 { errors: [ ':1:1: Error: Expected import directive or contract definition.\npragma solidity ^0.4.19;\n^\n' ] } -----------------------------------------------1.1 { errors: [ ':1:1: Error: Expected import directive or contract definition.\npragma solidity ^0.4.19;\n^\n' ] } -----------------------------------------------2 C:\Hassan\Working Directory\Blockchain\node_modules\solc\soljson.js:1 (function (exports, require, module, filename, dirname) { var Module;if(!Module)Module=(typeof Module!=="undefined"?Module:null)||{};var moduleOverrides={};for(var key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var ENVIRONMENT_IS_WEB=typeof window==="object";var ENVIRONMENT_IS_WORKER=typeof importScripts== ="function";var ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof require==="function"&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;var ENVIRONMENT_IS_SHELL=!ENVIRONMEN T_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;if(ENVIRONMENT_IS_NODE){if(!Module["print"])Module["print"]=function print(x){process["stdout"].write(x+"\n")};if(!Mo dule["printErr"])Module["printErr"]=function printErr(x){process["stderr"].write(x+"\n")};var nodeFS=require("fs");var nodePath=require("path");Module["read"]=function read (filename,binary){filename=nodePath"normalize";var ret=nodeFS["readFileSync"](fi

TypeError: Cannot read property ':kyc' of undefined at Timeout.afterDelay [as _onTimeout] (C:\Hassan\Working Directory\Blockchain\KYC-chain-master\root\init.js:22:50) at ontimeout (timers.js:458:11) at tryOnTimeout (timers.js:296:5) at Timer.listOnTimeout (timers.js:259:5) PS C:\Hassan\Working Directory\Blockchain\KYC-chain-master\root>


On Thu, Feb 8, 2018 at 3:50 PM, Rudrakh Panigrahi notifications@github.com wrote:

Hey! I see your environment is set up alright. Could you try something I am going to suggest so that I get a better insight into the issue, because I think that before the compilation is done (line no. 8), the instance contract is being called (line no 16). Actually that is the reason I have introduced delays so that such issues don't come up. Instead of running the init.js file, try running the code in the node console, executing each line in order as given below. Respond with the results, the error if it's unsuccessful.

var web3 = require('web3'); var fs = require('fs'); var solc = require('solc');

web3 = new web3(new web3.providers.HttpProvider("http://localhost:8545")); code = fs.readFileSync('kyc.sol').toString(); contract = solc.compile(code);

abiDefinition = JSON.parse(contract.contracts[':kyc'].interface); byteCode = contract.contracts[':kyc'].bytecode; kycContract = web3.eth.contract(abiDefinition); deployedContract = kycContract.new({data: byteCode, from: web3.eth.accounts[0], gas: 4700000}); contractInstance = kycContract.at(deployedContract.address); console.log(contractInstance.address);

ā€” You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rudrakh97/KYC-chain/issues/2#issuecomment-364088777, or mute the thread https://github.com/notifications/unsubscribe-auth/AhkBsHrhTEJkXi6jrButro5s3PiCqwG4ks5tSt-bgaJpZM4R-Jzu .

--

Thanks & Regards,

Muhammad Hassaan +971-561 643 694

muhahassan commented 6 years ago

As per your suggestion, executing the commands step by step, it is giving error on this line

contract = solc.compile(code);

contract = solc.compile(code); { errors: [ ':1:1: Error: Expected import directive or contract definition.\npragma solidity ^0.4.19;\n^\n' ] }

Hope, it will help you to sort out the problem.

Regards,

On Sun, Feb 11, 2018 at 9:54 AM, Muhammad Hassan hasssaan@gmail.com wrote:

Hello,

It seems that there is solidity compiler issue. I printed the log after the compiler call and it returns the error. First see the env setup:




PS C:\Hassan\Working Directory\Blockchain\KYC-chain-master\root> node -v v9.5.0 PS C:\Hassan\Working Directory\Blockchain\KYC-chain-master\root> npm -v 5.6.0 PS C:\Hassan\Working Directory\Blockchain\KYC-chain-master\root> npm list solc C:\Hassan\Working Directory\Blockchain -- truffle-solidity-loader@0.0.8 +-- ether-pudding@3.2.0 | +-- ethereumjs-testrpc@2.2.7 | |-- web3-provider-engine@8.6.1 | | -- *solc@0.4.19 extraneous* |-- solc@0.3.6 -- truffle@2.1.2 -- solc@0.4.8 extraneous

npm ERR! extraneous: solc@0.4.19 C:\Hassan\Working Directory\Blockchain\node_modules\web3-provider-engine\node_modules\solc npm ERR! extraneous: solc@0.4.8 C:\Hassan\Working Directory\Blockchain\node_modules\truffle\node_modules\solc PS C:\Hassan\Working Directory\Blockchain\KYC-chain-master\root>




Now, see the log printed, before invoking, I changed the version in kyc.sol from 0.4.4 to 0.4.19

-----------------------------------------------1 { errors: [ ':1:1: Error: Expected import directive or contract definition.\npragma solidity ^0.4.19;\n^\n' ] } -----------------------------------------------1.1 { errors: [ ':1:1: Error: Expected import directive or contract definition.\npragma solidity ^0.4.19;\n^\n' ] } -----------------------------------------------2 C:\Hassan\Working Directory\Blockchain\node_modules\solc\soljson.js:1 (function (exports, require, module, filename, dirname) { var Module;if(!Module)Module=(typeof Module!=="undefined"?Module:null)||{};var moduleOverrides={};for(var key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var ENVIRONMENT_IS_WEB=typeof window==="object";var ENVIRONMENT_IS_WORKER=typeof importScripts== ="function";var ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof require==="function"&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;var ENVIRONMENT_IS_SHELL=!ENVIRONMEN T_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER; if(ENVIRONMENT_IS_NODE){if(!Module["print"])Module["print"]=function print(x){process["stdout"].write(x+"\n")};if(!Mo dule["printErr"])Module["printErr"]=function printErr(x){process["stderr"].write(x+"\n")};var nodeFS=require("fs");var nodePath=require("path");Module["read"]=function read (filename,binary){filename=nodePath"normalize";var ret=nodeFS["readFileSync"](fi

TypeError: Cannot read property ':kyc' of undefined at Timeout.afterDelay [as _onTimeout] (C:\Hassan\Working Directory\Blockchain\KYC-chain-master\root\init.js:22:50) at ontimeout (timers.js:458:11) at tryOnTimeout (timers.js:296:5) at Timer.listOnTimeout (timers.js:259:5) PS C:\Hassan\Working Directory\Blockchain\KYC-chain-master\root>




On Thu, Feb 8, 2018 at 3:50 PM, Rudrakh Panigrahi < notifications@github.com> wrote:

Hey! I see your environment is set up alright. Could you try something I am going to suggest so that I get a better insight into the issue, because I think that before the compilation is done (line no. 8), the instance contract is being called (line no 16). Actually that is the reason I have introduced delays so that such issues don't come up. Instead of running the init.js file, try running the code in the node console, executing each line in order as given below. Respond with the results, the error if it's unsuccessful.

var web3 = require('web3'); var fs = require('fs'); var solc = require('solc');

web3 = new web3(new web3.providers.HttpProvider("http://localhost:8545")); code = fs.readFileSync('kyc.sol').toString(); contract = solc.compile(code);

abiDefinition = JSON.parse(contract.contracts[':kyc'].interface); byteCode = contract.contracts[':kyc'].bytecode; kycContract = web3.eth.contract(abiDefinition); deployedContract = kycContract.new({data: byteCode, from: web3.eth.accounts[0], gas: 4700000}); contractInstance = kycContract.at(deployedContract.address); console.log(contractInstance.address);

ā€” You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rudrakh97/KYC-chain/issues/2#issuecomment-364088777, or mute the thread https://github.com/notifications/unsubscribe-auth/AhkBsHrhTEJkXi6jrButro5s3PiCqwG4ks5tSt-bgaJpZM4R-Jzu .

--

Thanks & Regards,

Muhammad Hassaan +971-561 643 694

--

Thanks & Regards,

Muhammad Hassaan +971-561 643 694

muhahassan commented 6 years ago

Even though I revert the changes regarding version from 0.4.4 but still facing the same issue.

On Sun, Feb 11, 2018 at 9:57 AM, Muhammad Hassan hasssaan@gmail.com wrote:

As per your suggestion, executing the commands step by step, it is giving error on this line

contract = solc.compile(code);

contract = solc.compile(code); { errors: [ ':1:1: Error: Expected import directive or contract definition.\npragma solidity ^0.4.19;\n^\n' ] }

Hope, it will help you to sort out the problem.

Regards,

On Sun, Feb 11, 2018 at 9:54 AM, Muhammad Hassan hasssaan@gmail.com wrote:

Hello,

It seems that there is solidity compiler issue. I printed the log after the compiler call and it returns the error. First see the env setup:




PS C:\Hassan\Working Directory\Blockchain\KYC-chain-master\root> node -v v9.5.0 PS C:\Hassan\Working Directory\Blockchain\KYC-chain-master\root> npm -v 5.6.0 PS C:\Hassan\Working Directory\Blockchain\KYC-chain-master\root> npm list solc C:\Hassan\Working Directory\Blockchain -- truffle-solidity-loader@0.0.8 +-- ether-pudding@3.2.0 | +-- ethereumjs-testrpc@2.2.7 | |-- web3-provider-engine@8.6.1 | | -- *solc@0.4.19 extraneous* |-- solc@0.3.6 -- truffle@2.1.2 -- solc@0.4.8 extraneous

npm ERR! extraneous: solc@0.4.19 C:\Hassan\Working Directory\Blockchain\node_modules\web3-provider-engine\node_modules\solc npm ERR! extraneous: solc@0.4.8 C:\Hassan\Working Directory\Blockchain\node_modules\truffle\node_modules\solc PS C:\Hassan\Working Directory\Blockchain\KYC-chain-master\root>




Now, see the log printed, before invoking, I changed the version in kyc.sol from 0.4.4 to 0.4.19

-----------------------------------------------1 { errors: [ ':1:1: Error: Expected import directive or contract definition.\npragma solidity ^0.4.19;\n^\n' ] } -----------------------------------------------1.1 { errors: [ ':1:1: Error: Expected import directive or contract definition.\npragma solidity ^0.4.19;\n^\n' ] } -----------------------------------------------2 C:\Hassan\Working Directory\Blockchain\node_modules\solc\soljson.js:1 (function (exports, require, module, filename, dirname) { var Module;if(!Module)Module=(typeof Module!=="undefined"?Module:null)||{};var moduleOverrides={};for(var key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var ENVIRONMENT_IS_WEB=typeof window==="object";var ENVIRONMENT_IS_WORKER=typeof importScripts== ="function";var ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof require==="function"&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;var ENVIRONMENT_IS_SHELL=!ENVIRONMEN T_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;if( ENVIRONMENT_IS_NODE){if(!Module["print"])Module["print"]=function print(x){process["stdout"].write(x+"\n")};if(!Mo dule["printErr"])Module["printErr"]=function printErr(x){process["stderr"].write(x+"\n")};var nodeFS=require("fs");var nodePath=require("path");Module["read"]=function read (filename,binary){filename=nodePath"normalize";var ret=nodeFS["readFileSync"](fi

TypeError: Cannot read property ':kyc' of undefined at Timeout.afterDelay [as _onTimeout] (C:\Hassan\Working Directory\Blockchain\KYC-chain-master\root\init.js:22:50) at ontimeout (timers.js:458:11) at tryOnTimeout (timers.js:296:5) at Timer.listOnTimeout (timers.js:259:5) PS C:\Hassan\Working Directory\Blockchain\KYC-chain-master\root>




On Thu, Feb 8, 2018 at 3:50 PM, Rudrakh Panigrahi < notifications@github.com> wrote:

Hey! I see your environment is set up alright. Could you try something I am going to suggest so that I get a better insight into the issue, because I think that before the compilation is done (line no. 8), the instance contract is being called (line no 16). Actually that is the reason I have introduced delays so that such issues don't come up. Instead of running the init.js file, try running the code in the node console, executing each line in order as given below. Respond with the results, the error if it's unsuccessful.

var web3 = require('web3'); var fs = require('fs'); var solc = require('solc');

web3 = new web3(new web3.providers.HttpProvider("http://localhost:8545")); code = fs.readFileSync('kyc.sol').toString(); contract = solc.compile(code);

abiDefinition = JSON.parse(contract.contracts[':kyc'].interface); byteCode = contract.contracts[':kyc'].bytecode; kycContract = web3.eth.contract(abiDefinition); deployedContract = kycContract.new({data: byteCode, from: web3.eth.accounts[0], gas: 4700000}); contractInstance = kycContract.at(deployedContract.address); console.log(contractInstance.address);

ā€” You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rudrakh97/KYC-chain/issues/2#issuecomment-364088777, or mute the thread https://github.com/notifications/unsubscribe-auth/AhkBsHrhTEJkXi6jrButro5s3PiCqwG4ks5tSt-bgaJpZM4R-Jzu .

--

Thanks & Regards,

Muhammad Hassaan +971-561 643 694

--

Thanks & Regards,

Muhammad Hassaan +971-561 643 694

--

Thanks & Regards,

Muhammad Hassaan +971-561 643 694

AN8991 commented 6 years ago

Did you try and install the solc compiler again in the root folder? Sometimes it maybe an issue with the compiler itself. If not tried yet please run the below command and check if issue persists. npm install --save solc