1

Is there a call scheduling service that lets you schedule a call at a time in the future not predictable by someone with access to contract code and transaction details?

The scheduling services I've heard are Ethereum Alarm Clock, Oraclize, and Aion. Oraclize does offer random number generation as a service as well as function call scheduling, but I don't see how the two can be combined.

One solution I thought of is to have the call happen with higher frequency than desired, and only do actual execution if some random conditions are met, but that loses a lot of unpredictability, and is also very wasteful with gas.

1 Answer 1

0

Yes. You can use a Chainlink external adapter, Gelato Network, or Chainlink alarm clock to achieve this.

In all 3, you'll find that some kind of oracle is always needed. Let's look at an example of using a Chainlink external adapter to do this.


Let's say you have a function called addOne that you want to call at a random time, and a global variable called count.

public uint256 count;
function addOne() public {
        count = count + 1;
    }

And you wanted to call this at random times. You could make a Chainlink call to a node that has a sleep parameter identified. You'd identify that oracle's address and jobid in a function called randomlyCall which makes the request, and you'd specify addOne as the callback function when the oracle finishes the sleep duration. We would need to add some syntax to the addOne function to make sure only the chainlink oracle can randomly call it. We specify the addOne is the callback function in the 3rd parameter of the buildChainlinkRequest with: this.addOne.selector

public uint256 count;
function addOne(bytes32 _requestId) public recordChainlinkFulfillment(_requestId){
        count = count + 1;
    }

function randomlyCall() public {
Chainlink.Request memory req = buildChainlinkRequest(jobId, address(this), this.addOne.selector);
        sendChainlinkRequestTo(oracle, req, fee);
}

On the Chainlink side, we add an external adapter to the job specifications with some code to pick a random time. You could do this in nodejs for example with something like

index.js

const duration = Math.random() * ceiling
const wait = async () => {
  await sleep(duration)
}

wait()

You can learn more about external adapters here. Once you have this defined, you could have a network of Chainlink nodes run similar functions so that you're not depending on a centralized oracle to randomly call your function.

The only issue with this method is proving that the number the oracles come up with is random. You could use a Chainlink VRF to get a provably random number and use that as an input to your external adapter.

Note: I am a Chainlink developer advocate

2
  • Sadly, you didn't understand my question at all. As I mentioned, there are plenty of services out there providing FREE random number and function scheduling operations that were actually designed by developers rather than a philosophy Bsc who had never wrote a single line of code in his life ( github.com/SergeyDNazarov ), and don't even need paid marketing shills to have themselves be noticed and used by developers. The issue is that the 2 services cannot be combined. I cannot schedule a callback that happens at a time UNKNOWN until it is done.
    – qwerty
    Commented Oct 14, 2020 at 4:59
  • Let me edit the answer to make it more clear. Chainlink was engineered by an engineering team, Sergey is the co-founder, where the other co-founder is probably who you're looking for if you want an engineering face. You may also want to look at the research team including Ari Juels (former Chief Scientist of the RSA). You can see the code and repo here: github.com/smartcontractkit/chainlink. Shilling implies deceit in who you are, whereas the original answer and my bio clearly states who I am. I will edit the answer to hopefully be more helpful. Commented Oct 14, 2020 at 11:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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