The One Question bounty closes Thursday 10 December.

Join in
We Them Media logo We Them Media Support us

Web3bridge Students (Cohort XI) Share What They’ve Learned: NFT Gated Event Contract

The picture loads from YouTube. The player loads only when you press Play. Turn on captions in the player if you need them.

A Web3Bridge Cohort 11 student describes a team project: an NFT-gated event platform where only holders of an event NFT can register. They walk through the create event, register and get attendees functions, then compare two ways to mint the NFT, storing images on IPFS through a pinning service or encoding an SVG straight on chain.

Not by We Them Media Channel: Web3Bridge. Published Saturday 14 December 2024.

Titles are the owner’s. It plays from their channel.

Transcript

This transcript may contain errors. This video belongs to Web3Bridge. Letters mark each change of speaker.

These are the speakers’ own words. We have not checked their claims.

0:00 A: This video is proudly brought to you by Virtue Bridge with LIX, our official sponsors for Cohort 11.

0:08 B: Hi, my name is Chukwuma Alexia. So for this week, I and my colleagues were tasked with working on an NFT-gated event platform, event system, where, where persons can come and create events, different types of events. And then whenever a person If a person wants to participate in the event, you have to own, you have to own an NFT, and without the NFT, you can't register for the event. So basically, we just started the process of working on it by creating some structure mapping and our functions to put the whole project together.

0:53 C: So one of the ways we're able to achieve this particular contract is we created a few functions. The functions we created was a create event function, a register for the event function. We were also able to enact a get attendees for a particular event. So within the create event function, we checked for a few things, make sure that you actually give a legit title, a proper description, a proper location for the event to ensure that- just sanity checks to make sure that this event is not a dummy event. Then we went on to allow attendees for the event register for the event by specifying the event ID. So when you specify the event ID during the check in the register function, it checks if you have the required NFT for that particular event. If you do not, it throws an error informing you that you don't have that NFT. But then again, we also enacted a function within our contract that allows you to actually mint the NFT for that particular event. So once you've been able to mint that particular NFT, you can come back and register for the event.

1:53 D: So the contract ensures that anyone that is signing up for an event, that is registering for an event, has an NFT in their wallet. So to do that, the NFT itself has to be minted. And these NFTs are non-fungible tokens, which means that they are unique and they are created using ERC-721 contracts, right, which distributes the NFTs with unique token IDs to every user. One way to mint this NFT is to upload your image, right, to the Interplanetary File System, which is IPFS. And there are different platforms that make use of this IPFS protocol to store media online because storing media on the blockchain is computationally It's computationally expensive and it's also resource intensive, right? So the platform we used to mint and deploy this NFT was Pianta. It uses the IPFS protocol. And when- after, after, anytime you upload a file to Pianta, you get a unique ID, a CID, right? And then you carry that ID, you put it in a JSON file, and then we upload that JSON file to get a unique ID. that you then pass into your NFT smart contract, the mint function in that contract, which then stores that metadata on-chain, and then it reflects on an NFT platform like OpenSea. So another way to also mint these NFTs is to actually store the NFT data on-chain. So we use SVG files to store our images, right? So you can't technically store the SVG as in that file format on-chain, right? So we had to use the Base64 contract from OpenZeppelin to- we then encoded it to Base64. Then after getting that file, the output from that Base64 format, we then passed that into a string that contained the metadata of the NFT, of the image, right? With the name, the description, and all of that. And then we encode that again in Base64, and then we then pass that into the mint function to be stored on-chain. So yeah, these are the 2 methods of minting and deploying NFTs for use. We've seen that it's not just in collectibles or collectibles like NFTs, like Bored Ape Yacht Club, CryptoPunks, and all of that, like kinds of NFTs, right? You can also use them in a more practical application in an event. Gated contract. So thanks for joining us, and for more updates, make sure to like, subscribe, comment.

More from this hub

Something wrong, or a video you want off this page? Write to wethem.xyz@gmail.com and it is fixed or taken down within 48 hours.