{"id":20060614,"url":"https://github.com/oasisprotocol/demo-quiz","last_synced_at":"2026-06-15T16:32:34.761Z","repository":{"id":241574292,"uuid":"791748742","full_name":"oasisprotocol/demo-quiz","owner":"oasisprotocol","description":null,"archived":false,"fork":false,"pushed_at":"2026-04-23T15:16:10.000Z","size":963,"stargazers_count":0,"open_issues_count":3,"forks_count":1,"subscribers_count":11,"default_branch":"main","last_synced_at":"2026-04-23T16:38:17.842Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://playground.oasis.io/demo-quiz","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oasisprotocol.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-04-25T09:45:56.000Z","updated_at":"2025-07-04T07:36:16.000Z","dependencies_parsed_at":"2025-03-31T10:32:07.365Z","dependency_job_id":"c1b68ad9-d59e-4643-8dbe-23066b416705","html_url":"https://github.com/oasisprotocol/demo-quiz","commit_stats":null,"previous_names":["oasisprotocol/demo-quiz"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/oasisprotocol/demo-quiz","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oasisprotocol%2Fdemo-quiz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oasisprotocol%2Fdemo-quiz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oasisprotocol%2Fdemo-quiz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oasisprotocol%2Fdemo-quiz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oasisprotocol","download_url":"https://codeload.github.com/oasisprotocol/demo-quiz/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oasisprotocol%2Fdemo-quiz/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34372121,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-15T02:00:07.085Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T13:15:57.787Z","updated_at":"2026-06-15T16:32:34.735Z","avatar_url":"https://github.com/oasisprotocol.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Oasis Demo Quiz dApp\n\nA confidential quiz dApp exposing the RNG to generate a random order of\nquestions per coupon with the reward payout for the ones who solve it.\nRuns on Oasis Sapphire.\n\n- `backend` contains the solidity contract, deployment and testing utils.\n- `frontend` contains a Vue-based web application communicating with the\n  backend smart contract.\n\nThis monorepo is set up for `pnpm`. Install dependencies by running:\n\n```sh\npnpm install\n```\n\n## Backend\n\nMove to the `backend` folder and build smart contracts:\n\n```sh\npnpm build\n```\n\nNext, deploy the contract.\n\n### Basic Local Hardhat Deployment\n\nStart the hardhat node:\n\n```sh\nnpx hardhat node\n```\n\nDeploy smart contracts to that local network:\n\n```sh\nnpx hardhat deploy --network localhost\n```\n\nThe deployed Quiz and NftReward addresses will be reported. Store them\ninside the `frontend` folder's `.env.development`, for example:\n\n```\nVITE_QUIZ_ADDR=0x385cAE1F3afFC50097Ca33f639184f00856928Ff\n```\n\n### Deploying to Sapphire Localnet, Testnet and Mainnet\n\nPrepare your hex-encoded private key and store it as an environment variable:\n\n```shell\nexport PRIVATE_KEY=0x...\n```\n\nTo deploy the Quiz and Reward contracts to the [Sapphire Localnet], Testnet or Mainnet, use the\nfollowing commands respectively:\n\n```shell\nnpx hardhat deployQuiz --network sapphire-localnet\nnpx hardhat deployQuiz --network sapphire-testnet\nnpx hardhat deployQuiz --network sapphire\n```\n\n```shell\nnpx hardhat deployNftReward --network sapphire-localnet\nnpx hardhat deployNftReward --network sapphire-testnet\nnpx hardhat deployNftReward --network sapphire\n```\n\n[Sapphire Localnet]: https://github.com/oasisprotocol/oasis-web3-gateway/pkgs/container/sapphire-dev\n\n### Once deployed\n\nChecklist after deploying a production-ready quiz:\n\n1. Push questions. Example:\n\n   ```shell\n   npx hardhat addQuestions 0x385cAE1F3afFC50097Ca33f639184f00856928Ff test-questions.json --network sapphire-testnet\n   ```\n\n2. Add coupons. Example:\n\n   ```shell\n    hardhat addCoupons 0x385cAE1F3afFC50097Ca33f639184f00856928Ff test-coupons.txt  --network sapphire-testnet\n   ```\n\n3. Set ROSE payout reward amount. Example:\n\n   ```shell\n   npx hardhat setReward 0x385cAE1F3afFC50097Ca33f639184f00856928Ff 2.0  --network sapphire-testnet\n   ```\n\n4. Set gasless kaypair. The current account nonce will be fetched and stored to\n   the contract. Because of that, the provided account **must be used solely for\n   gasless transactions by the deployed quiz contract**. Example:\n\n   ```shell\n   npx hardhat setGaslessKeyPair 0x385cAE1F3afFC50097Ca33f639184f00856928Ff 0xd8cA6E05FC1a466992D98f5f4FFC621ca95b7229 0xbf63c1e7982a80f424b5e8c355b7f11a0968bf44b1407c473aadb364b8c291d3  --network sapphire-testnet\n   ```\n\n5. Fund the contract and the gasless account. Example:\n\n   ```shell\n   npx hardhat fund 0x385cAE1F3afFC50097Ca33f639184f00856928Ff 100  --network sapphire-testnet # contract\n   npx hardhat fund 0xd8cA6E05FC1a466992D98f5f4FFC621ca95b7229 10  --network sapphire-testnet # gasless account\n   ```\n\n6. Set NFT reward contract address and enable Mint from Quiz contract.\n\n   ```shell\n   npx hardhat setNftAddress 0x385cAE1F3afFC50097Ca33f639184f00856928Ff  0xB22C255250d74B0ADD1bfB936676D2a299BF48Bd --network sapphire-testnet\n   npx hardhat storeNFT 0xd8cA6E05FC1a466992D98f5f4FFC621ca95b7229 'test/assets/images/metadata_inline.json'   --network sapphire-testnet\n   ```\n\n7. Check the quiz contract status, to make sure if everything is set. Example:\n\n   ```shell\n   npx hardhat status 0x385cAE1F3afFC50097Ca33f639184f00856928Ff --network sapphire-testnet\n   ```\n\n   You can also obtain details on spent coupons as follows (may take a while):\n\n   ```shell\n   npx hardhat getCoupons 0x385cAE1F3afFC50097Ca33f639184f00856928Ff --network sapphire-testnet\n   ```\n\n### Deploy and setup quiz with a single task\n\nYou can also setup and run the entire quiz in a single task.\n`deployAndSetup` deploys and sets up the quiz and NFT reward.\n\n```shell\nnpx hardhat deployAndSetup test-config.yaml --network sapphire-testnet\n\n```\n\nCheck out other hardhat tasks that will help you manage the quiz:\n\n```shell\nnpx hardhat help\n```\n\n### A note on tests:\n\nWhen running tests on sapphire-localnet\n\n```shell\nnpx hardhat test --network sapphire-localnet\n```\n\navoid setting $PRIVATE_KEY environment variable, \nunless the address associated with this key is already funded on the network. \n\n### Additional tasks\n1. Add single question.\n\n```shell\nnpx hardhat addQuestion \"My question?\" 0x385cAE1F3afFC50097Ca33f639184f00856928Ff --network sapphire-testnet\n```\n\n2. Clear questions.\n\n```shell\nnpx hardhat clearQuestions 0x385cAE1F3afFC50097Ca33f639184f00856928Ff --network sapphire-testnet\n```\n\n3. Reclaim funds from Quiz contract.\n\n```shell\nnpx hardhat reclaimFunds 0x385cAE1F3afFC50097Ca33f639184f00856928Ff 0xC66AB83418C20A65C3f8e83B3d11c8C3a6097b6F --network sapphire-testnet\n```\n\n4. Fetch from Ipfs.\n\n```shell\nnpx hardhat fetchImageFromIpfs Qmbr87zRx1uGM9fGYgHXRyq4EwSZ4jSaiXwQZC7ACpNcfW output.png\n```\n\n## Frontend\n\nAfter you compiled the backend, updated `.env.development` with the\ncorresponding address and a chain ID, move to the `frontend` folder, compile\nand Hot-Reload frontend for Development:\n\n```sh\npnpm dev\n```\n\nNavigate to http://localhost:5173 with your browser to view your dApp. Some\nbrowsers (e.g. Brave) may require https connection and a CA-signed certificate\nto access the wallet. In this case, read the section below on how to properly\ndeploy your dApp.\n\nYou can use one of the deployed test accounts and associated private key with\nMetaMask. If you use the same MetaMask accounts on fresh local networks such as\nHardhat Node, Foundry Anvil or sapphire-dev docker image, don't forget to\n**clear your account's activity** each time or manually specify the correct\naccount nonce.\n\n### Frontend Deployment\n\nYou can build assets for deployment by running:\n\n```sh\npnpm build\n```\n\n`dist` folder will contain the generated HTML files that can be hosted.\n\n#### Different Website Base\n\nIf you are running dApp on a non-root base dir, add\n\n```\nBASE_DIR=/my/public/path\n```\n\nto `.env.production` and bundle the app with\n\n```\npnpm build-only --base=/my/public/path/\n```\n\nThen copy the `dist` folder to a place of your `/my/public/path` location.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foasisprotocol%2Fdemo-quiz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foasisprotocol%2Fdemo-quiz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foasisprotocol%2Fdemo-quiz/lists"}