Skip to content

francescomiliani/nft-labcamp

Repository files navigation

OpenSea NFTs Bulk Minter and Lister

This project allows to bulk upload and list NFTs on the OpenSea platform.

The idea stems from the need to upload, and subsequently list, massively, i.e. > 1K, NFTs on the NFT OpenSea marketplace. A task which if done by hand, takes an enormous amount of time, as well as being tedious and error-prone.

This project creates a ERC1155 smart contract and then deploys it to Görli/Goerli testnet/ Mumbai testnet/ Polygon mainnet or Ethereum mainnet.

NFT's can then be minted in bulk by sending transaction to the deployed smart contract.

After that, the listing process can be made via the usage of the OpenSea.js library (here the link).

Foreword:

In order to simply run the package, there is a sample_images folder containing pics of lovely kitties 😍. You can copy some pics from it and paste into images folder. Remember that your future NTFs collection should be loaded into this latter folder.

Dependencies:

  • NodeJS v16

    This versions can be installed via NVM for a greater flexibility, or by using following commands:

curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt install nodejs
# Test your installation
node -v
npm -v
  • cURL

    Needed to verify deployment and install yarn. Follow next commands:

sudo apt-get update
sudo apt-get install curl -y
  • Yarn v1.22.4

    Follow next commands:

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update
sudo apt-get install yarn=1.22.4-1 -y

Requirements

MetaMask

If you don't have a MetaMask account, download Metamask browser extension and create it a new one. Please, take note of your secret phrase seed because it will have to set to MNEMONIC enviroment variable inside .env file.

Infura

If you don't have an Infura.io account, go to https://infura.io/ and create it a new one. After that, you have to:

  1. create a new project and take note of your Project ID because it will have to set to INFURA_PROJECT_ID enviroment variable inside .env file.
  2. create an IPFS project and take note of your Project ID and API KEY because it will have to set to, respectively, IPFS_INFURA_PROJECT_ID and IPFS_INFURA_PROJECT_SECRET enviroment variables inside .env file.

Non-zero wallets balance

In order to launch the script executing the contract upload and listing, due to gas fees consumption reasons, you should ask for faucet tokens (ETH/MATIC) belonging the chain you wish to use. E.g. if you want deploy your collection on Polygon Testnet (i.e. Mumbai), your Mumbai wallet on Metamask has to contain some MATICs.

You can use the following links:

The minimum amount of required tokens is: 0.1

Enviroment setting

  1. Clone the project repo with command git clone https://github.com/francescomiliani/nft-labcamp and cd into nft-labcamp folder.

  2. Install node_modules packages and project dependencies for batch minting part by executing on your terminal under the root of the project:

npm install
  1. Install node_modules packages and project dependencies for listing part by executing on your terminal under the lister of the project:
cd lister && yarn
  1. To use from-terminal-deploying and perform the listing, rename .env.sample file in .env and update following environment variables:
  • MNEMONIC: with your MetaMask seed phrase;
  • INFURA_PROJECT_ID: with the Project ID created on Infura.io;
  • IPFS_INFURA_PROJECT_ID: with the IPFS Project ID created on Infura.io;
  • IPFS_INFURA_PROJECT_SECRET: with the IPFS Api Key Secret created on Infura.io;
  • OWNER_ADDRES: account address within Metamask you have a non-zero balance;
  • OPENSEA_API_KEY: requested via OpenSea form for production activities e.g. Ethereum mainnet

Usage

This project can be used to deploy smart contract in two ways:

  • Using Remix & MetaMask
  • From terminal by updating .env files with credentials.
    • via Truffle framework to deploy the smart contract
  1. Create a folder named images and put images you want to convert into NFTs inside this latter.

  2. Run node utils/rename-images-to-numbered-sequence.js to convert filenames in images directory to hexadecimal format and link them to metadata.

  3. Upload images folder to Pinata and grag the CID of the folder. Then, update the images_ipfs_location.txt replacing the template string with the CID received from Pinata.

  4. Run node scripts/create_metadata_from_template.js to create a metadata file for each image under metadata directory.

  5. Upload metadata folder to Pinata and grab the CID to update the smart contract ArtCollectible.sol file later.

  6. Either deploy contract using Remix or deploy via terminal:

  • A) Deploy via Remix
    • Update the metadata CID in ArtCollectible.sol inside constructor by replacing METADATA_IPFS_CID_TO_REPLACE string;
    • Under the section Solidity compiler, click on Compile ArtCollectible.sol. The Contract section should appear if the compilation was successful;
    • Under the section Deploy and run transactions:
      • Select Injected Provider - MetaMask under Environment;
      • Select the Account you asked for faucets previously;
      • Click on Deploy;
      • Confirm the transaction via MetaMask;
      • Once completed, you should see the transaction receipt on Remix log and the MetaMask transaction confirmation as notification on your browser;
  • B) Deploy via terminal
    • Update the metadata CID in ArtCollectible.sol inside constructor by replacing METADATA_IPFS_CID_TO_REPLACE string;
    • Update your account MNEMONIC in .env file;
    • Run truffle migrate --network {mainnet|goerli|polygon|mumbai} e.g. truffle migrate --network goerli to migrate your collection on Goerli testnet;
    • If migration was successful, you should see the contract address where was deployed;
  1. Estimate batch mint gas fees:

    • A) Via Remix, updating smart contract address in remix_scripts/estimate_gas_fees.js file and right-click and then Run.
    • B) Via terminal, using the command node scripts/estimate_gas_fees.js <network> <smart_contract_address>, where you have to substitute with:
      • mainnet: Ethereum mainnet
      • goerli: Goerli Ethereum testnet
      • polygon: Polygon mainnet
      • mumbai: Polygon testnet
      • rinkeby: Rinkeby Ethereum testnet [DEPRECATED since October 5th 2022]
  2. Check the file tokenIDs.txt containing a comma-separated list of ID (e.g. 1,2,3,4,5) and run the scripts/bulk_mint_nfts.js script to mint your NFTs' collection, by using the command node scripts/bulk_mint_nfts.js.

  3. Verify the deploy and mint both via OpenSea API and OpenSea website:

  • Via API, you can run the following command node scripts/deploy_verify.js <network> (see above example for network values);
  • Via Browser, please read "OpenSea collection import" section
  1. Modify the collection_descriptor.json file with your collection name, a description, the listing price for each NFT and the payment token (please, check OpenSea documentation about the latter parameter).

  2. List your collection by running listing.js script from lister folder, specifying the network you deployed your collection cd lister && node listing.js <network>

OpenSea collection import [Update June 2022]

During second part of 2022, OpenSea removed the "Import an existing smart contract" functionality from "My Collections" section. You can see and verify your just deployed smart contract/collection by using both where after asset you have to replace <smart contract address> and <token id> within a similar template as: https://api.opensea.io/asset/<smart contract address>/<token id>/validate/ You can verify the correct deploy either via web browser on OpenSea web site or via API:

You can click on your collection name link on the right to see your entire NFT collection with all images.

OpenSea NFTs listing - In-Depth Analysis

You can change listing/sell price multiple times, as many as you want: follow the step #11 by updating the collection_descriptor.json file and re-running the command illustrated.

If your listing was successful, on OpenSea web site, you can prowdly admire your listing, and your overall work, by observing your NFTs listed at the price you set and with a expiration date (become mandatory with last OpenSea documentation update

image

Furthermore, you can use additional payment tokens, not only ETH, for instance:

  • Testnet: ETH, DAI, UDSC, TER, WETH
  • Mainnet: ETH, APE, VOLT, ASH, NCT, GALA, UNI, REVV, LINK, MANA, CUBE, BAT, USDC, WETH, DAI, SAND

In order to find an updated list, at the moment you are reading, you can the the script getPaymentTokens.js via:

cd lister
node getPaymentTokens.js {mainnet|goerli}

immagine

💯 THAT'S ALL FOLKS! 💯 🥳 🍾

Finally, THAT'S ALL FOLKS! 🥳

🚨 PLEASE KEEP MIND ! ⌚

If you receive a "404 Page not found" or "404 This Page is lost" by OpenSea, don't worry 😉 If you deployed your contract on Ethereum, Goerli or Mumbai could be need at least 10 minutes. So, let's wait and retry later! And, you can run the script deploy_verify.js with network name as parameter, after have been created a file called smart_contract_address.txt containing the smart contract address, received from either Remix or Truffle, from where the script read.

node scripts/deploy_verify.js {mainnet|goerli|polygon|mumbai}

🚨 Disclaimer 🚨

Unfortunately, at the moment I'm publishing this code, Polygon network is not supported yet by the library OpenSea.js. The only two supported networks are: Mainnet (Ethereum) and Goerli Rinkeby (an Ethereum testnet). Therefore, you can still use this program to bulk upload your NFTs on Polygon, but, you will make the listing activity on OpenSea just on Ethereum and Goerli Rinkeby.

On Mumbai and Polygon, you have to list every NFT manually via OpenSea UI.

Update June 2022

Due to ETH 2.0 release, Rinkeby and other testnet e.g. Ropsten have been deprecated, and they will be shutdown on 2023. You can read the announcement here. This means that OpenSea testnet API are referring to Goerli and not to Rinkeby anymore.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published