1

So here's the contract that I deployed on Ropsten Network. I took code refer from here.

pragma solidity ^0.4.24;


// interface Aion 
contract Aion { 
    uint256 public serviceFee;
    function ScheduleCall(uint256 blocknumber, address to, uint256 value, uint256 gaslimit, uint256 gasprice, bytes data, bool schedType) public payable returns (uint,address);
}

// Main contract
contract MyContract{
uint256 public sqrtValue;
Aion aion;
uint256 public myData;

constructor(uint256 number) public payable{
    scheduleMyfucntion(number);
    myData = 1;
}

function scheduleMyfucntion(uint256 number) public {
    aion = Aion(0xFcFB45679539667f7ed55FA59A15c8Cad73d9a4E);
    bytes memory data = abi.encodeWithSelector(bytes4(keccak256('myfucntion(uint256)')),number); 
    uint callCost = 200000*1e9 + aion.serviceFee();
    aion.ScheduleCall.value(callCost)( block.timestamp + 10 minutes, address(this), 0, 200000, 1e9, data, true);
}

function myfucntion(uint256 number) public {
    // do your task here and call again the function to schedule
    myData = myData+1;
    scheduleMyfucntion(number);
} 

function getMyData() view public returns (uint256) {
    return myData;
}
function () public payable {}
}

The purpose of this contract is to schedule a call in every 10 minutes.

Expectations: myData variable should be incremented by one in every 10 minutes.

Actual: Unable to see any new transaction after successful deployment. Nor able to see the variable being incremented ever.

  • Can you please share the address of your deployed contract? – Jaime Dec 7 '18 at 10:06
  • Yes. I have redeployed the contract. Here's the address: 0x157b9c5fc098a3Ae144E32f5EB3498FfC0063635 – Gagan Dec 7 '18 at 10:29
  • Umm. It's strange but this newly deployed contract is working. :/ I did nothing but re-deployed it. – Gagan Dec 7 '18 at 10:46
  • Here's the list of contract addresses which didn't work till now.! 0x778a8a3d4fe72be32e2d6e95d07e5b1799c17069, 0xba034f3ae444bab679c252c83af7f558974872b6, 0x4409453f0a3ec2acce8d9e7ed6296024f5c9991e, 0x1bc58aea415db508aba290ea275a226c48c54861. – Gagan Dec 7 '18 at 10:50
  • 1
    Yes, I also deploy a new one [here]( ropsten.etherscan.io/address/…) and it works. It may have been some issue with Aions testnet server but the transactions should be picked up if they were not cancelled. – Jaime Dec 7 '18 at 10:52
1

I deployed the contract and it seems to work well. The only explanation could be that the server of the test network missed your request.

Also, your code uses a variable named number. I went through the link you posted and this seems to be only to show that you can send data together with your request, you are safe to remove that variable.

Hope this helps.

  • Thanks! I implemented this to my real project and deployed it successfully. First time it runs well but when it is called by Aion contract at the scheduled time later it reverts. Here's the Txn hash which failed. Any thought? :( – Gagan Dec 11 '18 at 11:00
  • 1
    I see that the schedule was executed and an attempt to reschedule fail. Checking the smart contract of Aion the only possibility that the request fails is that you do not send the correct amount of ether to pay for the transactions. Can you please share the code of your real project?. – Jaime Dec 11 '18 at 15:48
  • Did you solve this? – Jaime Dec 15 '18 at 12:04
  • Yes @Jaime thanks! I solved this. I made my function payable but never sent ethers to it when rescheduling happens. – Gagan Dec 17 '18 at 5:43
  • cool, if this helped you please accept the answer. – Jaime Dec 17 '18 at 7:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.