{"id":49850072,"url":"https://github.com/midnightntwrk/example-nft-contracts","last_synced_at":"2026-05-14T15:04:34.654Z","repository":{"id":346421590,"uuid":"1190470325","full_name":"midnightntwrk/example-nft-contracts","owner":"midnightntwrk","description":"Example NFT contracts for Midnight","archived":false,"fork":false,"pushed_at":"2026-05-12T14:58:11.000Z","size":79,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-12T16:40:16.686Z","etag":null,"topics":["compact","midnightntwrk"],"latest_commit_sha":null,"homepage":"","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/midnightntwrk.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":"SECURITY.md","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":"2026-03-24T10:08:47.000Z","updated_at":"2026-05-12T16:22:26.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/midnightntwrk/example-nft-contracts","commit_stats":null,"previous_names":["midnightntwrk/example-nft-contracts"],"tags_count":0,"template":false,"template_full_name":"midnightntwrk/midnight-template-repo","purl":"pkg:github/midnightntwrk/example-nft-contracts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/midnightntwrk%2Fexample-nft-contracts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/midnightntwrk%2Fexample-nft-contracts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/midnightntwrk%2Fexample-nft-contracts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/midnightntwrk%2Fexample-nft-contracts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/midnightntwrk","download_url":"https://codeload.github.com/midnightntwrk/example-nft-contracts/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/midnightntwrk%2Fexample-nft-contracts/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33030380,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T13:14:54.681Z","status":"online","status_checked_at":"2026-05-14T02:00:06.663Z","response_time":57,"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":["compact","midnightntwrk"],"created_at":"2026-05-14T15:04:30.653Z","updated_at":"2026-05-14T15:04:34.646Z","avatar_url":"https://github.com/midnightntwrk.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NFT Contracts\n\nThis project is built on the [Midnight Network](https://midnight.network/).\n\n[![Generic badge](https://img.shields.io/badge/Compact%20Toolchain-0.30.0-1abc9c.svg)](https://shields.io/) [![Generic badge](https://img.shields.io/badge/TypeScript-5.8.3-blue.svg)](https://shields.io/)\n\nExample NFT smart contracts for the Midnight blockchain written in the Compact language (Minokawa). Includes two implementations:\n\n- **NFT** — standard ERC-721-style contract with public on-chain ownership\n- **NFT-ZK** — privacy-preserving NFT with hash-based ownership using zero-knowledge proofs\n\nBoth contracts follow a modular pattern: the core logic lives in a reusable module (`modules/Nft.compact`, `modules/NftZk.compact`) that you import into your own contract and wrap with whatever authorization you need.\n\n## Project Structure\n\n```\nexample-nft-contracts/\n├── contracts/\n│   ├── nft/                         # Public NFT contract\n│   │   ├── src/\n│   │   │   ├── nft.compact          # Example contract (admin-only mint/burn)\n│   │   │   ├── witnesses.ts         # TypeScript witness definitions\n│   │   │   ├── modules/Nft.compact  # Reusable NFT module\n│   │   │   └── test/                # Unit tests and simulator\n│   │   ├── CONTRACT.md\n│   │   └── README.md\n│   └── nft-zk/                      # Privacy-preserving NFT contract\n│       ├── src/\n│       │   ├── nft-zk.compact       # Example contract (admin-only mint/burn)\n│       │   ├── witnesses.ts         # TypeScript witness definitions\n│       │   ├── modules/NftZk.compact # Reusable NFT-ZK module\n│       │   └── test/                # Unit tests and simulator\n│       ├── CONTRACT.md\n│       └── README.md\n```\n\n## Prerequisites\n\n- [Node.js v22+](https://nodejs.org/)\n- Yarn\n- Compact devtools installed and on `PATH`\n\n```bash\n# Install the Compact devtools\ncurl --proto '=https' --tlsv1.2 -LsSf https://github.com/midnightntwrk/compact/releases/latest/download/compact-installer.sh | sh\n\nsource $HOME/.local/bin/env\n\n# Install the toolchain version used by this project\ncompact update 0.30.0\n```\n\n## Quick Start\n\n```bash\n# Install dependencies\nyarn install\n\n# Compile contracts and run tests\nyarn test:compile\n```\n\nRunning `yarn compact` and `yarn test` separately is also supported.\n\n## Using as a Module\n\nAdd this repository as a dependency:\n\n```json\n{\n  \"dependencies\": {\n    \"@midnight-ntwrk/example-nft-contracts\": \"github:midnightntwrk/example-nft-contracts\"\n  }\n}\n```\n\nThen import the module in your Compact contract:\n\n```compact\npragma language_version \u003e= 0.22.0;\n\nimport CompactStandardLibrary;\nimport \"@midnight-ntwrk/example-nft-contracts/contracts/nft/src/modules/Nft\";\n\n// Export the circuits you want to expose\nexport {\n  balanceOf,\n  ownerOf,\n  approve,\n  getApproved,\n  setApprovalForAll,\n  isApprovedForAll,\n  transfer,\n  transferFrom\n};\n\nstruct AdminSecretKey { bytes: Bytes\u003c32\u003e; }\nstruct AdminPublicKey { bytes: Bytes\u003c32\u003e; }\n\nexport ledger contractAdmin: AdminPublicKey;\n\nwitness localSecretKey(): AdminSecretKey;\n\nconstructor() {\n  contractAdmin = disclose(deriveAdminPublicKey(localSecretKey()));\n}\n\nexport circuit deriveAdminPublicKey(sk: AdminSecretKey): AdminPublicKey {\n  return AdminPublicKey {\n    bytes: persistentHash\u003cVector\u003c2, Bytes\u003c32\u003e\u003e\u003e([pad(32, \"nft:admin:pk:v1\"), sk.bytes])\n  };\n}\n\n// Wrap mint/burn with your own authorization\nexport circuit mintAdmin(to: ZswapCoinPublicKey, tokenId: Uint\u003c64\u003e): [] {\n  assert(contractAdmin == deriveAdminPublicKey(localSecretKey()), \"Not authorized.\");\n  mint(to, tokenId);\n}\n```\n\nFor the privacy-preserving version, import `NftZk` instead:\n\n```compact\nimport \"@midnight-ntwrk/example-nft-contracts/contracts/nft-zk/src/modules/NftZk\";\n```\n\nThe Compact compiler resolves package imports by searching directories in `COMPACT_PATH`. Make sure your compile script includes `node_modules`:\n\n```bash\nCOMPACT_PATH=$COMPACT_PATH:./node_modules compact compile mycontract.compact output/dir\n```\n\n## License\n\nApache-2.0 — see [LICENSE](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmidnightntwrk%2Fexample-nft-contracts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmidnightntwrk%2Fexample-nft-contracts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmidnightntwrk%2Fexample-nft-contracts/lists"}