3

When I invoke a method of web3.eth.personal I receive an error as follows:

> web3.eth.personal.getAccounts().then(console.log);
Promise {
  <pending>,
  domain: 
   Domain {
     domain: null,
     _events: 
      { removeListener: [Function: updateExceptionCapture],
        newListener: [Function: updateExceptionCapture],
        error: [Function: debugDomainError] },
     _eventsCount: 3,
     _maxListeners: undefined,
     members: [] } }
> (node:34481) UnhandledPromiseRejectionWarning: Error: Returned error: Method not found
    at Object.ErrorResponse (/home/s/node_modules/web3-core-helpers/src/errors.js:29:16)
    at /home/s/node_modules/web3-core-requestmanager/src/index.js:140:36
    at XMLHttpRequest.request.onreadystatechange (/home/s/node_modules/web3-providers-http/src/index.js:77:13)
    at XMLHttpRequestEventTarget.dispatchEvent (/home/s/node_modules/xhr2/lib/xhr2.js:64:18)
    at XMLHttpRequest._setReadyState (/home/s/node_modules/xhr2/lib/xhr2.js:354:12)
    at XMLHttpRequest._onHttpResponseEnd (/home/s/node_modules/xhr2/lib/xhr2.js:509:12)
    at IncomingMessage.<anonymous> (/home/s/node_modules/xhr2/lib/xhr2.js:469:24)
    at IncomingMessage.emit (events.js:185:15)
    at IncomingMessage.emit (domain.js:440:23)
    at endReadableNT (_stream_readable.js:1106:12)
    at process._tickCallback (internal/process/next_tick.js:178:19)
(node:34481) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:34481) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Do I need to install or define any additional requirements ? Also I have installed web3-eth-personal as follows:

npm install web3-eth-personal

And then I use following commands:

var Personal = require('web3-eth-personal');
var personal = new Personal( new Personal.providers.HttpProvider("http://localhost:8545"));
web3.eth.personal.getAccounts().then(console.log);

PS. I found the solution: I started the Parity with Parity --chain tobalaba --jsonrpc-hosts all --jsonrpc-interface all --jsonrpc-cors '*' --jsonrpc-apis 'web3,eth,net,parity,traces,rpc,parity_set,personal' and now it works.

1
  • Could you give me some hints, what is that parity part? where do I do that when I use Cloudflare as provider?
    – Suisse
    Apr 5, 2021 at 18:36

3 Answers 3

3

For parity : As documented in the options, available under parity --help not all API’s are exposed by default. However you can simply enable them by running parity with the flag: --jsonrpc-apis APIS exp :

parity --jsonrpc-apis web3,rpc,personal,parity_accounts,eth,net,parity,parity_set,signer 

for geth start your geth with --rpcapi "eth,net,web3,personal"

1
  • for using websocket rpc instead of json rpc in Geth, replace flag --jsonrpc with --wsrpc
    – Rafid
    Oct 17, 2019 at 7:21
2

I used web3.personal directly and i was able to access the methods inside it again.

This is weird because in the console, web3.eth.personal is still what works but in the script for a browser, it doesn't

I hope this helps.

0

GetAccounts() or accounts, is a method of eth :

web3.eth.getAccounts().then(console.log);

otherwise, with personal you can create a new account, sign a transaction on another node (not locally) so make sure it is secure.

hope that helps

Phill

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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