OVMGateway
Inherits: IOVMGateway
THIS IS AN EXAMPLE CONTRACT WHICH USES HARDCODED VALUES FOR CLARITY. THIS EXAMPLE USES UN-AUDITED CODE. DO NOT USE THIS CODE IN PRODUCTION.
State Variables
EXPIRYTIME
The time after which a request can be canceled
uint256 public constant EXPIRYTIME = 5 minutes;
_requestCount
uint256 internal _requestCount;
_commitments
a commitment is a request that has not been fulfilled yet
mapping(bytes32 requestId => Commitment commitment) internal _commitments;
_tokensInEscrow
Tokens sent for requests that have not been fulfilled yet
uint256 internal _tokensInEscrow;
Functions
sendRequest
Sends a request to execute a task.
function sendRequest(
address requester,
address callbackAddress,
bool deterministic,
bytes calldata data
) external payable override returns (bytes32 requestId);
Parameters
Name | Type | Description |
---|---|---|
requester | address | The address of the requester. |
callbackAddress | address | The address of the contract to receive the callback. |
deterministic | bool | Whether the request is deterministic. |
data | bytes | The data to be passed to the callback function. msg.value is the payment for the task. |
Returns
Name | Type | Description |
---|---|---|
requestId | bytes32 | The unique identifier for the request. |
cancelRequest
Cancels a request.
function cancelRequest(bytes32 requestId) external override;
Parameters
Name | Type | Description |
---|---|---|
requestId | bytes32 | The request ID to cancel. |
setResponse
Sets the response for a given requestId.
function setResponse(
bytes32 requestId,
bytes calldata data,
string calldata envProof,
string calldata inputProof,
string calldata outputProof,
string calldata rootProof
) external override;
Parameters
Name | Type | Description |
---|---|---|
requestId | bytes32 | The unique identifier for the request. |
data | bytes | The response data to be set. |
envProof | string | The environment proof to be set. |
inputProof | string | The input proof to be set. |
outputProof | string | The output proof to be set. |
rootProof | string | The root proof to be set. |
getSpecification
Gets the specification of the callback contract.
function getSpecification(address callbackAddress)
external
view
override
returns (Specification memory);
Parameters
Name | Type | Description |
---|---|---|
callbackAddress | address | The address of the callback contract. |
Returns
Name | Type | Description |
---|---|---|
<none> | Specification | specification The specification of the callback contract. |
getCommitments
Gets the commitments of a request.
function getCommitments(bytes32 requestId) external view override returns (Commitment memory);
Parameters
Name | Type | Description |
---|---|---|
requestId | bytes32 | The request ID to get the commitments for. |
Returns
Name | Type | Description |
---|---|---|
<none> | Commitment | commitments The commitments of the request. |
getRequestsCount
Gets the number of requests.
function getRequestsCount() external view override returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | count The number of requests. |
_transfer
transfer native tokens by a low-level call. _transfer should always be at the end of the function, to apply the checks-effects-interactions pattern
function _transfer(address to, uint256 amount) internal;