Giter Site home page Giter Site logo

samherring99 / starsnft Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 5.03 MB

A repository containing a real example of an ERC721 smart contract NFT token set generated in Ruby and hosted on Github and deployed through the Remix IDE.

Home Page: https://starsnft.herokuapp.com/

License: GNU General Public License v3.0

Ruby 92.32% Solidity 6.60% Shell 1.08%
nft erc721 blockchain ethereum smart-contracts ruby solidity

starsnft's Introduction

Stars NFT Generation, Data Hosting and Smart Contract Creation

Cover

This page serves as the home for the Stars NFT Project.


Get one here, or check out the Discord to join the Stars community!


This repository also contains a real example of the workflow for:

  1. Algorithmically generating a set of NFTs with tiered rarity structure.

  2. Hosting the image and metadata for the generated NFT set on Github.

  3. Creating an ERC721 smart contract in Solidity with contract metadata linked to Github hosting.

Requirements

Notes Before Using This Code

  • If you want to create AND HOST your own NFT set here using this code: FORK THIS REPOSITORY.
  • If you want to create your own NFT set and NOT host it here, or if you simply just want to experiment: CLONE THIS REPOSITORY.

Usage

Once dependencies are all installed, enter the starsnft directory with cd starsnft after cloning/forking. This is the main working directory for this project and is where all commands should be entered. Below are the steps for replicating this project.

Step 1: Creating Attributes

Part1 Part2 Part3 Part4 Part9 Part7 Part5 Part6 Part8

(OPTIONAL) Run cleaning script bash clean.sh to empty already generated image directories and their descriptions to give you a fresh project to work with.

The first step to creating a set of generated NFT avatars with tiered rarity structure is coming up with A. a list of attributes and B. their rarities within the collection. For example, the above set of images shows the attributes for the Stars NFT Collection. Listed out, these attributes are:

- Gender
- Background
- Body
- Eyes
- Mouth
- Nose
- Shoes
- Hat (optional)
- Socks (optional)
- Accessories (optional)

For each 'optional' attribute, there are rarities for these attributes to occur such as a Hat being 30% likely to appear, Socks being 40% likely to appear and a 20% chance of having an Accessory.

Within the attributes, there are also rarities, like:

- Gender - 70% male, 30% female
- Background - 60% (red, orange, yellow), 25% (green, blue), 15% (yellow)
- Body - All 25%
- etc.

Attributes can also have rarities dependent on the Gender attribute, like how female Stars can have earrings or lipstick on their mouths. Attribute rarities and the code for assigning attributes to specific genders or other attribute instances can be found in the generate.rb file.

Once you have your attributes planned out, it's time to start drawing assets!

Open the PNG image editing tool of your choice (GIMP is free and works perfectly for this use case), and create a blank canvas or project of size 56 pixels by 56 pixels.

After you've finished, export all of your .png files to the 'parts' directory, with subfolders for each attribute just like how the example is set up. Don't forget to make the background transparent when exporting.

Step 2

Assuming that you've created your image assets and organized it accordingly (or are using the provided 'parts' directory), you can now generate your images!

Execute the command ruby generate.rb in the main project directory and read the output for descriptions.

Star2 Star1

Above are some examples of generated stars in this Stars NFT Collection, specifically Star 98 and Star 121.

After the Ruby program finished, you will be left with 3 folders and a file:

- gen - This folder contains all PNG images from the set generated at 1x size (56 px by 56 px by default).
- img - This folder contains all PNG images from the set generated at 6x size (336 px by 336 px by default).
- descriptions - This folder contains all metadata descriptions in text files for each generated image.
- metadata.json - This file contains contract-level metadata info for the whole collection.

Congratulations! You just generated your first set of NFT token images. In order to host them for access by the blockchain, publish them here to your fork or create a new repository.

Step 3

Once your images are generated and uploaded, it's time to move to the blockchain!

Make sure your metadata.json file is filled out with the correct parameters (name, description, image, and external_url are straightforward), namely your MetaMask wallet address to recieve royalties on sales, and the seller_basis_fee of 250, which corresponds to a 2.5% royalty fee deposited to your wallet for every transaction. All of these values can and should be changed as needed.

Open the SampleContract.sol file in a text editor of your choice. For the simple, base ERC721 contract, only the constructor, baseURI(), and contractURI() methods need to be changed for deployment.

Constructor: change the contract name and symbol to match what you want. baseURI(): change the return string to match the location of your hosted 'descriptions' folder. contractURI(): change the return string to match the location of your hosted 'metadata.json' file.

If you want to add any other complexity or methods to your contract, now would be the time to do it. You can also create any other type of Solidity smart contract of your choice and use that with this repository as well. Just be sure to change the correct baseURI and contractURI values when appropriate.

DEPLOYMENT

REMIX:

  • Open up Remix and import SampleContract.sol (or create your own there) in the first (highest) tab.
  • Once all the code and values in the contract file are set, navigate to the second tab down to compile it. Remix does have an auto-compile option, but just make sure that it's compiled anyways.
  • After compilation, you are ready for deployment!
    • If you want to deploy to a testnet first, you'll need some test ETH. Head over to a Rinkeby or Ropsten faucet to get some ether to experiment with.
    • If you want to deploy straight to mainnet, you'll need ~0.5 ETH in your MetaMask wallet to cover gas fees for deployment and minting.
  • Move to the third tab on the page, select your environment as Injected Web3 (make sure you are on the correct network in Metamask!), select your contract file, and press Deploy.
  • After confirming with Metamask, your deployed contract and its methods should appear under the 'Deployment' section.
  • Click the 'safeMint' button in red to mint your first token.
  • If you made it to this step with no issues, you've just deployed your first smart contract and minted your first NFT on the blockchain!
  • Visit https://testnets.opensea.io/assets/CONTRACT_ADDRESS/0 for Rinkeby/Ropsten or https://opensea.io/assets/CONTRACT_ADDRESS/0 for Mainnet to view your NFT.

Truffle:

Happy creating!

DISCLAIMER

This project, in potentally involving the real Ethereum mainnet blockchain, DOES involve real finances if you choose to do so. This repository was created solely for educatoinal purposes, and its creators take zero financial responsibility over money YOU put in to the blockchain for NFT projects, or any financial harm caused to any individual by any projects you release with this code. Do your own research, always be aware of what you're clicking and agreeing to on any website, and invest your money wisely.

starsnft's People

Contributors

samherring99 avatar

Stargazers

 avatar Diane avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.