thirdweb: Create a Gated Website Using NFTs and IPFS
Learn how to create a gated website using NFTs and IPFS.
thirdweb is an easy-to-use platform to build Web3 applications with code or no-code. thirdweb makes creating and deploying apps such as NFT collections or NFT marketplaces easy. thirdweb can be used with objects stored on IPFS, so objects stored in a Filebase IPFS bucket can be seamlessly uploaded for use with a thirdweb app.
Read below to learn how to create a gated website using NFTs and IPFS.
- Create a folder of images you’d like to use as NFT images for your NFT drop.
- Have an IDE or text editor for making changes to snippets of code.



Then select 'Deploy Now'.

For this tutorial, we’ll be using the Mumbai testnet, so we are using a Mumbai wallet.


To do this, navigate to console.filebase.com. If you don’t have an account already, sign up, then log in.
Select ‘Create Bucket’ in the top right corner to create a new bucket for your NFTs.

Bucket names must be unique across all Filebase users, be between 3 and 63 characters long, and can contain only lowercase characters, numbers, and dashes.

These files need to be named in sequential order, such as 0.png, 1.png, 2.png, etc.


https://ipfs.filebase.io/ipfs/IPFS_CID
Take note of this URL.
Select the ‘Code’ tab. This code showcases different code snippets to use to mint your NFTs using scripts, with your contract address and crypto wallet address inputted automatically for easy copy and paste. This tutorial will showcase the JavaScript code examples, but you can use any of the languages showcased in this Code tab. You can follow along with the code examples showcased in this tutorial, or copy and paste the snippets provided in this tab.

npm install @thirdweb-dev/sdk
15. Open an IDE such as VSCode and insert the following code, replacing CONTRACT
with your contract address, WALLET_ADDRESS
with your crypto wallet address, each IPFS_CID
with your IPFS folder CID you took note of earlier and replacing the name and description of each NFT with your desired information.
CONTRACT
with your contract address, WALLET_ADDRESS
with your crypto wallet address, each IPFS_CID
with your IPFS folder CID you took note of earlier and replacing the name and description of each NFT with your desired information.import { ThirdwebSDK } from "@thirdweb-dev/sdk";
const sdk = new ThirdwebSDK("mumbai");
const contract = sdk.getContract("CONTRACT", "edition-drop");
// Custom metadata of the NFTs to create
const metadatas = [{
name: "Cool NFT",
description: "This is a cool NFT",
image: fs.readFileSync("https://ipfs.filebase.io/ipfs/IPFS_CID/0.png"), // This can be an image url or file
},
}];
const results = await contract.createBatch(metadatas); // uploads and creates the NFTs on chain
const firstTokenId = results[0].id; // token id of the first created NFT
const firstNFT = await results[0].data(); // (optional) fetch details of the first created NFT
node mint.js

This will determine who is able to claim this NFT.



Open a command-line window, then create a project with this template with the following command:
npx create-tw-app --example nft-gated-website
cd nft-gated-website
npm install
npm run dev
Replace the following value with the contract address you took note of earlier.
// Replace this address with your NFT Drop address!
const editionDrop = useEditionDrop(
"CONTRACT_ADDRESS"

You can change the text, style, and any other aspect of this webpage by editing the src/App.js file.



You can also change this text in the
src/App.js
file to reflect your NFT drop.Using this example, you can expand on and create a landing page that NFT holders are redirected to after minting their membership NFT, creating a gated website exclusive to your NFT holders!
If you have any questions, please join our Discord server, or send us an email at [email protected]