2

I'm beginner at solidity development, and I have a question:

How they get NFT collections of various smart contracts to show in the explorer-collection page?

https://opensea.io/explore-collections

2

2 Answers 2

2

Im not sure if this is correct but If I was to make my own marketplace I'd either

  1. Check the Contract creation opcode in transactions in a block

  2. transfer transactions from the 0x00 address to a wallet in a block

  3. you could also listen for events in the blockchain, but i feel is not optimal because you would need to know the deployed contract upfront

Sources for answer 1, 2 and 3:

  1. you can find an answer about contract creation tracking here, you could just read the transactions in a block and verify if there are transactions with the contract creation opcode in them; If there is a contract creation event; then you can verify if it implements any nft standard by calling its supportsInterface(bytes4 interfaceID) in the contract, you can get more info of the standards here 1155 and 721

  2. Read the transactions in a block and verify if there are transfers from the 0x00 address to a wallet

  3. I think this one is not optimal but there are RPC providers that give you event subscription, ie. event subcription for mints (a mint is basically a transfer), the rpc providers i mention are infura or alchemy, there are more like moralis but I prefer these two; you could take a look and see if anything in these rpc providers help your cause

1

If you are looking to simulate OpenSea explore tab menu on your own, and you are not familiarize at all with smart contract and solidity no worries, when you click on '/explore-collection' path to import collections, it shows you several collectios currently they have randomly.

But before creating a 'tab in your navbar or menu' to assign a page and show your assets, you need to create or mint this collections first, and connect each asset with an administrator address wallet and the permissions.

enter image description here

You can create a collection using ThirdWeb, where you can simulate and upload pictures of your original nft to assign them an address, benefactor, comissions of the marketplace, test transactions between your own wallets or mint a new one if you need, how I do in my 'OpenSea clone' with 'Bored Ape Yatch' collection clon below.

enter image description here

To test the smart contract flow, I use Goerli ETH that is provider and powered by Alchemy how @Casareafer mentioned, which have a faucet of 0.2 Goerli ETH everyday, as a proposal to use an stable Ethereum Testnet to interact and to practice.

enter image description here

Then you can follow the transaction on Etherscan or your wallet (recommendation create a new account from your main account in metamask to test).

enter image description here

Assign each contract and project pre stablished in ThirdWeb directly in the code just adding the address of the collection created:

import { useContract } from '@thirdweb-dev/react'

export default function Component() {
  const { contract, isLoading, error } = useContract("0xa478F76110110fB4cd5CCAA33d0Ac62C3364A021", "nft-collection-name")

  // Now you can use the nftCollection contract in the rest of the component
}

Burn a single NFT

const result = await contract.burnToken(tokenId);

Mint many unique NFTs at once to a specified wallet.

// Address of the wallet you want to mint the NFT to
const walletAddress = "0x8197b2a89d80010019718e799e1224d4f2b429Ef";

// Custom metadata of the NFTs you want to mint.
const metadatas = [{
  name: "Cool NFT #1",
  description: "This is a cool NFT",
  image: fs.readFileSync("path/to/image.png"), // This can be an image url or file
}, {
  name: "Cool NFT #2",
  description: "This is a cool NFT",
  image: fs.readFileSync("path/to/other/image.png"),
}];

const tx = await contract.mintBatchTo(walletAddress, metadatas);
const receipt = tx[0].receipt; // same transaction receipt for all minted NFTs
const firstTokenId = tx[0].id; // token id of the first minted NFT
const firstNFT = await tx[0].data(); // (optional) fetch details of the first minted NFT

You can find all the rest of the explanation and code in ThirdWeb depending of the project are you simulating, registering with your email to be able to connect your metamask testnet address.

1
  • I really liked your answer, this platform is very useful. Thanks my friend for the help. Dec 5, 2022 at 0:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.