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 payable
una 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);
}
}
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 payable
modificador. Si no implementa una payable
funció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 {}
0xcafe
el feto
0xcafe