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

297
Views
Asynchronous and synchronous problems in bootstrap-table callback function
<link href="https://unpkg.com/bootstrap-table@1.19.1/dist/bootstrap-table.min.css" rel="stylesheet">
// link Jquery & Web3.js
<script src="https://unpkg.com/bootstrap-table@1.19.1/dist/bootstrap-table.min.js"></script>

<table
  id="table"
  data-toggle="table"
  data-height="460"
  data-url="json/data1.json">
  <thead>
    <tr>
      <th data-field="owner" data-formatter="ownerFormatter">Owner Address</th>
      <th data-field="balance" data-formatter="balanceFormatter">Balance</th>
    </tr>
  </thead>
</table>

<script>
  function ownerFormatter(value, row) {
    return '<span>'+value+'</span>';
  }

  async function balanceFormatter(value, row) {
    let wallet_address = row['owner'];
    let sss_balance = 0;
    //window.abi_json is defined elsewhere
    let MyContract = new web3.eth.Contract(window.abi_json,'0xC3028FbC1742a16A5D69dE1B334cbce28f5d7EB3');
    //According to the WEB3 document to read the balance of a certain currency online, console.log(sss_balance) can print the balance normally
    sss_balance = await MyContract.methods.balanceOf(wallet_address).call();
    //return balance
    return sss_balance;
  }
</script>

I want to make a table that lists user wallets and their balances in a certain currency on the Binance Smart Chain. The wallet addresses are all in data1.json, and the balance needs to be obtained from the chain in real time . The above balanceFormatter can print sss_balance normally in the function body, but can't return a normal floating point value. I know the reason for the error is that async can only return promise objects. Too bad

about 4 years ago · Juan Pablo Isaza
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!