Giter VIP home page Giter VIP logo

eth-nft-drop's Introduction

eth-nft-drop

Intro

This project is my REACTION to the video ⬇️

IMAGE ALT TEXT

Detail

Tech stack

Sketch

Not entirely correct

πŸ€“ Instead of editing in Mongo Atlas, we can use CMS for marketing team can edit too.

Kick-start project

npm create-next-app -e with-tailwindcss my-project

Project structure

  • πŸ—‚ Folder pages where all pages in your site placed

  • 🌈 TailwindCSS allows you quickly applying CSS to components

    • Font
    • Text size
    • Color
  • Nextjs

    • Replace class component by function component
     function Search() {
        return (
          <div> Search <div/>
        )
     }
     
     export default Search
    • Path

      • Ex: localhost:3000/NFT/para-farm
      • Create folder NFT under pages folder then [id].tsx this mean wildcard
    • Flexbox

      <div className="flex h-screen flex-col lg:grid lg:grid-cols-10">
        {/* Left */}
        <div className="lg:col-span-4">
          <div> LEFT </div>
        </div>
      </div>

      lg:min-h-screen meaning on large screen the min height of component is the height of the screen

      lg:h-96 lg:w-72 meaning on large screen (height, width) = (96, 72)

      <button className="px-4 py-2 lg:px-5 lg:py3"/> meaning ONLY (5,3) in large screen, OTHER screens (small, medium) will be (4,2). Same apply for flex (small, medium) large will go with grid

      flex-1 flex-col 1 meaning get all the space

      If not large screen case, it will back to 'flex' mode, meaning it will layout at it's ease
      ⚠️ Flex it NOT Grid

      • Flex: 1 dimensional layout, will expand all items in 1 line then go to next line.
        Flex everything is on the same row
      • Grid: 2 dimensionals
        Split the screen by cols

      https://www.geeksforgeeks.org/comparison-between-css-grid-css-flexbox/
      Fine to use both at the same component which means depends on
      // by row, but each row will divide by number of cols
        <flex>
          <grid />
        <flex/>
      // or 
      // by number of cols, but each col will layout in one row
        <grid>
          <flex />
        <grid/>
    • Thirdweb: Wrap your entire app (_app.tsx)

      return(
       <ThirdwebProvider desiredChainId={ChainId.bsc}>
        <Component {...pageProps} />
       </ThirdwebProvider>
      )

      πŸ‘ Beside that, thirdweb provides NFT drop, which you can just upload the images and hit Deploy button Instead of 1.png and 1.json we can use bulk upload replace json files by .csv

    • πŸ–– Vercel:
      https://vercel.com/
      You can deploy your FE for free, connecting thru github

    • 😲 Opensea test net
      https://testnets.opensea.io/

    • πŸ”΄ Typescript
      We need define the type to avoid warning

      // typings.d.ts where you specify how object should look
      interface Image {
       asset: {
        url: string
       }
      }
      export interface Creator {
       _id: string
       name: string
       image: Image
       bio: string
      }
      
      export interface Collection {
       _id: string
       title: string
       creator: Creator
       address: string
      }
      
      // index.js 
      interface Props {
       collections: Collection[]
      }

      Typescript using interface to define type

    • 🐸🐸🐸 Fetch

      • In Next.js using getServerSideProps to fetch data everytime it renders the page

        You should use getServerSideProps only if you need to render a page whose data must be fetched at request time https://nextjs.org/docs/pages/building-your-application/data-fetching/get-server-side-props

      • Next.js is server render/ pre-rendering
        Actually, both React and Next.js are hosted in Remote server so both are SSR (server side rendering) BUT react render page by download js files instead html tags like Next.js so Next is lil better

SSR CSR
https://www.freecodecamp.org/news/next-vs-react/
https://blog.logrocket.com/create-react-app-vs-next-js-performance-differences/
function NFTDropPage({collection}: Props) {
  const [claimedSupply, setClaimedSupply] = useState<number>(0)
  const nftDrop = useNFTDrop(collection.address)

  //🀌 CAN use many useEffect as you want 
  useEffect(()=> {
    //fetchPrice
  }, [])
  
  useEffect(()=> {
    if (!nftDrop) return; //defensive programming

    const fetchNFTDropData = async () => {
      const claimed = await nftDrop.getAllClaimed();

      setClaimedSupply(claimed.length)
    }
    fetchNFTDropData()
  },[nftDrop])
}

THE end

  1. I see no reason to use Sanity as content center (CMS). πŸ€·β€β™‚οΈ
  2. Surprisingly, this entire app despite strongly is a Another blockchain tutorial, but not a single line of Sol written. thirdweb is all you need πŸ€”
  3. Using testnet open-sea to check minting instead bsc-scan πŸ‘

Author

This repo was developed by @lamha. Follow or connect with me on my LinkedIn.

License

eth-nft-drop's People

Contributors

halamus avatar

Stargazers

 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.