Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

299
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda