# Prediction Mkt Repo

PATH:  <mark style="color:red;">C:\XFT\prediction-mkts\prod</mark>

<mark style="color:purple;">COUNTERPARTIES</mark>\ <mark style="color:red;">contracts/XFTConditionalTokens.sol</mark> [0x786Bc48C7ef3E9AA811068Fb4b0eC0DC01028740](https://sepolia.arbiscan.io/address/0x786bc48c7ef3e9aa811068fb4b0ec0dc01028740)\
contracts/XFTPredictionMktFacility.sol&#x20;

USDXT [0xC1BF9854E43b84f3abec5f5d1C72F0a6f602034b](https://sepolia.arbiscan.io/address/0xC1BF9854E43b84f3abec5f5d1C72F0a6f602034b)\
USDX [0x4F1D5c7221dB8F3F28b2F0398Aa2bc321b72C523](https://sepolia.arbiscan.io/address/0x4F1D5c7221dB8F3F28b2F0398Aa2bc321b72C523)

***

### HARDHAT PROJECT SETUP

npm init -y\
npm i -D hardhat @nomicfoundation/hardhat-toolbox dotenv\
npx hardhat --init

```powershell
PS C:\XFT\prediction-mkts\prod> npx hardhat --init

 █████  █████                         ███  ███                  ███      ██████
░░███  ░░███                         ░███ ░███                 ░███     ███░░███
 ░███   ░███   ██████  ████████   ███████ ░███████    ██████  ███████  ░░░  ░███
 ░██████████  ░░░░░███░░███░░███ ███░░███ ░███░░███  ░░░░░███░░░███░      ████░
 ░███░░░░███   ███████ ░███ ░░░ ░███ ░███ ░███ ░███   ███████  ░███      ░░░░███
 ░███   ░███  ███░░███ ░███     ░███ ░███ ░███ ░███  ███░░███  ░███ ███ ███ ░███
 █████  █████░░███████ █████    ░░███████ ████ █████░░███████  ░░█████ ░░██████
░░░░░  ░░░░░  ░░░░░░░ ░░░░░      ░░░░░░░ ░░░░ ░░░░░  ░░░░░░░    ░░░░░   ░░░░░░

👷 Welcome to Hardhat v3.0.4 👷

√ Which version of Hardhat would you like to use? · hardhat-2
√ Where would you like to initialize the project?

Please provide either a relative or an absolute path: · .
√ What type of project would you like to initialize? · empty-hardhat-config-js
✨ Template files copied ✨
√ You need to update the following dependencies using the following command:
npm install --save-dev "hardhat@^2.14.0"

Do you want to run it now? (Y/n) · true

npm install --save-dev "hardhat@^2.14.0"

added 75 packages, removed 22 packages, changed 16 packages, and audited 593 packages in 8s

117 packages are looking for funding
  run `npm fund` for details

15 low severity vulnerabilities

To address issues that do not require attention, run:
  npm audit fix

Some issues need review, and may require choosing
a different dependency.

Run `npm audit` for details.
✨ Dependencies updated ✨
Give Hardhat a star on Github if you're enjoying it! ⭐️✨

     https://github.com/NomicFoundation/hardhat
PS C:\XFT\prediction-mkts\prod>
```

mkdir scripts\
mkdir contracts\
cd contracts\
touch XFTConditionalTokens.sol\
npx hardhat clean\
npx hardhat compile

***

### XFTConditionalTokens.sol

Path: <mark style="color:red;">contracts/XFTConditionalTokens.sol</mark>

```
[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"conditionId","type":"bytes32"},{"indexed":true,"internalType":"address","name":"oracle","type":"address"},{"indexed":true,"internalType":"bytes32","name":"questionId","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"outcomeSlotCount","type":"uint256"}],"name":"ConditionPreparation","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"conditionId","type":"bytes32"},{"indexed":true,"internalType":"address","name":"oracle","type":"address"},{"indexed":true,"internalType":"bytes32","name":"questionId","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"outcomeSlotCount","type":"uint256"},{"indexed":false,"internalType":"uint256[]","name":"payoutNumerators","type":"uint256[]"}],"name":"ConditionResolution","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"redeemer","type":"address"},{"indexed":true,"internalType":"contract IERC20","name":"collateralToken","type":"address"},{"indexed":true,"internalType":"bytes32","name":"parentCollectionId","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"conditionId","type":"bytes32"},{"indexed":false,"internalType":"uint256[]","name":"indexSets","type":"uint256[]"},{"indexed":false,"internalType":"uint256","name":"payout","type":"uint256"}],"name":"PayoutRedemption","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"stakeholder","type":"address"},{"indexed":false,"internalType":"contract IERC20","name":"collateralToken","type":"address"},{"indexed":true,"internalType":"bytes32","name":"parentCollectionId","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"conditionId","type":"bytes32"},{"indexed":false,"internalType":"uint256[]","name":"partition","type":"uint256[]"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"PositionSplit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"stakeholder","type":"address"},{"indexed":false,"internalType":"contract IERC20","name":"collateralToken","type":"address"},{"indexed":true,"internalType":"bytes32","name":"parentCollectionId","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"conditionId","type":"bytes32"},{"indexed":false,"internalType":"uint256[]","name":"partition","type":"uint256[]"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"PositionsMerge","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"values","type":"uint256[]"}],"name":"TransferBatch","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"TransferSingle","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"value","type":"string"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"URI","type":"event"},{"constant":true,"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address[]","name":"owners","type":"address[]"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"}],"name":"balanceOfBatch","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"parentCollectionId","type":"bytes32"},{"internalType":"bytes32","name":"conditionId","type":"bytes32"},{"internalType":"uint256","name":"indexSet","type":"uint256"}],"name":"getCollectionId","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"oracle","type":"address"},{"internalType":"bytes32","name":"questionId","type":"bytes32"},{"internalType":"uint256","name":"outcomeSlotCount","type":"uint256"}],"name":"getConditionId","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"conditionId","type":"bytes32"}],"name":"getOutcomeSlotCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"contract IERC20","name":"collateralToken","type":"address"},{"internalType":"bytes32","name":"collectionId","type":"bytes32"}],"name":"getPositionId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"contract IERC20","name":"collateralToken","type":"address"},{"internalType":"bytes32","name":"parentCollectionId","type":"bytes32"},{"internalType":"bytes32","name":"conditionId","type":"bytes32"},{"internalType":"uint256[]","name":"partition","type":"uint256[]"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"mergePositions","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"payoutDenominator","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"payoutNumerators","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"oracle","type":"address"},{"internalType":"bytes32","name":"questionId","type":"bytes32"},{"internalType":"uint256","name":"outcomeSlotCount","type":"uint256"}],"name":"prepareCondition","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"contract IERC20","name":"collateralToken","type":"address"},{"internalType":"bytes32","name":"parentCollectionId","type":"bytes32"},{"internalType":"bytes32","name":"conditionId","type":"bytes32"},{"internalType":"uint256[]","name":"indexSets","type":"uint256[]"}],"name":"redeemPositions","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"questionId","type":"bytes32"},{"internalType":"uint256[]","name":"payouts","type":"uint256[]"}],"name":"reportPayouts","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"values","type":"uint256[]"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeBatchTransferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"contract IERC20","name":"collateralToken","type":"address"},{"internalType":"bytes32","name":"parentCollectionId","type":"bytes32"},{"internalType":"bytes32","name":"conditionId","type":"bytes32"},{"internalType":"uint256[]","name":"partition","type":"uint256[]"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"splitPosition","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"}]
```

***

Yes—deploy **ConditionalTokens.sol** as-is (0.5.x). Use it unchanged; wire your facility + oracle around it. Collateral: **USDXT**.

contracts /scripts/\
contracts/ConditionalTokens.sol\
contracts/XFTPredictionMktFacility.sol\
contracts/XFTTrustedOracle.sol\
scripts/deploy-conditional-tokens.js\
scripts/deploy-xft-trusted-oracle.js\
scripts/deploy-xft-facility.js\
scripts/create-market.js

```
Deployment Flow (Arbitrum Sepolia, USDXT)
1 Set .env RPC + PRIVATE_KEY
2 Choose USDXT address on Arbitrum Sepolia
3 npx hardhat compile (solc 0.5.13 for CT; facility/oracle can be 0.8.x or also 0.5.x)
4 Deploy ConditionalTokens -> get CT address
5 Deploy XFTTrustedOracle -> get ORACLE address
6 Deploy XFTPredictionMktFacility(CT, USDXT, treasury, ORACLE, feeBps)
7 In facility.createMarket(questionId, outcomeSlots=2, open, cutoff, uri)
8 Facility calls CT.prepareCondition(oracle=ORACLE, questionId, 2)
9 Save marketId, conditionId; publish addresses/IDs
10 For demo: ORACLE.setOutcome(questionId, YES/NO) then facility.resolveFromOracle(marketId)
```

<mark style="color:purple;">Hardhat setup</mark>

```
npm init -y
npm i -D hardhat @nomicfoundation/hardhat-toolbox dotenv
npx hardhat

npm i hardhat axios tsx 
```

Build & deploy cmds

```
npx hardhat compile
npx hardhat run scripts/deploy-conditional-tokens.js --network sepolia
npx hardhat run scripts/deploy-xft-trusted-oracle.js --network sepolia
npx hardhat run scripts/deploy-xft-facility.js --network sepolia
npx hardhat run scripts/create-market.js --network sepolia
```

Notes (least words)

* ConditionalTokens stays unmodified; it mints/burns positions and escrows USDXT via split/merge/redeem.
* XFTPredictionMktFacility: wraps CT (depositAndMint, merge, redeem, lock, resolveFromOracle, withdrawFees).
* XFTTrustedOracle: demo truth source; later swap to UMA adapter with same surface.
* Ensure hardhat.config has a 0.5.13 compiler entry for CT (and another for 0.8.x if used).


---

# 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://docs.xft.finance/learn/smart-contract-repo-setup/prediction-mkt-repo.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.
