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.
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
npm install
npm run 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.
Go to polkadot apps and select the
development endpoint (ws://localhost:9944
).
Send some funds from one of the test accounts (Alice etc.) to your test account.
npm run dev
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.
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.
The frontend checks the is_human
function in the protocol contract before it allows the user to purchase.
demo-nft-marketplace/src/components/Modal/CheckoutModal.tsx
Lines 49 to 59 in 65669d7
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.
demo-nft-marketplace/contracts/lib.rs
Lines 78 to 79 in 65669d7
demo-nft-marketplace/contracts/lib.rs
Lines 203 to 217 in 65669d7
demo-nft-marketplace/contracts/lib.rs
Lines 186 to 200 in 65669d7
The entire process flow can be visualised as follows.