# Gateway

Gateway does two things mainly it accepts the tasks for preExecution for which it does payload hash verification and then logs out the new task for relayer to pick up and after the private computation it accepts the task for postExecution procedure where it does payload hash verification, result signature verification, packet signature verification and then call back the client with computed result for the task and logs out the task details. Initialize and updateRoute are periphary functions in which you can initialize a master verification address for the contract and then check the validity of the (route -> verification address) map for updateRoute and this map is to be stored onchain for postExecution validity checks.&#x20;

### Gateway Interface:

```solidity
interface IGateway {
    /// @notice Initialize the verification address
    /// @param _masterVerificationAddress The verification input address
    function initialize(address _masterVerificationAddress) external;
    
    /// @notice Updating the route
    /// @param _route                 Route name
    /// @param _verificationAddress   Address corresponding to the route
    /// @param _signature             Signed hashed inputs(_route + _verificationAddress)
    function updateRoute(string memory _route, address _verificationAddress, bytes memory _signature) external;
    
    /// @notice Pre-Execution
    /// @param _task                  Task struct
    /// @param _info                  ExecutionInfo struct
    function preExecution(Task memory _task, ExecutionInfo memory _info) external;
    
    /// @notice Post-Execution
    /// @param _taskId                Task Id of the executed message
    /// @param _sourceNetwork         Source network of the message
    /// @param _info                  PostExecutionInfo struct
    function postExecution(uint256 _taskId, string memory _sourceNetwork, PostExecutionInfo memory _info) external;
}
```

### Data Structs:

```solidity
struct Task {
        address callback_address;
        bytes4 callback_selector;
        address user_address;
        string source_network;
        string routing_info;
        bytes32 payload_hash;
        bool completed;
}

struct ExecutionInfo {
        bytes user_key;
        string routing_code_hash;
        string handle;
        bytes12 nonce;
        bytes payload;
        bytes payload_signature;
}

struct PostExecutionInfo {
        bytes32 payload_hash;
        bytes result;
        bytes32 result_hash;
        bytes result_signature;
        bytes32 packet_hash;
        bytes packet_signature;
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://fortress-labs.gitbook.io/snakepath/public-gateway/gateway.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
