Skip to content

node-real/predictdotfun-demo

Repository files navigation

Demo for PredictDotFun

Prerequisites

  1. brew install python with version 3.14+
  2. run python -m venv venv and source ./venv/bin/activate to active local Python Interpreter.
  3. run pip install -r requirements.txt.
  4. create .env from .env.exmaple and edit your eoa private key and PredictDotFun api key.

Step-0 Get JWT Token

run python jwt.py

Step-1 Approve

run python approve.py to set approvals, this is interaction with contracts, no auth header reqeust.

exmaples outputs of set_approvals transactions

Hash (abbr) Action Block Age From (abbr) To (abbr) Amount Txn Fee
0x4865a5 Set Approval For 71940800 7 mins ago 0xf155...54E6 0x22DA...9d244 0 BNB 0.00000232
0x0983bc Approve 71940798 7 mins ago 0xf155...54E6 BUSD-T Stablecoin 0 BNB 0.00000232
0xa72989 Set Approval For 71940796 7 mins ago 0xf155...54E6 0x22DA...9d244 0 BNB 0.00000232
0xbddfca Approve 71940794 7 mins ago 0xf155...54E6 BUSD-T Stablecoin 0 BNB 0.00000232
0x5f70e4 Set Approval For 71940791 7 mins ago 0xf155...54E6 0x22DA...9d244 0 BNB 0.00000232

Step-2 Get Markets

Find active market id by:

curl -X 'GET' 'https://api.predict.fun/v1/markets' -H 'accept: application/json' -H 'x-api-key: <your-api-key>'

Step-3 Get Orderbook

Find orderbook of a specified market by:

curl -X 'GET' 'https://api.predict.fun/v1/markets/420/orderbook' -H 'accept: application/json' -H 'x-api-key: <your-api-key>'

Step-4 Construct Order

  1. edit limit_order.py line32 price_per_share_wei, line33 quantity_wei, line46 token_id, line50 fee_rate_bps, line57 is_neg_risk and line58 is_yield_bearing.
  2. run python limit_order.py to get information likes:
salt: 1786497918
maker: 0xf155A90e1308817f186Ad69E8Ee5939645ce54E6
signer: 0xf155A90e1308817f186Ad69E8Ee5939645ce54E6
taker: 0x0000000000000000000000000000000000000000
token_id: 51923869364888026720633707255758662304830403989354809616621058202583057583874
maker_amount: 1000000000000000000
taker_amount: 100000000000000000000
expiration: 4102444800
nonce: 0
fee_rate_bps: 200
side: 0
signature_type: 0
signature: e0863e219f72c00baf8b79e900ef8b6bab4155bbad2a7343c4e75532f6f5b7db6b231c8fb32e4ce823fef4d1151618a37fe9d01900cc4b26c721d5e47e6959ee1b
hash: None

Step-5 Place Order to get Order Hash

curl -X 'POST' \
  'https://api.predict.fun/v1/orders' \
  -H 'accept: application/json' \
  -H 'x-api-key: <your-api-key>' \
  -H 'Authorization: Bearer <your-jwt-token>' \
  -H 'Content-Type: application/json' \
  -d '{
  "data": {
    "pricePerShare": "10000000000000000",
    "strategy": "LIMIT",
    "slippageBps": "0",
    "order": {
      "salt": "1786497918",
      "maker": "0xf155A90e1308817f186Ad69E8Ee5939645ce54E6",
      "signer": "0xf155A90e1308817f186Ad69E8Ee5939645ce54E6",
      "taker": "0x0000000000000000000000000000000000000000",
      "tokenId": "51923869364888026720633707255758662304830403989354809616621058202583057583874",
      "makerAmount": "1000000000000000000",
      "takerAmount": "100000000000000000000",
      "expiration": "4102444800",
      "nonce": "0",
      "feeRateBps": "200",
      "side": 0,
      "signatureType": 0,
      "signature": "0xe0863e219f72c00baf8b79e900ef8b6bab4155bbad2a7343c4e75532f6f5b7db6b231c8fb32e4ce823fef4d1151618a37fe9d01900cc4b26c721d5e47e6959ee1b"
    }
  }
}'

step-6 Query Order Stats

curl -X 'GET' \
  'https://api.predict.fun/v1/orders/<order-hash>' \
  -H 'accept: application/json' \
  -H 'x-api-key: <your-api-key>' \
  -H 'Authorization: Bearer <your-jwt-token>' \

step-7 Cancle Order

curl -X 'POST' \
  'https://api.predict.fun/v1/orders/remove' \
  -H 'accept: application/json' \
  -H 'x-api-key: <your-api-key>' \
  -H 'Authorization: Bearer <your-jwt-token>' \
  -H 'Content-Type: application/json' \
  -d '{
  "data": {
    "ids": [
      "42357"
    ]
  }
}'

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages