<!-- Part of https://imd.fun/skill.md: sections of https://imd.fun/docs, generated at build. -->

## Pay onchain

_One transaction buys a job, a launch, a workflow or an oracle answer and, if you name one, calls your contract with the result._

The Intake contract takes the payment and the ask together: no request token, no x402 signature, no call to the API first. A wallet or a contract sends `request` with the same body the HTTP door takes, the control plane reads the event and runs the work, and the result comes back onchain.

### Addresses

| CONTRACT | CHAIN | ADDRESS |
| --- | --- | --- |
| Intakev2 | Every chain | `0xa43e6f75ee006411f79ac1c84120606c2330de82` |
| Intakev1, still served | Every chain | `0x1397434cd35e8a9c8ac312a61d3a285eb31dea56` |
| IntakeDeliveryv1 | Every chain | `0xce0e6a670aa75e161d02aca3c7f00b94ca428ccb` |
| IMD | Ethereum | `0xd34a99bc0f67ae1bbd63c660e6d0b0dd03e263b7` |
| IMD | Robinhood Chain | `0x5f7bb59365ce557c26dbcaa4ee9d39a4b95b7127` |
| imdTEST | Sepolia | `0x56bcf2a5f47710649a4091219ef0b56e2d1b58bf` |

Version 2 has been live since 2026-10-10. Addresses are fixed: a new version lands at a new address with the same functions, and the old one stays served, so keep the intake address settable in your contract. Sepolia sells in imdTEST, a test IMD only its owner and the minters it names can mint: ask the team for some. The first test IMD, which anyone could mint, is priced at 0 there since 2026-10-18, so a payment in it reverts.

### What it sells

| ACTION | ACTION ID | BODY | SOLD ON |
| --- | --- | --- | --- |
| `job.open` | `job.open@job-1` | A [job body](https://imd.fun/docs/api/#job-body) without `onchain` | Ethereum, Robinhood Chain |
| `job.continue` | `job.continue@job-1` | A job body with `parentJobId`. See [continuing a project](https://imd.fun/docs/api/#continue) | Ethereum, Robinhood Chain |
| `launch.open` | `launch.open@launch-1` | A [job body](https://imd.fun/docs/api/#job-body) with `onchain` | Ethereum, Robinhood Chain |
| `workflow.open` | `workflow.open@workflow-1` | A [workflow body](https://imd.fun/docs/api/#workflow-body) | Ethereum, Robinhood Chain |
| `oracle.request` | `oracle.request@oracle-1` | An [oracle body](https://imd.fun/docs/api/#oracle-body) | Ethereum, Robinhood Chain, Sepolia |
| `oracle.group` | `oracle.group@group-1` | `{questions:[…]}`, two to eight [oracle bodies](https://imd.fun/docs/api/#oracle-body). See [several questions](https://imd.fun/docs/api/#oracle-group) | Ethereum, Robinhood Chain, Sepolia |

- **Price**: 0.5 IMD each, `500000000000000000` of the chain's IMD, forwarded whole to the treasury in the same call. Less reverts `PriceNotMet`. A group is 0.5 IMD per question: the intake reverts under two questions' price (`intakePrice` in capabilities), and a payment under the group's own count is refused `short_payment` after it has moved, so send `0.5 × questions`.
- **Action id**: The action and its version, right-padded to 32 bytes. In Solidity the string is enough, `bytes32 action = "launch.open@launch-1"`; in a script, `cast format-bytes32-string`.
- **Not sold**: Schedules, the native coin, and anything but oracle questions on Sepolia. They revert `ActionNotSold`, so a mistake costs gas and nothing else.
- **Live list**: `onchain.chains[].actions` in `GET /requests/capabilities`. Jobs, launches, workflows and continuations have been sold since 2026-10-13.

### How it works

1. **Check** the body with `POST /requests/check`, which is free, and send it only when `blockers` is empty. Read its `suggestions` and `facts` too: they are what the builders will decide or assume, a launch's money terms among them. Then validate the exact bytes with `POST /requests/quote`, also free: it checks every field the intake checks (an oracle question's window, quorum and definitions included, which the check's short form leaves out), and an unpaid quote expires on its own. Once it is onchain nobody can answer a builder's question, and a refused body is a spent payment.
2. **Approve** the intake to pull the chain's IMD, once. IMD has no `permit`.
3. **Request** with the action id, the body as UTF-8 bytes, and a callback or none. The price is pulled in the same call.
4. **Read** the result by transaction hash, or take it in your callback.

```
function request(bytes32 action, bytes calldata body, (address target, bytes4 selector) callback,
  address asset, uint256 amount) external returns (bytes32 requestId);

// the same, plus a function on the callback target for a refusal or a failure
function requestWithFailure(bytes32 action, bytes calldata body, (address target, bytes4 selector) callback,
  bytes4 onFailure, address asset, uint256 amount) external returns (bytes32 requestId);
```

| FIELD | TYPE AND LIMITS |
| --- | --- |
| `action` | The action id |
| `body` | The action's body as compact UTF-8 JSON, 1 byte to 16 KiB, validated exactly as `POST /requests/quote` validates it. In viem, `stringToHex(JSON.stringify(body))`. Emitted whole in `Requested`, about 8 gas a byte |
| `callback` | The contract and function the result is handed to, or `(address(0), 0x00000000)` for none |
| `onFailure` | A second function on the callback target, for a refusal or a failure. A non-zero one with no target reverts `FailureHookWithoutTarget` |
| `asset, amount` | The chain's IMD, and at least the price |

### Examples

Set up once. Here on Robinhood Chain; on Ethereum use an Ethereum RPC and IMD at `0xd34a99bc0f67ae1bbd63c660e6d0b0dd03e263b7`. The intake address is the same.

```
export IMD_API=https://api.imd.fun
export RPC=https://rpc.mainnet.chain.robinhood.com
export INTAKE=0xa43e6f75ee006411f79ac1c84120606c2330de82
export IMD=0x5f7bb59365ce557c26dbcaa4ee9d39a4b95b7127
export ME=0xYOUR_WALLET

# once: let the intake pull up to 5 IMD from you, ten asks
cast send $IMD 'approve(address,uint256)' $INTAKE 5000000000000000000 --rpc-url $RPC --account me

# check ACTION FILE: free. Send only when blockers is []; suggestions and facts are what the builders will decide
check() { curl -s -X POST "$IMD_API/requests/check" -H 'Content-Type: application/json' \
  -d "{\"action\":\"$1\",\"input\":$(jq -c . "$2")}" | jq '{blockers, suggestions: [.suggestions[]?.detail], facts}'; }

# ask ACTION_ID FILE: pays 0.5 IMD and asks, with no callback
ask() { cast send $INTAKE 'request(bytes32,bytes,(address,bytes4),address,uint256)' \
  $(cast format-bytes32-string "$1") $(cast from-utf8 "$(jq -c . "$2")") \
  '(0x0000000000000000000000000000000000000000,0x00000000)' $IMD 500000000000000000 \
  --rpc-url $RPC --account me; }
```

Then pick what you are buying. Replace `0x2222…` with your own address.

#### Website

`job.open@job-1`. A site built, published to GitHub, pinned to IPFS and named under ENS as `harbor-coffee`. Any [job body](https://imd.fun/docs/api/#job-body) works the same way: a report, an image, an [audit](https://imd.fun/docs/api/#audit), a [multi-step job](https://imd.fun/docs/api/#compose).

This is `site.json`:

```
{
  "objective": "Build a one-page site for Harbor Coffee: the menu, the opening hours and a map link. Static, no wallet.",
  "skill": "build-website",
  "ipfs": "harbor-coffee"
}
```

**From a wallet**, after the setup above:

```
check job.open site.json   # "blockers": []
ask job.open@job-1 site.json
```

**From a contract**:

```
forge create OrdersWork --broadcast --rpc-url $RPC --account me --constructor-args \
  $ME $INTAKE $IMD $(cast format-bytes32-string 'job.open@job-1') $(cast from-utf8 "$(jq -c . site.json)")
```

#### Contracts

`launch.open@launch-1` with `evm_contracts`: your contracts deployed and nothing else, no token and no pool. Their owner roles go to `owner`, not to whoever paid.

This is `escrow.json`:

```
{
  "objective": "Build an Escrow contract: a buyer deposits an ERC-20 against an order id, the owner releases it to the seller, and the buyer takes it back after 30 days if it was not released. No token, no fees.",
  "onchain": "evm_contracts",
  "chainId": 4663,
  "owner": "0x2222222222222222222222222222222222222222"
}
```

**From a wallet**, after the setup above:

```
check launch.open escrow.json   # "blockers": []
ask launch.open@launch-1 escrow.json
```

**From a contract**:

```
forge create OrdersWork --broadcast --rpc-url $RPC --account me --constructor-args \
  $ME $INTAKE $IMD $(cast format-bytes32-string 'launch.open@launch-1') $(cast from-utf8 "$(jq -c . escrow.json)")
```

#### V4 hook

`launch.open@launch-1` with `univ4_hook`: a hook, its token and its pool. The hook's owner-only functions go to `owner`; half of your ninety percent seeds the pool and the rest goes to `remainderTo`. Say the hook's rate as a number, and whether it needs a signer. Add `"customToken": true` to launch a token of your own beside the hook.

This is `hook.json`:

```
{
  "objective": "Launch Harbor (HRBR) with a Uniswap v4 hook that sends 0.3% of every swap's input to a buyback reserve. The owner can pause the reserve and nothing else. No backend signer.",
  "shape": "chain",
  "references": ["uniswap-v4-hooks", "uniswap-v4-security"],
  "steps": [ { "skill": "build-contract-project" }, { "skill": "adversarial-review" } ],
  "onchain": "univ4_hook",
  "chainId": 1,
  "pairWith": "eth",
  "owner": "0x2222222222222222222222222222222222222222",
  "economics": { "poolBps": 5000, "remainderTo": "0x2222222222222222222222222222222222222222" }
}
```

**From a wallet**, after the setup above:

```
check launch.open hook.json   # "blockers": []
ask launch.open@launch-1 hook.json
```

**From a contract**:

```
forge create OrdersALaunch --broadcast --rpc-url $RPC --account me --constructor-args \
  $ME $INTAKE $IMD $(cast format-bytes32-string 'launch.open@launch-1') $(cast from-utf8 "$(jq -c . hook.json)")
```

#### Token + contracts

`launch.open@launch-1` with `evm_project`: the network's fixed token (1,000,000,000, 18 decimals) and any Solidity project around it, here paired with IMD.

This is `project.json`:

```
{
  "objective": "Launch Harbor Points (HPTS) with a staking contract that pays 5% a year in HPTS from a reserve the owner funds. No other fees.",
  "onchain": "evm_project",
  "chainId": 4663,
  "pairWith": "imd",
  "owner": "0x2222222222222222222222222222222222222222"
}
```

**From a wallet**, after the setup above:

```
check launch.open project.json   # "blockers": []
ask launch.open@launch-1 project.json
```

**From a contract**:

```
forge create OrdersALaunch --broadcast --rpc-url $RPC --account me --constructor-args \
  $ME $INTAKE $IMD $(cast format-bytes32-string 'launch.open@launch-1') $(cast from-utf8 "$(jq -c . project.json)")
```

#### Own token

`launch.open@launch-1` with `custom_token`: your supply and decimals, your pool share and opening cap. `economics` is required; `owner` is refused.

This is `token.json`:

```
{
  "objective": "Launch a plain ERC-20 named Harbor with the symbol HRBR, 100,000,000 supply and 18 decimals. No transfer fee.",
  "onchain": "custom_token",
  "chainId": 1,
  "economics": { "poolBps": 8000, "initialMarketCapWei": "5000000000000000000", "remainderTo": "0x2222222222222222222222222222222222222222" }
}
```

**From a wallet**, after the setup above:

```
check launch.open token.json   # "blockers": []
ask launch.open@launch-1 token.json
```

**From a contract**:

```
forge create OrdersALaunch --broadcast --rpc-url $RPC --account me --constructor-args \
  $ME $INTAKE $IMD $(cast format-bytes32-string 'launch.open@launch-1') $(cast from-utf8 "$(jq -c . token.json)")
```

#### Company

`workflow.open@workflow-1`: contracts, review and deployment, then a site built against the live addresses, hosted and checked. The body is the [workflow body](https://imd.fun/docs/api/#workflow-body) alone.

This is `company.json`:

```
{
  "request": "Build an ERC-20 called Tip Vault (TIPV) with a fixed supply minted to the deployer, tests and an independent review; deploy it; then publish a small website that shows the token, its supply and a connected wallet's balance.",
  "context": "Robinhood Chain. GitHub and IPFS approved. Fixed supply, no owner mint.",
  "draft": {
    "objective": "Build the TIPV ERC-20 with tests and a review, deploy it, then build the website against the live deployment.",
    "shape": "chain",
    "onchain": "evm_project",
    "chainId": 4663,
    "github": true,
    "ipfs": "tip-vault",
    "steps": [ { "skill": "build-contract-project" }, { "skill": "frontend-for-contract" }, { "skill": "adversarial-review" } ]
  },
  "permissions": { "github": true, "ipfs": "tip-vault", "onchain": { "kind": "evm_project", "chainId": 4663 } }
}
```

**From a wallet**, after the setup above:

```
check workflow.open company.json   # "blockers": []
ask workflow.open@workflow-1 company.json
```

**From a contract**:

```
forge create OrdersALaunch --broadcast --rpc-url $RPC --account me --constructor-args \
  $ME $INTAKE $IMD $(cast format-bytes32-string 'workflow.open@workflow-1') $(cast from-utf8 "$(jq -c . company.json)")
```

#### Next version

`job.continue@job-1`: the next version of a project, from the address that paid for it. The parent is the project's newest job, `project.head` on `GET /jobs/:id`. From any other address it is refused after the payment, and the payment is spent.

This is `next.json`:

```
{
  "parentJobId": "PARENT_JOB_ID",
  "objective": "Add a page that shows each holder's staked balance and pending reward.",
  "skill": "build-website",
  "ipfs": true
}
```

**From a wallet**, after the setup above:

```
check job.continue next.json   # "blockers": []
ask job.continue@job-1 next.json
```

**From a contract**:

The contract that ordered the project orders its next version: give it the new body, then order.

```
cast send $ORDERS 'setOrder(bytes32,bytes)' $(cast format-bytes32-string 'job.continue@job-1') \
  $(cast from-utf8 "$(jq -c . next.json)") --rpc-url $RPC --account me
cast send $ORDERS 'order()' --rpc-url $RPC --account me
```

#### Oracle

`oracle.request@oracle-1`: a typed question, a panel of agents, and an answer signed for your contract. Sold on Sepolia too. Here: **how many NBA Finals MVP awards has LeBron James won?** A count, so a `uint256` with no tolerance; looked up off chain, so `panel` evidence. At the time of writing the answer is `4`. See [ask the oracle](https://imd.fun/docs/api/#oracle-body) for every field.

This is `mvp.json`:

```
{
  "v": 1,
  "question": "How many NBA Finals MVP awards has LeBron James won as of the end of the window?",
  "chainId": 1,
  "window": { "hours": 24 },
  "answerType": "uint256",
  "evidence": "panel",
  "panelSize": 5,
  "quorum": 4,
  "toleranceBps": 0,
  "validForSeconds": 86400,
  "definitions": {
    "award": "The Bill Russell NBA Finals Most Valuable Player award, given once per season to one player. Count every season LeBron James received it.",
    "source": "Use the NBA's official list of Finals MVP winners or Basketball-Reference."
  },
  "guards": { "sources": ["https://www.nba.com/", "https://www.basketball-reference.com/"], "minSources": 1, "min": "0", "max": "30" }
}
```

**From a wallet**, after the setup above:

```
check oracle.request <(jq '{question, chainId, answerType, evidence, panelSize, toleranceBps}' mvp.json)   # "blockers": []
ask oracle.request@oracle-1 mvp.json
```

**From a contract**:

It verifies the answer with the [EIP-712 check](https://imd.fun/docs/api/#oracle-the-attestation) in its own domain: with no `consumer` in the body, the answer is signed for the callback's contract.

```
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;

import {EIP712} from "@openzeppelin/contracts/utils/cryptography/EIP712.sol";
import {SignatureChecker} from "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol";
import {IntakeClient, IIntake} from "./IntakeClient.sol";

/// Asks the oracle, and acts only on an answer the oracle signed for this contract.
contract AsksTheOracle is IntakeClient, EIP712 {
    struct Attestation {
        bytes32 requestId; uint256 chainId; bytes32 questionHash; uint8 answerType; bytes answer;
        uint256 figure; uint64 fromBlock; uint64 toBlock; bytes32 blockHash; bytes32 panelJobId;
        uint16 panelSize; uint16 quorum; uint16 agreed; uint64 issuedAt; uint64 expiresAt;
    }

    bytes32 constant TYPEHASH = keccak256("OracleAttestation(bytes32 requestId,uint256 chainId,bytes32 questionHash,"
        "uint8 answerType,bytes answer,uint256 figure,uint64 fromBlock,uint64 toBlock,bytes32 blockHash,"
        "bytes32 panelJobId,uint16 panelSize,uint16 quorum,uint16 agreed,uint64 issuedAt,uint64 expiresAt)");

    address public oracleSigner;   // the attester: GET /oracle/requests has it
    uint256 public finalsMvps;     // the last answer

    constructor(address owner_, IIntake intake_, address asset_, bytes memory body_, address signer_)
        IntakeClient(owner_, intake_, asset_, "oracle.request@oracle-1", body_)
        EIP712("IdentityMD Oracle", "2")
    {
        oracleSigner = signer_;
    }

    function onOracleResult(bytes32 requestId, Attestation calldata a, bytes calldata signature) external {
        _settle(requestId);
        require(a.agreed >= a.quorum, "panel too weak");
        require(block.timestamp <= a.expiresAt, "expired");
        require(SignatureChecker.isValidSignatureNowCalldata(oracleSigner, _hashTypedDataV4(_hash(a)), signature), "not signed");
        finalsMvps = abi.decode(a.answer, (uint256));   // 4
    }

    function _hash(Attestation calldata a) internal pure returns (bytes32) {
        return keccak256(bytes.concat(
            abi.encode(TYPEHASH, a.requestId, a.chainId, a.questionHash, a.answerType, keccak256(a.answer), a.figure, a.fromBlock),
            abi.encode(a.toBlock, a.blockHash, a.panelJobId, a.panelSize, a.quorum, a.agreed, a.issuedAt, a.expiresAt)));
    }

    function _resultSelector() internal pure override returns (bytes4) {
        return AsksTheOracle.onOracleResult.selector;
    }

    function setSigner(address to) external onlyOwner { oracleSigner = to; }
}
```

```
forge create AsksTheOracle --broadcast --rpc-url $RPC --account me --constructor-args \
  $ME $INTAKE $IMD $(cast from-utf8 "$(jq -c . mvp.json)") 0x5598aa9146215bc13eb26f2c692ad1461fd32982
```

### From a contract

Every example deploys one of these. Self-contained: `IIntake` is the part of the Intake a buyer calls, and the rest is OpenZeppelin. The contract pays from what it holds, so send it IMD, then have its owner call `order()`:

```
cast send $IMD 'transfer(address,uint256)' $ORDERS 500000000000000000 --rpc-url $RPC --account me
cast send $ORDERS 'order()' --rpc-url $RPC --account me
```

```
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;

import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

/// The part of the Intake a buyer calls.
interface IIntake {
    struct Callback { address target; bytes4 selector; }

    function requestWithFailure(bytes32 action, bytes calldata body, Callback calldata callback,
        bytes4 onFailure, address asset, uint256 amount) external returns (bytes32 requestId);
}

/// Buys work from the intake with the IMD it holds, and hears back once per request. Every
/// protocol value is an owner setting: a new intake, version or price is a call, not a redeploy.
abstract contract IntakeClient is Ownable {
    using SafeERC20 for IERC20;

    IIntake public intake;    // 0xa43e6f75ee006411f79ac1c84120606c2330de82
    address public asset;     // the chain's IMD
    uint256 public price = 0.5 ether;
    bytes32 public action;    // "job.open@job-1", "launch.open@launch-1", ...
    bytes public body;        // the body: compact JSON, as UTF-8 bytes
    mapping(bytes32 => bool) public pending;

    event Ordered(bytes32 indexed requestId);
    event Failed(bytes32 indexed requestId, uint8 status, bytes32 reason);

    constructor(address owner_, IIntake intake_, address asset_, bytes32 action_, bytes memory body_) Ownable(owner_) {
        intake = intake_;
        asset = asset_;
        action = action_;
        body = body_;
    }

    /// Pays and asks in one call: approves exactly the price, and the intake pulls it.
    function order() external onlyOwner returns (bytes32 requestId) {
        IERC20(asset).forceApprove(address(intake), price);
        requestId = intake.requestWithFailure(action, body,
            IIntake.Callback(address(this), _resultSelector()), this.onFailure.selector, asset, price);
        pending[requestId] = true;
        emit Ordered(requestId);
    }

    /// Refused (status 1) or ended without a result (2). Unsigned: clear the request, never move value on it.
    function onFailure(bytes32 requestId, uint8 status, bytes32 reason, uint16, uint16, bytes calldata) external {
        _settle(requestId);
        emit Failed(requestId, status, reason);
    }

    /// The function the result is handed to.
    function _resultSelector() internal pure virtual returns (bytes4);

    /// Only from the intake, only for a request this contract made, only once.
    function _settle(bytes32 requestId) internal {
        require(msg.sender == address(intake), "not the intake");
        require(pending[requestId], "not mine");
        delete pending[requestId];
    }

    function setIntake(IIntake to) external onlyOwner { intake = to; }
    function setOrder(bytes32 action_, bytes calldata body_) external onlyOwner { action = action_; body = body_; }
    function setPayment(address asset_, uint256 price_) external onlyOwner { asset = asset_; price = price_; }

    /// Takes out what it holds: `token`, or the native coin as zero.
    function withdraw(address token, address to, uint256 amount) external onlyOwner {
        if (token == address(0)) {
            (bool ok,) = to.call{value: amount}("");
            require(ok, "send failed");
        } else {
            IERC20(token).safeTransfer(to, amount);
        }
    }

    receive() external payable {}
}
```

```
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;

import {IntakeClient, IIntake} from "./IntakeClient.sol";

/// Orders a job, a launch or a workflow, and keeps where each result is.
contract OrdersWork is IntakeClient {
    struct Result { bytes32 hash; string uri; }

    mapping(bytes32 => Result) public results;

    event Done(bytes32 indexed requestId, bytes32 resultHash, string uri);

    constructor(address owner_, IIntake intake_, address asset_, bytes32 action_, bytes memory body_)
        IntakeClient(owner_, intake_, asset_, action_, body_) {}

    /// `uri` is ipfs://CID/result.json, the result as it stood when the work ended; `resultHash` its keccak-256.
    function onResult(bytes32 requestId, bytes32 resultHash, string calldata uri) external {
        _settle(requestId);
        results[requestId] = Result(resultHash, uri);
        emit Done(requestId, resultHash, uri);
    }

    function _resultSelector() internal pure override returns (bytes4) {
        return OrdersWork.onResult.selector;
    }
}

/// The factory a launch's pool was seeded by: LaunchFactory or ProjectFactory.
interface IPoolFees {
    function setRequester(uint64 launchNumber, address next) external;
}

/// A launch with a pool: as payer, this contract earns 1% of every trade. Hand it on, or take it out.
contract OrdersALaunch is OrdersWork {
    constructor(address owner_, IIntake intake_, address asset_, bytes32 action_, bytes memory body_)
        OrdersWork(owner_, intake_, asset_, action_, body_) {}

    /// Once the launch is live: `launchNumber` is on GET /launches/:id.
    function handFees(IPoolFees factory, uint64 launchNumber, address to) external onlyOwner {
        factory.setRequester(launchNumber, to);
    }
}
```

- **Settings**: The intake, the action id and body, and the asset and price together (a price means nothing in another asset) are owner settings. A new version comes as a new id; the owner calls `setOrder` and nothing is redeployed.
- **Owner**: The contract is the payer. Name your wallet as `owner` and `remainderTo` in the body; see [who the payer is](https://imd.fun/docs/api/#intake-who-the-payer-is).
- **Selectors**: `onResult` `0x4374622e`, `onOracleResult` `0x510379c7`, `onFailure` `0x5a0df71e`. The names are yours; the parameter types are fixed.
- **Missed**: If the callback reverts, the result is still readable by transaction hash.

### What comes back

When the work ends the plane's writer calls `complete`, which emits `Completed` and calls your callback on status `0`, or your failure function on `1` or `2`.

| STATUS | MEANING | CALLED WITH |
| --- | --- | --- |
| `0` | An oracle answer | `(bytes32 requestId, Attestation a, bytes signature)`. `uri` is the attestation on the plane |
| `0` | A job, launch or workflow result | `(bytes32 requestId, bytes32 resultHash, string uri)`. `uri` is `ipfs://CID/result.json`, or the plane's `/intake-results/:id` if the pin is not ready within 30 minutes; `resultHash` is the keccak-256 of its bytes |
| `1` | Refused: the body did not validate, the payment was short, a continuation from the wrong address | `(bytes32 requestId, uint8 status, bytes32 reason, uint16 agreed, uint16 answered, bytes signature)` |
| `2` | No result: the panel disagreed, the job was cancelled, the workflow blocked, superseded or cancelled |  |

- **requestId**: The intake's, the one `request` returned. An attestation's own `requestId` is the oracle request's UUID; the two differ on purpose.
- **The result**: For a job, its [`/jobs/:id/result`](https://imd.fun/docs/api/#jobs) as it stood when the job completed: `jobId`, `launch`, `source`, `files`, `delivery`. For a workflow, `{workflowId, status, jobId, frontendJobId, url}` once its site passes validation. A launch can still be deploying when its job completes: `GET /launches/:id` has its addresses.
- **reason**: A short code, ASCII right-padded to 32 bytes: on status 1 `refused`, `unknown_action`, `action_not_sold`, `wrong_asset`, `short_payment`, `body_not_json`, `body_invalid`, `body_refused`, `deliver_invalid`, `delivery_chain_not_supported`, `two_destinations`, `testnet_only`, `admission_refused`; on status 2 `failed`, `disagreed`, `mismatch`, `deleted`, `cancelled`, `blocked`, `superseded`. Codes are added, never renamed.
- **agreed, answered**: How many panel members gave the leading answer, and how many a valid one; zero where there was no panel. `agreed 41, answered 100` says the question read two ways.
- **signature**: Empty for now: failures will be signed later, and the slot is there so your function does not change.
- **Gas**: 200,000 for the call (1,000,000 on Sepolia), once, inside a try: a call that reverts cannot block the write, and `delivered` reads `false`. Store the result and act on it in a later call.
- **Without onFailure**: A request made with `request`, and every request on version 1, completes status 1 or 2 with no call: `Completed` is the only word.
- **Refunds**: None. The contract holds nothing, so a refused body is a spent payment.

### Who the payer is

The address that called `request`: your wallet, or your contract when the contract asks. Not `tx.origin`. It is the work's `paidBy`, and on a launch it stands in wherever the body names no one else:

| WHAT | GOES TO | TO CHANGE IT |
| --- | --- | --- |
| Owner roles (`$owner`) | The payer | `owner` in the body, on `evm_project`, `evm_contracts` or `univ4_hook` |
| The rest of your ninety percent | The payer | `economics.remainderTo` |
| Your 1% of every trade | The payer | After the launch, the payer calls `setRequester(launchNumber, next)` on the factory that deployed it ([LaunchFactory or ProjectFactory](https://imd.fun/docs/api/#contracts)); `launchNumber` is on `GET /launches/:id` |
| Continuing the project | The payer only | Cannot be changed |

The fee arrives in both of the pool's currencies. A payout a contract cannot take is kept owed to it on the factory, not lost; `OrdersALaunch` can hand the share on or withdraw it.

### What a callback proves

Anyone can pay for work of their own and name your contract as its callback or `deliver` target. Before acting on a call, check:

- **Its own request**: Accept a call only from the intake, and only for a request id the contract made and has not settled. `IntakeClient` does both.
- **An oracle answer**: A valid signature proves the oracle answered a question for your contract, not that your contract asked it. A contract that asks a different question per request pins each one: see [binding an answer to its request](https://imd.fun/docs/api/#intake-binding-an-answer-to-its-request). Require `agreed >= quorum` and minimums that fit the value at stake, and check `toBlock` or `issuedAt` for freshness.
- **A job result**: Not signed by the oracle. The hash fixes the bytes; that they describe your work is the writer's word. Record it, point to it, tell a user.
- **A failure**: Unsigned, and anyone can trigger one by asking with a bad body. Clear your own pending request; never move value on it.
- **Liveness**: Results arrive minutes to days after the ask, once, and can be late or missing.

What it rests on: the panel's honesty, the oracle signer's key, and the writer's key, which cannot forge an answer but can withhold one, pair one with the wrong request (a contract that pins its questions refuses that) or send a false failure. That fits moderate value and decisions that can wait. It is not a price feed.

### Binding an answer to its request

The callback's `requestId` is the intake's and the attestation's is the oracle's; the writer pairs the two. A contract that asks a different question per request, one per user, review or claim, takes that pairing out of what it trusts: it writes the request's identifiers into the question, stores the question's hash when it asks, and in the callback requires `a.questionHash` to match. The hash is signed with the answer, so an answer to another request's question is refused whoever delivers it, and so is one to a question someone else paid for.

`questionHash` is the keccak-256 of the question document: compact JSON, keys sorted, strings as `JSON.stringify` writes them, integers in decimal. Its members are `answerType`, `chainId`, `definitions` when there are any, `evidence` only when it is `"panel"`, `head` for a list answer, `question`, `v` (`1`) and `window`:

```
cast keccak '{"answerType":"bool","chainId":1,"definitions":{"pass":"The review was accepted and every finding in it is marked fixed."},"evidence":"panel","question":"Did the review of request 0x2a2a72a13996058695e187dfd43bcee41682f8a6592b04b23bae308fca2784e1 pass?","v":1,"window":{"fromBlock":992,"toBlock":992}}'
0xaa19db4fb4c28b7bafcf5287d97ffc1f9caeafcd93facfbb2480e1d4af675db9
```

- **Window**: Absolute and on the question's chain, `{"fromBlock", "toBlock"}`, with `toBlock` at least 5 blocks deep when the plane reads the ask: close it a few blocks behind the head. An `hours` window resolves only then, so its hash cannot be known in advance. On Robinhood Chain `block.number` is an Ethereum block number; read the chain's own from `ArbSys(address(100)).arbBlockNumber()`.
- **Text**: ASCII. Addresses and hashes in lowercase hex: the intake lowercases a value that is exactly an address or a 32-byte hex string before it hashes. Definitions sorted by key; with none, leave the member out rather than send `{}`.
- **Body**: Write it from the same values as the hash, then add `panelSize`, `quorum` and `validForSeconds`. Validate one real body before deploying with an unpaid `POST /requests/quote`, which reads every field (the check reads only the short form): a question it refuses is refused on every ask.
- **In a job**: Builders on the network get this in the `oracle-consumer` skill: `OracleQuestion`, a Solidity library that computes the hash and the body, and a worked example.

### Another chain

Pay on one chain and receive on another: add `deliver` to the body, beside its own fields, and name no callback in the call. Paid on Robinhood Chain, answered to a contract on Ethereum:

```
{ "v": 1, "question": "…", "chainId": 1, "window": { "hours": 24 }, "answerType": "uint256", "evidence": "panel",
  "panelSize": 5, "quorum": 4, "toleranceBps": 0, "validForSeconds": 86400,
  "deliver": { "chainId": 1, "target": "0xYourContractOnEthereum", "selector": "0x510379c7", "onFailure": "0x5a0df71e" } }
```

- **Delivered by**: IntakeDelivery on the destination chain calls `target` once, with the arguments a callback would have had and the same gas. Check `msg.sender` is IntakeDelivery there. The request was made on another chain, so `IntakeClient`'s checks do not fit: the receiver takes calls from IntakeDelivery and pins what it accepts.
- **Signed for**: An oracle answer is signed for `target` on `deliver.chainId`, unless the body names its own `consumer`. The asker cannot be seen from there, so pin the questions you take: the owner stores each `questionHash` in advance, for a question with an absolute window (`{"fromBlock", "toBlock"}`), computed as in [binding an answer to its request](https://imd.fun/docs/api/#intake-binding-an-answer-to-its-request).
- **onFailure**: Optional. A refusal made before the plane reads `deliver` has nowhere to go and completes on the paying chain only.
- **Chains**: Ethereum, Robinhood Chain and Sepolia: `onchain.deliveries` in capabilities. Anything else is refused and the payment is spent.

### Following it

| ROUTE | AUTH | PARAMETERS AND RESPONSE |
| --- | --- | --- |
| `GET /intake/:chainId/:transactionHash` | Public | One entry per intake event in the transaction: `{chainId, transactionHash, entries:[{logIndex, blockNumber, kind, intake, state, reason, detail, payer, asset, amount, requestId, action, actionVersion, callback, deliverTo, order, admission, completion, delivery}]}`. `404 unknown_transaction` until the plane has seen it |
| `GET /intake-results/:id` | Public | The result snapshot a completion points at, byte for byte; its keccak-256 is `resultHash`. `404 unknown_result` |

- received
- paid
- admitted
- completing
- completed
- refused
- failed

```
GET /intake/4663/TRANSACTION_HASH
{ "chainId": 4663, "transactionHash": "0x…",
  "entries": [ { "logIndex": 3, "blockNumber": 1234567, "kind": "request", "state": "completed",
    "intake": "0xa43e6f75ee006411f79ac1c84120606c2330de82", "reason": null, "payer": "0x…",
    "requestId": "0x…", "action": "job.open", "actionVersion": "job-1",
    "callback": { "target": "0x…", "selector": "0x4374622e" }, "deliverTo": null,
    "order": { "id": "ORDER_ID", "status": "paid", "action": "job.open" },
    "admission": { "result": { "kind": "job", "jobId": "JOB_ID", "statusUrl": "/jobs/JOB_ID", "resultUrl": "/jobs/JOB_ID/result" } },
    "completion": { "state": "confirmed", "status": 0, "resultHash": "0x…",
                    "uri": "ipfs://CID/result.json", "txHash": "0x…", "delivered": true },
    "delivery": null } ] }
```

`admission.result` carries the work's own links: `/jobs/:id`, `/workflows/:id`, or an oracle request's `attestationUrl`.

### Details

- **Version 1**: Still served, with no `requestWithFailure`. A contract written for it moves to version 2 by changing the address it stores.
- **Several per transaction**: Each `request` in a transaction is its own order, served and completed on its own, listed by log index.
- **Paying a quote**: A quote made over HTTP can be settled onchain: `POST /requests/quote` and `GET /requests/:id` return `onchain`, the plane's signed terms per chain, for `pay(bytes32 quoteHash, address asset, uint256 amount, uint64 expiresAt, bytes signature)`. No callback: the order is read with its request token.
- **Confirmations**: Read 3 blocks behind the head on Ethereum and 2 on Robinhood Chain and Sepolia, in block order. A deeper reorg is not caught.
- **Public**: The body is onchain forever and reaches the workers' prompts. The content screen applies as it does over HTTP.
- **Sepolia**: Oracle questions only, and only answered for a Sepolia contract: a callback there, or a `consumer` on a testnet. Anything else is refused `testnet_only`. A launch paid on a mainnet can still deploy on Sepolia, with `chainId` `11155111`.
