NFTwitch - Earn dynamic NFTs as you grow your Twitch channel, for Chainlink Hackathon 2021!

Rinkeby demo: https://nftwitch.link/

Please note the demo only works on Rinkeby, so do NOT send any crypto on mainnet - it will be lost!

A longer video can be viewed here

Inspiration

While brainstorming project ideas, I thought maybe I should try doing something related to NFTs since they are popular right now. One of the ideas mentioned in this article involves minting NFTs based on external conditions. As a gamer, game developer, and streamer, it was not long before I realized I could try to integrate with Twitch for this purpose. I thought it would be really cool if I could have a way to generate new NFTs based on reaching goals as a streamer. I would be able to sell the NFTs to fans, who would be happy to buy them to support my streams. It was really easy for me to imagine lots of people actually using this product for real purposes, so I didn't hesitate to start working on it.

What it does

Streamers register with a smart contract via the front-end, using Chainlink's API to verify ownership of their Twitch account. Streamers can periodically return to the site and mint a number of NFTs when a new follower threshold is reached (verified by Chainlink). Upon minting, the NFTs are allocated to the streamer and can then be redistributed and/or sold to fans. Additionally, Chainlink is used to get a link to the streamer's avatar from the Twitch API to be stored in a metadata file which is then uploaded to IPFS.

How we built it

The front-end web app was built in React using create-eth-app and ethers.js. The smart contracts were developed using Solidity on the Ethereum blockchain. I had to build a custom external adapter for getting the API data from Twitch, which I wrote in Javascript. I also had to run my own Chainlink node. I had both the EA and the node running in Docker containers, which I then uploaded to Amazon Web Services. The demo website is hosted on Heroku. And I learned how to use IPFS and Pinata to store files.

Challenges we ran into

The biggest challenge was doing everything I wanted to do within the time limit. Due to the scope of the project, I had to do a little bit of everything. So I would often get started on one aspect, make good progress, and then get stuck when moving onto the next part. Most of my time was either spent setting up the infrastructure for the Chainlink node and external adapter, or writing the smart contract in an efficient and user-friendly way.

Accomplishments that we're proud of

I'm most proud of having built (to my knowledge) the first external adapter for the Twitch API and to use it in a working dapp with a real use-case.

What we learned

I learned so much from this project! Going into it I did have some prior experience writing smart contracts and web development but nothing for a major project like this. I learned how to set up my own Chainlink node, build my own external adapter, host them using Docker on AWS and connect the two of them together. I also learned how to create an ERC-721 smart contract and use Chainlink to make API calls within the contract. And of course I learned how to build a front-end to tie everything together. As someone who is primarily a game developer, this was a project that really made me put my web skills to the test, and I had a lot of fun!

What's next for NFTwitch

There is so much more I could do with this project, if only I had more time:

  • storing the avatar files themselves on IPFS
  • using a Layer 2 solution to reduce gas / speed up transactions
  • having our own marketplace for sharing or trading the NFTs
  • integrating other stats such as view count, broadcaster type, etc.
  • dynamic components such as what game the streamer is currently playing (or has recently played)
  • integrating Chainlink VRF to produce random stats of some kind
  • error-checking on the front-end
  • security audit of the smart contract
  • deploy on mainnet!
Share this project:

Updates