2

i was following this nice tutorial to make simple Daap,and at one place i got stuck. I'm really newish to that, so hope someone could explain that. This is the link and the place where i get stuck,if you go thru link, is NodeJS Time section.

const Web3 = require('web3');
const net = require('net');
const compiledContract = require('./contracts/contractv1');

web3IPC = '/Users/jackschultz/Library/PrivEth/geth.ipc';
let web3 = new Web3(web3IPC, net);

const byteCode = compiledContract.byteCode;
const QuestionContract = new web3.eth.Contract(compiledContract.abi);

web3.eth.getCoinbase(function(err, cba) {
 coinbaseAddress = cba;
 console.log(coinbaseAddress);
});
const coinbasePassphrase = 'passphrase';

app.post('/', (req, res) => {
  const question = req.body.question;
  web3.eth.personal.unlockAccount(coinbaseAddress, coinbasePassphrase, function(err, uares) {
    QuestionContract.deploy({data: byteCode, arguments: 
}).send({from: coinbaseAddress, gas: 2000000})
     .on('receipt', function (receipt) {
         console.log("Contract Address: " + receipt.contractAddress);
         res.redirect('/questions?address=' + receipt.contractAddress);
    });
  });
});  

So here is a code, but i didn't got what i should do with that, where to save, what format should save. Im using win7 and do not have NodeJs, and what exactly that Path points to(Users/jackschultz/Library/PrivEth/geth.ipc) cause i did not find that path on my local machine,instead i have C:\Users\Administrator\AppData\Roaming\Ethereum which has geth and keystore folders ? So need the guide for execution steps. Unfortunately i couldn't reached out to the authour,so sorry for such a dumb question, but i was working with that tutorial for a long time, don't wanna stop in the middle.

  • This code runs ONLY in node.js server. And File path you want is the path of your blockchain. It either could be your local blockchain Ganache (test RPC) or you can use Ropsten or other testnet. – Yogesh - EtherAuthority.io Nov 27 '18 at 14:40
1

This is Nodejs code. It sounds like your system doesn't meet the requirements for the tutorial. You'll need to install NodeJS on your system, and Geth as well, if you want to follow the tutorial exactly.

It would be much easier for you to sign up with Infura, and configure web3 to use that as the provider instead of Geth, especially if you're just starting out.

Using Geth means to sync and run a full ethereum node on your machine, which can take days to download. Infura is a service which does that for you, so you can simply access an ethereum node without having to run it yourself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.