Trabajando con Chainlink Alarm Clock , fulfill()
parece que mi método nunca se llama. Entonces, para el ejemplo de documentos (a continuación), votingLive
nunca se vuelve a establecer en falso después de que se acabe el tiempo. Todo lo demás funciona y he llegado a este punto con los oráculos de rinkeby y kovan en remix y localmente, todos con el mismo problema.
No se agrega ningún retardo de tiempo y la función no se ejecuta.
pragma solidity ^0.6.0;
import "@chainlink/contracts/src/v0.6/ChainlinkClient.sol";
contract ChainlinkTimedVote is ChainlinkClient
{
uint private oraclePayment;
address private oracle;
bytes32 private jobId;
uint private yesCount;
uint private noCount;
bool private votingLive;
mapping(address => bool) public voters;
//only the contract owner should be able to start voting
address payable owner;
modifier onlyOwner {
require(msg.sender == owner);
_;
}
constructor() public {
setPublicChainlinkToken();
owner = msg.sender;
oraclePayment = 0.1 * 10 ** 18; // 0.1 LINK
//Rinkeby alarm oracle
oracle = 0x7AFe1118Ea78C1eae84ca8feE5C65Bc76CcF879e;
jobId = "4fff47c3982b4babba6a7dd694c9b204";
//initialize votes
yesCount = 0;
noCount = 0;
votingLive = false;
}
function startVote(uint voteMinutes) public onlyOwner {
Chainlink.Request memory req = buildChainlinkRequest(jobId, address(this), this.fulfill.selector);
req.addUint("until", now + voteMinutes * 1 minutes);
//Start voting window then submit request to sleep for $voteMinutes
votingLive = true;
sendChainlinkRequestTo(oracle, req, oraclePayment);
}
//Callback for startVote request
function fulfill(bytes32 _requestId) public recordChainlinkFulfillment(_requestId) {
//$voteMinutes minutes have elapsed, stop voting
votingLive = false;
}
//Increments appropriate vote counter if voting is live
function vote(bool voteCast) public {
require(!voters[msg.sender], "already Voted!");
//if voting is live and address hasn't voted yet, count vote
if(voteCast) {yesCount++;}
if(!voteCast) {noCount++;}
//address has voted, mark them as such
voters[msg.sender] = true;
}
//Outputs current vote counts
function getVotes() public view returns (uint yesVotes, uint noVotes) {
return(yesCount, noCount);
}
function isVotingLive() public view returns (bool) {
return votingLive;
}
//Lets user know if their vote has been counted
function haveYouVoted() public view returns (bool) {
return voters[msg.sender];
}
}
¿Quizás estoy creando mal la solicitud?
Chainlink.Request memory req = buildChainlinkRequest(jobId, address(this), this.fulfill.selector);
req.addUint("until", now + voteMinutes * 1 minutes);
volteando
votingLive = true;
sendChainlinkRequestTo(oracle, req, oraclePayment);
a
sendChainlinkRequestTo(oracle, req, oraclePayment);
votingLive = true;
También estoy notando que no se está agregando ningún retraso de tiempo.
Parece que puede haber un problema con los nodos en los documentos actuales de Chainlink. Pruebe este nodo (en Kovan) y trabaje en su lugar:
Dirección de Oracle = 0xAA1DC356dc4B18f30C347798FD5379F3D77ABC5b
trabajoId = 982105d690504c5d9ce374d040c08654
Para referencia futura, busqué trabajos similares en market.link: https://market.link/search/all?network=42&search=Alarm%20Clock
Los documentos se actualizarán.
Extraño planeta
patricio collins
votinglive
primero en verdadero? ¿Solo para asegurarse de que está recibiendo una respuesta?