Skip to content

fabriziogianni7/cartesi-multi-outcome-prediction-market

Repository files navigation

Cartesi Multi Outcome Prediction Market

Shipped on Vercel and Holesky!

Index

Description

This project is a Multi-Outcome Prediction Market entirely on-chain, powered by Cartesi and EigenLayer.

Calculating share prices for multiple outcomes using the LSMR formula is computationally intensive and costly on the blockchain. Cartesi's Coprocessor offloads these calculations:

Reduces Gas Costs: By handling complex computations off-chain. Boosts Scalability: Enhances speed and efficiency of market operations. Ensures Security: With on-chain verification of off-chain results.

This approach makes sophisticated prediction markets accessible, accurate, and versatile, leveraging Cartesi's technology for a better user experience.

Architecture

cartesi

Flow

image

Screenshots

Screenshot 2025-02-13 alle 20 12 04 Screenshot 2025-02-13 alle 20 12 28

Install Dependencies

(need to install make first)

    make install-all

Run The Project Locally

  1. install cartesi cli and docker
  2. start devnet and publish app
cartesi-coprocessor start-devnet && cartesi-coprocessor publish --network devnet
  1. get machine hash and Devnet_task_issuer
cartesi-coprocessor address-book
  1. deploy MultiOutcomePredictionMarket contract
cartesi-coprocessor deploy --contract-name MultiOutcomePredictionMarket --network devnet --constructor-args <devnet_task_issuer> <Machine Hash>
  1. create new market
cast send <deployed contract> "createMarket(string,uint256[],uint256,string[])" "Who will win the Formula 1 championship?" [10,10,10] 100 '["Lewis Hamilton", "Max Verstappen", "Charles Leclerc"]' --rpc-url http://127.0.0.1:8545 --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 # no it's not a real private key
  1. invoke coprocessor
cast send <deployed contract> "prepareCallAndRunExecution(uint256,uint256,uint256)" 1 1 6  --rpc-url http://127.0.0.1:8545 --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 # no it's not a real private key
  1. check result
cast call <deployed contract> "getMarket(uint256)" 1 --rpc-url http://127.0.0.1:8545

Running Frontend

  1. access FE folder
cd ui-coprocessor-template
  1. create .env file with these variables
NEXT_PUBLIC_CONTRACT_ADDRESS = 0x1429859428c0abc9c2c47c8ee9fbaf82cfa0f20f;
NEXT_PUBLIC_MARKET_ID = 4;
  1. run FE
npm run dev

Run Tests

    cd contracts && forge test

Screenshot 2025-02-14 alle 18 34 08

Project Design And Video Demo

     


Built by @fabriziogianni7 and @SolidityDrone - use at your own risk.

About

A multi-outcome prediction market built on top of cartesi and eigenlayer using lmsr formula

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published