I am trying to understand the Aion scheduling system, so I tried their code example from here.

Below is the code snippet:

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;

    function schedule_rqsr(uint256 number) public {
        aion = Aion(0xFcFB45679539667f7ed55FA59A15c8Cad73d9a4E);
        bytes memory data = abi.encodeWithSelector(bytes4(keccak256('sqrt(uint256)')),number);
        uint callCost = 200000*1e9 + aion.serviceFee();
        aion.ScheduleCall.value(callCost)( block.number+15, address(this), 0, 200000, 1e9, data, false);

    function sqrt(uint256 number) public {
        sqrtValue = number**2;

    function () public payable {}


The contract is deployed successfully at ropsten address 0x91FDda60342d55B249A05083A5e9cB8102674D05

I am facing an issue while initiating the function schedule_rqsr. When this function is triggered, I face this error of "Gas Estimation Failed"

Gas Limit: 3,000,000

Find the error screenshot here: enter image description here


Typically when you are warned that gas estimation failed it's only that: a warning. It means the system tries to estimate how much gas you should provide (what should be the gas limit) but it fails. In that case you probably have to provide the gas limit manually and just send the transaction. Everything will work just fine if you provide big enough a gas limit.

The gas estimation may fail due to various reasons but it will fail deterministically; meaning that it will fail every time for the same contract and function call. Typically the contract has either too complicated inner logic or it calls external contracts and this causes the estimation to fail.

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.