Saldo De y la cantidad recaudada no aumenta remitente una cuenta

¿Puede alguien darme una pista o corregir lo que está mal con el código? Tal vez sea obvio dónde está el error, pero no lo veo y estoy atascado. ¿Qué hacer a continuación?. El código está aquí: https://ropsten.etherscan.io/address/0xc3ec072c279043ad2e56f4b5683b78337ed614d9

function () payable public {  }

function buy () payable public whenNotPaused beforeDeadline afterStartTime saleNotClosed {
    require(msg.value >= minContribution);

    // Update the sender's balance of wei contributed and the amount raised
    uint amount = msg.value;
    uint currentBalance = balanceOf[msg.sender];
    balanceOf[msg.sender] = currentBalance.add(amount);
    amountRaised = amountRaised.add(amount);

    // Compute the number of tokens to be rewarded to the sender
    // Note: it's important for this calculation that both wei
    // and PDT have the same number of decimal places (18)
    uint numTokens = amount.mul(rate);

    // Transfer the tokens from the crowdsale supply to the sender
    if (tokenReward.transferFrom(tokenReward.owner(), msg.sender, numTokens)) {
        FundTransfer(msg.sender, amount, true);
        // Check if the funding goal or cap have been reached
        // TODO check impact on gas cost
        checkFundingGoal();
        checkFundingCap();
    }
    else {
        revert();
    }
}

que hacer para arreglarlo? (Remix Ropsten no actualiza el saldo del remitente).

Cualquier ayuda es muy apreciada. Robert

¿Dónde se consulta el saldo actualizado?
Hola, estoy usando Remix para llamar a balanceOf y la cantidad aumentó después de enviar algunos éteres al contrato de venta colectiva, pero no actualicé el saldo. ¿Alguna pista? Roberto

Respuestas (1)

Creo que el problema radica en el hecho de que la función function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; }devuelve un valor de los saldos de mapeo, pero está usando y actualizando el mapeo llamado balanceOf. Podría crear una nueva función que regrese balanceOf[msg.sender]para verificar si funciona.

Hola Gabe, veo que te refieres a la línea 171 en el contrato (contrato BasicToken). contract ERC20La línea básica 125 también tiene -function balanceOf(address who) public view return (uint256); Si tiene algo en mente sobre cómo debería verse la función, ¡ilumíname! no soy programador Traté de agregar la siguiente línea en mi función de compra; saldoDe[mensaje.remitente] = saldoDe[mensaje.remitente].add(cantidad); Lamentablemente sin éxito.