1

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.

2
  • What is the error message when you execute web3.eth.accounts?
    – Malone
    Dec 10, 2017 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, 2017 at 16:01

1 Answer 1

1

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

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

npm install [email protected]

0

Your Answer

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

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