I use exactly the example of web3js (here) to sign a text.

So, I generated a .js file asfollows :

Web3 = require("web3")
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));

web3.eth.personal.sign("Hello world", "0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe", "test password!")

However, I receive the following error message, when I run this file with Terminal (Ubuntu) as follows : node filename.js

Error message: https://ibb.co/j6HEUy

enter image description here

Even when I use web3.eth.sign instead of web3.eth.personal.sign, I receive the same error message :

Error: Invalid JSON RPC response: ""

UPDATE: I need to run testrpc before running the code. However, now I receive another error message as follows:

Error: Returned error: Error: cannot sign data; no private key

enter image description here

  • Hi @sas, did you figure out a solution? – fabdarice Sep 18 '18 at 21:41
  • @fabdarice Hi, apparently I must use MetaMask to sign a message, instead of using testRPC. – Questioner Sep 19 '18 at 10:44

Your Answer

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

Browse other questions tagged or ask your own question.