Scheduler¶
-
class
Scheduler
¶
Introduction¶
The Scheduler
contract is the high level API for scheduling
transaction requests. It exposes a very minimal subset of the full parameters
that can be specified for a TransactionRequest
in order to provide a
simplified scheduling API with fewer foot-guns.
The Alarm service exposes two schedulers.
BlockScheduler
for block based scheduling.TimestampScheduler
for timestamp based scheduling.
Both of these contracts present an identical API. The only difference is which
temporalUnit
that each created TransactionRequest
contract is
configured with.
Interface¶
pragma solidity 0.4.24;
/**
* @title SchedulerInterface
* @dev The base contract that the higher contracts: BaseScheduler, BlockScheduler and TimestampScheduler all inherit from.
*/
contract SchedulerInterface {
function schedule(address _toAddress, bytes _callData, uint[8] _uintArgs)
public payable returns (address);
function computeEndowment(uint _bounty, uint _fee, uint _callGas, uint _callValue, uint _gasPrice)
public view returns (uint);
}
Defaults¶
The following defaults are used when creating a new TransactionRequest
contract via either Scheduler
contract.
feeRecipient
:0xecc9c5fff8937578141592e7E62C2D2E364311b8
which is the address of the developer contribution wallet, which is used to fund the project.payment
:1000000 * tx.gasprice
set at the time of scheduling.fee
:10000 * tx.gasprice
or 1/100th of the default payment.reservedWindowSize
: 16 blocks or 5 minutes.freezePeriod
: 10 blocks or 3 minutesclaimWindowSize
: 255 blocks or 60 minutes.
API¶
There is just one schedule
method on each Scheduler
contract with different call signatures. (Prior versions of the EAC had 2 API methods, we
reduced this down to only the full API to force specification of all parameters.)
-
Scheduler.
schedule
(address _toAddress, bytes _callData, uint[7] _uintArgs) public payable returns (address newRequest)¶
The _toAddress
is the recipient that the transaction will be sent to when it
is executed. The recipient can be any valid Ethereum address including both
user accounts and contracts. _callData
is the encoded bytecode that will be sent
with the transaction. Simple value transfers can set this variable to an empty string,
but more complex calls will need to encode the method of the inteded call and pass
it in this variable.
The _uintArgs
map to the following variables:
_uintArgs[0]
: ThecallGas
to be sent with the executing transaction._uintArgs[1]
: Thevalue
in wei to be sent with the transaction._uintArgs[2]
: ThewindowSize
, or size of the exeuction window._uintArgs[3]
: ThewindowStart
, or the block / timestamp of when the execution window begins._uintArgs[4]
: ThegasPrice
that must be sent with the executing transaction._uintArgs[5]
: Thefee
value attached to the transaction._uintArgs[6]
: Thepayment
value attached to the transaction.
The method returns the address
of the newly created TransactionRequest
.
Endowments¶
When scheduling a transaction, you must provide sufficient ether to cover all of the execution costs with some buffer to account for possible changes in the network gas price. See Check #1: Insufficient Endowment for more information on how to compute the endowment.