ETH-Pantheon / Aion

A system for Scheduling transactions with arbitrary bytecode on the Ethereum Network
https://www.aion.ethpantheon.com
MIT License
26 stars 13 forks source link

Looping over scheduleTransaction() #24

Closed Banksy-said-hi closed 3 years ago

Banksy-said-hi commented 3 years ago

Hi

I was struggling with looping over the scheduleTransaction() of your first sample contract which tries to send a eth transaction at some specified time or block.

I have developed a simple loop(for) logic to make multiple synced transactions, however, I am given this error: "the execution failed due to an exception"

Also, I have opened a question in ETHstackexchange. It would be great to have your opinion about this issue. https://ethereum.stackexchange.com/questions/114413/looping-over-scheduling-eth-transaction

This is my main scheduleTransaction() function ![Uploading Screen Shot 2021-11-27 at 5.24.14 PM.png…]()

And this is my second one, which is connected to the main function. However, it gives an error while getting executed for scheduling multiple transactions.

Screen Shot 2021-11-27 at 5 25 35 PM
Banksy-said-hi commented 3 years ago

I assume I have to provide enough gas while calling scheduletransaction(i) in my loop. But I'm not sure how to do it :(

jfdelgad commented 3 years ago

Hello Rahim

The example Recurrent transactions is what you need. The code that you are posting is not correct because it sends several request within a single transaction.

The way to get this to work is as in the example. First you schedule the transaction and after the number of blocks you requested, Aion smart contract sends your contract a transaction. This transactions call MyFunction (in the example) you can put there the code you need to execute (for instance sending ether) and then request another scheduling of a transaction and os on.

Notice that Aion creates an account for you (an smart contract) so you need to ensure that the call to MyFunction comes from that specific smart contract.

Banksy-said-hi commented 3 years ago

You are an angel. Thanks