Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

155
Views
Promise { <pending> } in Web3

I need something help.. I'm trying to make an async request but the response is a Promise { <pending> }

This is my code

const getBalance = async (adress) => {
  try {
    let wei = await web3.eth.getBalance(address);
  } catch (err) {
    console.error(err);
  }
};

let balanceWallet = getBalance(address);
console.log(balanceWallet);

So when I run my code to debug it returns Promise { <pending> } I don't know what's wrong in my code

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

getBalance is an async function :) JS does not allow us to use async/await on the program top level but we can use then/catch to get promise result)

You just have to use (but before u have to change getBalance function and return promise there)

const getBalance = (adress) => web3.eth.getBalance(address);

getBalance(address)
.then(balanceWallet => {
  console.log(balanceWallet)
  // some logic with result
})
.catch(error => /** handle an error **/ )

I hope it helps! Enjoy programming!

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!