Dhoni77 / pulsemarkets

Home Page:pulsemarkets-v2-web.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Prompt Wars

Originally branded as Pulse Markets, Prompt Wars is a decentralized game build on top of NEAR Protocol Rust smart-contracts.

The reasoning behind the game is simple:

Submit a prompt that will render the image on display, compare all the prompt results with the source image and pay the rewards to the resulting image that is closest to the reference image.

Prompt Wars screenshot

Follow docs.pulsemarkets.org for a broader understanding of the smart-contract Prediction Markets protocol on top of which Prompt Wars is built.

To launch your own instance of Prompt Wars, you can:

  1. connect to our Testnet or Mainnet contracts, OR
  2. connect to your own contracts

The client is a NextJS application that connects to the NEAR Protocol Rust smart-contracts with near-api-js.

To launch on localhost:3003, first clone this repo and run:

git@github.com:aufacicenta/pulsemarkets.git
cd pulsemarkets
yarn
cd app
yarn
yarn dev:debug

You'll need these values in app/.env:

export NODE_ENV=test
export NEXT_PUBLIC_ORIGIN="http://localhost:3003"

export NEXT_PUBLIC_INFURA_ID="..." # get it from infura.io, works to upload prompt images to IPFS

# Uncomment when ready to prod
# export NEXT_PUBLIC_DEFAULT_NETWORK_ENV="mainnet"

export NEXT_PUBLIC_DEFAULT_NETWORK_ENV="testnet"

export NEAR_SIGNER_PRIVATE_KEY="..." # a private key of your NEAR wallet account. This wallet creates the games and determines the winner

export REPLICATE_API_TOKEN="..." # get it from replicate.ai, this connects to Stable Diffusion to compare the images

export NEXT_PUBLIC_WEBSOCKETS_PORT=8000

All important configuration regarding Testnet and Mainnet smart-contracts is in: getConfig.ts.

Change these values according to your deployment, if needed.

The main contract is contracts/prompt-wars/src/contract.rs (it's Typescript abstraction is app/src/providers/near/contracts/prompt-wars/contract.ts).

You can tweak the contract to your needs and deploy it using the NEAR CLI. Update getConfig.ts to match your contracts' addresses.

Make sure that the tests pass!

# ./contracts/prompt-wars
cargo test -- --nocapture

This is done through the API endpoints:

  • /api/prompt-wars/create — create new games using the market factory contract (once this is called, it automates the next steps)
  • /api/prompt-wars/reveal — compare the prompt results with the source image, store the results in the prompt wars market contract
  • /api/prompt-wars/resolve — set the winner
  • /api/prompt-wars/self-destruct — get the storage NEAR native balance back

Check the paid issues in the Prompt Wars project board!

About

pulsemarkets-v2-web.vercel.app


Languages

Language:TypeScript 60.9%Language:SCSS 24.4%Language:Rust 10.0%Language:Solidity 2.5%Language:JavaScript 1.7%Language:Handlebars 0.3%Language:Shell 0.1%