Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/weijiekoh/zknftmint
https://github.com/weijiekoh/zknftmint
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/weijiekoh/zknftmint
- Owner: weijiekoh
- Created: 2021-12-01T23:41:49.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-08-22T14:59:40.000Z (over 1 year ago)
- Last Synced: 2024-11-05T03:36:52.281Z (2 months ago)
- Language: Solidity
- Size: 1.72 MB
- Stars: 48
- Watchers: 3
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-zero-knowledge-proofs - zk-NftMint: Mint an NFT if you know a secret
README
# Mint an NFT if you know a secret
Developed for 0xPARC.
Contract on Goerli: [`0xc4490d6407f81378c8d3620eA11092B2FC429Df2`](https://goerli.etherscan.io/address/0xc4490d6407f81378c8d3620eA11092B2FC429Df2)
## Getting started
Clone this repository and install dependencies:
```bash
git clone [email protected]:weijiekoh/zknftmint.git
cd zknftmint
npm i
npm run bootstrap
```You may need to manually install dependencies for `zkey-manager` by following instructions [here](https://github.com/privacy-scaling-explorations/zkey-manager#requirements).
In a separate terminal, run a HTTP server in `web/zkeys`:
```bash
cd web/zkeys
npx http-server --cors -p 8000
```In another terminal, run the web application:
```bash
cd web
npm run serve
```Get Goerli ETH: https://faucet.paradigm.xyz/
To generate a proof and nullifier, first navigate to:
http://127.0.0.1:1234
Next, paste your ETH address from Metamask and enter the secret (currently
hardcoded to `1234`). Click "Create proof".Navigate to the Write Contract page for the NftMint contract on Etherscan,
click on "Connect to Web3", and select `mintWithProof`. Copy and paste the
nullifier and the proof, and click "Write".https://goerli.etherscan.io/address/0xc4490d6407f81378c8d3620eA11092B2FC429Df2#writeContract
If the proof is valid and you have not previously used this address to mint an
NFT on this contract, the transaction will execute and mint an NFT to your
address.## Development
To install NPM dependencies, run this in the project's root directory:
```
npm i && npm run bootstrap
```To compile the Typescript code for tests, run:
```
npm run build
```To compile the circuits, generate its zkey file, and export its verification
key for off-chain proof verification:```
cd circuits
npx zkey-manager compile -c ./zkeys.config.yml
npx zkey-manager downloadPtau -c ./zkeys.config.yml
npx zkey-manager genZkeys -c ./zkeys.config.yml
npx snarkjs zkev ./NftMint__prod.0.zkey ./zkeys/verification_key.json
node build/exportVerifier.js ./zkeys/NftMint__prod.0.zkey ../contracts/contracts/verifier.sol
```Note that no phase 2 trusted setup is performed, so do not use this in
production unless you perform one.Next, compile the contracts:
```
cd ../contracts
npm run compileSol
```Deploy the contracts to a testnet:
```bash
npx hardhat run build/deploy.js --network goerli
```Verify the contracts on Etherscan:
1. Update `contracts/hardhat.config.js` with your Etherscan API key.
2. Run:```bash
npx hardhat verify --network goerli ""
```