Home

Awesome

What is the Demo NFT Marketplace?

The Demo NFT Marketplace is an open source NFT marketplace built by Rarible DAO using the Rarible Protocol. Prosopo has forked and modified the marketplace to work with OpenBrush's PSP34 contracts. The PSP34 contracts have also been modified so that they are protected by Prosopo's human verification system.

Demo

Checkout the demo app!

<img alt="Main demo page" src="https://raw.githubusercontent.com/prosopo/demo-nft-marketplace/article/.github/images/screenshot1.png"> <img alt="Product demo page" src="https://raw.githubusercontent.com/prosopo/demo-nft-marketplace/article/.github/images/screenshot2.png">

How to run locally

1. Build the contract

The contract metadata JSON is required to interact with the contract from the frontend. You can obtain this by building the contract sources. Run the following command from the root of the repository to build the contract.

docker run --rm -it -v $(pwd):/sources paritytech/contracts-ci-linux:production \
  cargo +nightly contract build --manifest-path=/sources/contracts/Cargo.toml

2. Install packages and set up environment variables

npm install

npm run setup

3. Fund your test account

3a. Wallet Setup

You will need to have a test account present in a polkadot wallet. Choose either talisman , subwallet or polkadotjs. Please only install one wallet in your browser! Once you have installed a wallet, create an account.

3b. Send some funds to your wallet

Go to polkadot apps and select the development endpoint (ws://localhost:9944).

Select endpoint

Send some funds from one of the test accounts (Alice etc.) to your test account.

Send funds

4. Start the app

npm run dev

How it works

The NFT marketplace is composed of two parts - the website and the smart contract backend. A user is requested to connect their web3 account when they enter the marketplace.

Selecting an account

Once an account has been selected they can begin the purchase process. Upon clicking buy, the website frontend checks if the user's account has previously completed captcha challenges by calling the prosopo protocol contract. If the user has answered the majority of previous captcha challenges correctly within a certain timeframe, they will be allowed to purchase an NFT. Otherwise, they will be shown a captcha challenge.

is_human checks in Dapp frontend website

The frontend checks the is_human function in the protocol contract before it allows the user to purchase.

https://github.com/prosopo/demo-nft-marketplace/blob/65669d7d3909bb287718b028e95e013f1c29ee78/src/components/Modal/CheckoutModal.tsx#L49-L59

is_human checks in NFT Contract

There are additional checks in the NFT marketplace smart contract that prevent the user from calling the NFT marketplace contract directly, bypassing the frontend checks.

The threshold number of captcha that the user must correctly answer is set to 80% within the last 5 minutes. In this example, the values are fixed in the NFT contract however they could reside elsewhere.

https://github.com/prosopo/demo-nft-marketplace/blob/65669d7d3909bb287718b028e95e013f1c29ee78/contracts/lib.rs#L78-L79

https://github.com/prosopo/demo-nft-marketplace/blob/65669d7d3909bb287718b028e95e013f1c29ee78/contracts/lib.rs#L203-L217

https://github.com/prosopo/demo-nft-marketplace/blob/65669d7d3909bb287718b028e95e013f1c29ee78/contracts/lib.rs#L186-L200

Flow

The entire process flow can be visualised as follows.

Main CAPTCHA flow