{"id":19498072,"url":"https://github.com/patrickalphac/dungeons-and-dragons-nft","last_synced_at":"2025-04-25T22:33:00.446Z","repository":{"id":43076192,"uuid":"301726444","full_name":"PatrickAlphaC/dungeons-and-dragons-nft","owner":"PatrickAlphaC","description":"#chainlink #nft","archived":false,"fork":false,"pushed_at":"2021-06-28T12:06:43.000Z","size":2093,"stargazers_count":618,"open_issues_count":5,"forks_count":272,"subscribers_count":17,"default_branch":"master","last_synced_at":"2023-11-07T17:15:35.643Z","etag":null,"topics":["chainlink","nft","oracle","truffle"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PatrickAlphaC.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}},"created_at":"2020-10-06T12:56:02.000Z","updated_at":"2023-11-02T15:52:23.000Z","dependencies_parsed_at":"2022-09-13T10:40:27.259Z","dependency_job_id":null,"html_url":"https://github.com/PatrickAlphaC/dungeons-and-dragons-nft","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PatrickAlphaC%2Fdungeons-and-dragons-nft","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PatrickAlphaC%2Fdungeons-and-dragons-nft/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PatrickAlphaC%2Fdungeons-and-dragons-nft/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PatrickAlphaC%2Fdungeons-and-dragons-nft/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PatrickAlphaC","download_url":"https://codeload.github.com/PatrickAlphaC/dungeons-and-dragons-nft/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224019638,"owners_count":17242176,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["chainlink","nft","oracle","truffle"],"created_at":"2024-11-10T21:49:07.876Z","updated_at":"2024-11-10T21:49:09.032Z","avatar_url":"https://github.com/PatrickAlphaC.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Chainlink Random Character Creation\n\nThis repo is a starting point for creating:\n1. NFTs built with verifiable RNG using the [Chainlink VRF](https://docs.chain.link/docs/get-a-random-number)\n2. Create dynamic NFTs that change based on real world data. [By using decentralized oracles to get data.](https://docs.chain.link/docs/make-a-http-get-request)\n3. Adding your randomized NFTs to the [OpenSea Marketplace](https://opensea.io/)\n\nSkip down to [deploy To Opensea](#deploy-to-opensea) - to see how to add a tokenURI\n\nWe will easily create our own NFT on the Rinkeby Chain. We can edit the name of the character in the [`generate-character.js`](./scripts/generate-character.js) script. \n\nThis will create a character with 6 attributes from 0 - 99:\n -   uint256 strength;\n -   uint256 dexterity;\n -   uint256 constitution;\n -   uint256 intelligence;\n -   uint256 wisdom;\n -   uint256 charisma;\n\nAnd then:\n -   uint256 experience;\n -   string name;\n\n## Quickstart\n\nRight now this repo only works with rinkeby. Run the following.\n\n### Setup Environment Variables\nYou'll need a `MNEMONIC` and a rinkeby `RINKEBY_RPC_URL` environment variable. Your `MNEMONIC` is your seed phrase of your wallet. You can find an `RINKEBY_RPC_URL` from node provider services like [Infura](https://infura.io/)\n\nThen, you can create a `.env` file with the following.\n\n```bash\nMNEMONIC='cat dog frog....'\nRINKEBY_RPC_URL='www.infura.io/asdfadsfafdadf'\n```\n\nOr, set them in a `bash_profile` file or export them directly into your terminal. You can learn more about [environment variables here](https://www.twilio.com/blog/2017/01/how-to-set-environment-variables.html). \n\nTo run them directly in your terminal, run: \n```bash\nexport MNEMONIC='cat dog frog....'\nexport RINKEBY_RPC_URL='www.infura.io/asdfadsfafdadf'\n```\n\nThen you can get started with:\n\n### Clone The Repo and migrate\n```\ngit clone https://github.com/PatrickAlphaC/dungeons-and-dragons-nft\ncd dungeons-and-dragons-nft\nyarn\ntruffle migrate --reset --network rinkeby\n```\n\nThis will deploy your D\u0026D NFT!\n\n### Generate a character\nYou can now try it out:\n```bash\ntruffle exec scripts/fund-contract.js --network rinkeby\ntruffle exec scripts/generate-character.js --network rinkeby\ntruffle exec scripts/get-character.js --network rinkeby\n```\n\nThis will create a new character with random stats! \nDepending how often you deploy, you can pick which character by changing the [`dnd.getCharacterOverView(1)`](contracts/DungeonsAndDragonsCharacter.sol) command in `get-character.js` to swap the `0` out with whatever `tokenId` of the character you like. \n\nThis will give you the overview of your NFT. You'll see `BN` since the call returns big numbers, you can cast them to ints to see what they are.... Or you could go one step farther\n\n### See it on etherscan or oneclickdapp\n\nYou can get an [Etherscan API key](https://etherscan.io/apis) for free and interact with the NFTs on chain. Then set `ETHERSCAN_API_KEY ` as an environment variable.\n\n```bash\nyarn add truffle-plugin-verify\ntruffle run verify DungeonsAndDragonsCharacter --network rinkeby --license MIT\n```\n\nThis will verify and publish your contract, and you can go to the `Read Contract` section of etherscan that it gives you. \n\nOtherwise, you can use [oneclickdapp](https://oneclickdapp.com/) and just add the contract address and ABI. You can find the ABI in the `build/contracts` folder. Just remember it's not the whole file that is the ABI, just the section that says `ABI`.\n\n\n# Deploy to Opensea\n\nOnce we have our NFTs created, we need to give them a `tokenURI`. TokenURIs are the standard for showing the data of NFTs to the world. This makes it easier to store things like images since we don't have to waste the gas of adding them on-chain. \n\nThe [TokenURI](https://eips.ethereum.org/EIPS/eip-721) represents a URL or other unique identifier, and it is an `.json` file with a few parameters.\n\n```\n{\n    \"name\": \"Name for it \",\n    \"description\": \"Anything you want\",\n    \"image\": \"https://ipfs.io/ipfs/HASH_HERE?file.png\",\n    \"attributes\": [...]\n}\n```\n\nWe are going to be storing these images and meta data in IPFS. You'll need both:\n1. [IPFS](https://ipfs.io/)\n2. [IPFS companion](https://chrome.google.com/webstore/detail/ipfs-companion/nibjojkomfdiaoajekhjakgkdhaomnch?hl=en)\n3. [Pinata](https://pinata.cloud/pinataupload)\n\nIPFS is a peer to peer network for storing files. It's free and open sourced, and we can use it to host our tokenURI. The IPFS companion let's us view IPFS data nativly in our browsers like Brave or Chrome. And Pinata allows us to keep our IPFS files up even when our node is down (don't worry about that for now)\n\nOnce our IPFS node is up, we can start adding files to it. We first want to upload the image of our NFT. What does this D\u0026D character look like? Add it to your IPFS node and then \"Pin\" it. Once pinned, you can get the CID of the pinned file, and make sure it stays pinned by pinning it on your Pinata account. Don't worry, it's free! This will just help keep the data up even when our IPFS node is down. \n\nOnce we have the image pinned and up, we can get the link for that image. It'll look a little something like this:\n\n`https://ipfs.io/ipfs/QmTgqnhFBMkfT9s8PHKcdXBn1f5bG3Q5hmBaR4U6hoTvb1?filename=Chainlink_Elf.png`\n\nThis is a real link, and if you click it and nothing renders, your IPFS companion might not be working, or your IPFS node is down. \n\nOnce we have our image, we can add it to our metadata `.json` file, and add our stats in there. You can see some samples in the `metadata` folder. We want to use the values of our characters that we got off-chain, so be sure to verify what the random numbers you got on etherscan! Once we have the .json metadata file, we want to add that to IPFS as well, and pin it too!\n\nThis metadata json file is going to be our `tokenURI`, so we will modify our `set-token-uri.js` with the `tokenId` of the NFT we are giving a picture to, and adding the ipfs tokenURI.\n\nThen we just run it like:\n\n```\ntruffle exec scripts/set-token-uri.js --network rinkeby\n```\n\nNow, we can get the address of our NFT and head on over to the opensea testnet marketplace to see if we did it correctly. If done correctly, it'll look [something like this](https://testnets.opensea.io/assets/dungeonsanddragonscharacter-v9).\n\n[Here is the link for adding your testnet NFT contract to be viewed on opensea.](https://testnets.opensea.io/get-listed/step-two)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatrickalphac%2Fdungeons-and-dragons-nft","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpatrickalphac%2Fdungeons-and-dragons-nft","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatrickalphac%2Fdungeons-and-dragons-nft/lists"}