Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Fix not working example of get "eth_accounts" #2572

Closed

Conversation

MatthieuScarset
Copy link
Contributor

Cannot use await inside the server function when using Ganache as a JSON-RPC web server.

Cannot use await inside the server function when using Ganache as a JSON-RPC web server.
method: "eth_accounts",
params: []
});
}).then(accounts => console.log(accounts));

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be:

server.listen(PORT, async (err) => {
  if (err) throw err;
  console.log(`ganache listening on port ${PORT}...`);
  const provider = server.provider;
  const accounts = await provider.request({
    method: "eth_accounts",
    params: []
  });

@davidmurdoch
Copy link
Member

Thanks for bringing this to our attention. I'm closing in favor of: #2789

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants