0

Installed web3.js 1.0.0-beta.26 on macOS Running testrpc, Node.js based Ethereum client

After running node in my terminal and initiating the web3 object listening to port 8545:

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

I can only see my lists of accounts asynchronous like:

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

I want to do it synchronous like:

> web3.eth.accounts

Also for example web3.eth.getBalance() returns a promise. Where I before was able to run it synchronous.

I want to execute it like in this video: https://youtu.be/-5LhwoCcjp0?t=1m15s Is this because I have installed the latest version or is there a possibility to run it synchronous.

  • What is the error message when you execute web3.eth.accounts? – Malone Dec 10 '17 at 15:00
  • @Malone No error message. I get an accounts object. But I installed a previous version where I can use web3.eth.accounts and get the array of accounts. So I think it has to do with the new version.. – Robbert Dec 10 '17 at 16:01
1

No, currently web3 v1.0 only supports asynchronous operations.

You can install the previous version if you want synchronous behavior.

npm install web3@0.20

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.