¿Por qué la transferencia de fondos rompe el contrato?

Mi contrato implementado llamó con éxito solo por "invocación de función" a través de web3 o Remix. Pero siempre fallaba cuando enviaba fondos al contrato.

Pensé que el único requisito de que el contrato tenga payableuna función, pero tal vez no sea suficiente.

El contrato se parece a:

contract GetRandom is usingOraclize {
    event newRandomNumber(bytes);

    function GetRandom() {
        oraclize_setProof(proofType_Ledger);
        update();
    }

    function __callback(bytes32 _queryId, string _result, bytes _proof) oraclize_randomDS_proofVerify(_queryId, _result, _proof) {
        // if we reach this point successfully, it means that the attached authenticity proof has passed!
        if (msg.sender != oraclize_cbAddress()) throw;

        newRandomNumber(bytes(_result));
    }

    function update() payable {
        uint N = 7; // number of random bytes we want the datasource to return
        uint delay = 0; // number of seconds to wait before the execution takes place
        uint callbackGas = 200000; // amount of gas we want Oraclize to set for the callback function

        // this function internally generates the correct oraclize_query and returns its queryId
        bytes32 queryId = oraclize_newRandomDSQuery(delay, N, callbackGas);
    }
}

Respuestas (2)

siempre fallaba cuando enviaba fondos al contrato

Esto suena como si intentara enviar Ether al contrato inteligente sin más datos y, por lo tanto, sin llamar a ninguna función específica. Si "simplemente envía Ether" al contrato inteligente, se invoca una función especial sin nombre llamada función de respaldo . En su caso, esta función alternativa también debe tener un payablemodificador. Si no implementa una payablefunción de respaldo usted mismo, no es posible "simplemente enviar Ether" al contrato inteligente.

Agregue este como respaldo, similar a lo que dijo Sebastian:

function() payable {}
¿Lanzar qué en el respaldo? ¿Por qué ayudaría esto?
Un respaldo es solo una función en blanco que se activa cuando alguien interactúa con el contrato sin una de las otras funciones especificadas. Entonces, por ejemplo, si alguien acaba de enviar dinero a la dirección del contrato, este respaldo solo recibiría los fondos en el contrato.
¿No hay un límite de gas en la ejecución de la función de respaldo?