Request Factory¶
-
class
RequestFactory¶
Introduction¶
The RequestFactory contract is the lowest level API for creating
transaction requests. It handles:
- Validation and Deployment of
TransactionRequestcontracts- Tracking of all addresses that it has deployed.
This contract is designed to allow tuning of all transaction parameters and is probably the wrong API to integrate with if your goal is to simply schedule transactions for later execution. The Request Factory API is likely the right solution for these use cases.
Interface¶
pragma solidity 0.4.19;
contract RequestFactoryInterface {
event RequestCreated(address request, address indexed owner);
function createRequest(address[3] addressArgs,
uint[12] uintArgs,
bytes callData)
public payable returns (address);
function createValidatedRequest(address[3] addressArgs,
uint[12] uintArgs,
bytes callData)
public payable returns (address);
function validateRequestParams(address[3] addressArgs,
uint[12] uintArgs,
bytes callData,
uint endowment)
public view returns (bool[6]);
function isKnownRequest(address _address)
public view returns (bool);
}
Events¶
-
RequestFactory.RequestCreated(address request)¶
The RequestCreated event will be logged for each newly created
TransactionRequest.
-
RequestFactory.ValidationError(uint8 error)¶
The ValidationError event will be logged when an attempt is made to create
a new TransactionRequest which fails due to validation errors. The error represents an error code that maps to the following errors.
0 => InsufficientEndowment1 => ReservedWindowBiggerThanExecutionWindow2 => InvalidTemporalUnit3 => ExecutionWindowTooSoon4 => CallGasTooHigh5 => EmptyToAddress
Function Arguments¶
Because of the call stack limitations imposed by the EVM, all of the following
functions on the RequestFactory contract take their arguments in the
form of the following form.
address[3] _addressArgsuint256[11] _uintArgsbytes _callData
The arrays map to to the following TransactionRequest attributes.
- Addresses (
address) _addressArgs[0] => meta.owner_addressArgs[1] => paymentData.feeRecipient_addressArgs[2] => txnData.toAddress
- Addresses (
- Unsigned Integers (
uintakauint256) _uintArgs[0] => paymentData.fee_uintArgs[1] => paymentData.payment_uintArgs[2] => schedule.claimWindowSize_uintArgs[3] => schedule.freezePeriod_uintArgs[4] => schedule.reservedWindowSize_uintArgs[5] => schedule.temporalUnit_uintArgs[6] => schedule.windowStart_uintArgs[7] => schedule.windowSize_uintArgs[8] => txnData.callGas_uintArgs[9] => txnData.callValue_uintArgs[10] => txnData.gasPrice
- Unsigned Integers (
Validation¶
-
RequestFactory.validateRequestParams(address[3] _addressArgs, uint[11] _uintArgs, bytes _callData, uint _endowment) public returns (bool[6] result)¶
The validateRequestParams function can be used to validate the parameters
to both createRequest and createValidatedRequest. The additional
parameter endowment should be the amount in wei that will be sent during
contract creation.
This function returns an array of bool values. A true means that the
validation check succeeded. A false means that the check failed. The
result array’s values map to the following validation checks.
Check #1: Insufficient Endowment¶
result[0]
Checks that the provided endowment is sufficient to pay for the fee
and payment as well as gas reimbursment.
The required minimum endowment can be computed as the sum of the following:
callValueto provide the ether that will be sent with the transaction.2 * paymentto pay for maximum possible payment2 * feeto pay for maximum possible feecallGas * txnData.gasPriceto pay forcallGas.180000 * txnData.gasPriceto pay for the gas overhead involved in transaction execution.
Check #2: Invalid Reserved Window¶
result[1]
Checks that the reservedWindowSize is less than or equal to windowSize +
1.
Check #3: Invalid Temporal Unit¶
result[2]
Checks that the temporalUnit is either 1 to specify block based scheduling,
or 2 to specify timestamp based scheduling.
Check #4: Execution Window Too Soon¶
result[3]
Checks that the current now value is not greater than windowStart -
freezePeriod.
- When using block based scheduling,
block.numberis used for thenowvalue. - When using timestamp based scheduling,
block.timestampis used.
Check #5: Call Gas too high¶
result[5]
Check that the specified callGas value is not greater than the current
gasLimit - 140000 where 140000 is the gas overhead of request
execution.
Check #6: Empty To Address¶
result[6]
Checks that the toAddress is not the null address
0x0000000000000000000000000000000000000000.
Creation of Transaction Requests¶
-
RequestFactory.createRequest(address[3] _addressArgs, uint[11] _uintArgs, bytes _callData) public payable returns (address)¶
This function deploys a new TransactionRequest contract. This
function does not perform any validation and merely directly deploys the new
contract.
Upon successful creation the RequestCreated event will be logged.
-
RequestFactory.createValidatedRequest(address[3] _addressArgs, uint[11] _uintArgs, bytes _callData) public payable returns (address)¶
This function first performs validation of the provided arguments and then
deploys the new TransactionRequest contract when validation succeeds.
When validation fails, a ValidationError event will be logged for each
validation error that occured.
Tracking API¶
-
RequestFactory.isKnownRequest(address _address) returns (bool)¶
This method will return true if the address is a
TransactionRequest that was created from this contract.