Filebase
HomepageFilebase DashboardDiscordBlog
  • 👋Welcome to Filebase!
  • Getting Started
    • FAQ
    • Service Limits
    • Getting Started Guides
      • Pin Your First File To IPFS
      • Developer Quick Start Guide
  • IPFS Concepts
    • What is IPFS?
    • What is an IPFS CID?
    • What is IPFS Pinning?
    • What is an IPFS Gateway?
  • IPFS Pinning
    • Pinning Files
    • Listing Files
    • Deleting Files
    • Event Notifications
  • IPNS Names
    • Managing Names
  • Dedicated IPFS Gateways
    • Managing Dedicated Gateways
    • Access Controls
    • Image Optimizations
    • Adding a Custom Domain
  • API Documentation
    • S3-Compatible API
      • Cross Origin Resource Sharing (CORS)
        • Create and Apply a CORS Rule to a Filebase Bucket
        • Deep Dive: Cross Origin Resource Sharing (CORS)
      • Pre-Signed URLs
    • Filebase Platform APIs
    • IPFS Pinning Service API
  • Code Development + SDKs
    • Code Development
      • Apache Libcloud - Python
      • Apostrophe CMS
      • AWS Lambda - NodeJS
      • AWS Lambda - Python
      • AWS SDK - Go (Golang)
      • AWS SDK - Java
      • AWS SDK - JavaScript
      • AWS SDK - .NET
      • AWS SDK - PHP
      • AWS SDK - Python
      • AWS SDK - Ruby
      • Code Examples
        • How To Utilize Filebase with NodeJS
      • DataCamp
      • Dart / Flutter
      • Django
      • Docker
        • Docker Volume Backup
      • Elixir Phoenix
      • Filebase NPM Package
      • Fog.io - Ruby
      • Google App Scripts
      • Integrated Haskell Platform
      • Laravel
      • Nuxt
      • Paperspace
      • Postman
      • Reading a JSON File
      • UNA
      • Unity
      • Uppy AWS S3 Plugin
      • Vue
      • Watcher for NodeJS
      • Webpack S3 Plugin
      • Xamarin
    • SDK Examples: Pinning Files and Folders to IPFS
      • AWS SDK for .NET
      • AWS SDK for Go
      • AWS SDK for JavaScript
      • AWS SDK for PHP
      • AWS SDK for Python
      • AWS SDK for Ruby
  • Archive
    • Content Archive
      • IPFS Getting Started Guide
      • Web Console Getting Started Guide
      • IPFS Tools
        • IPFS CLI
        • IPFS Desktop
        • IPFS Pin Sync
        • IPFS Pinning Service API
        • IPFS3up
      • Third Party Tools and Clients
        • Backup Client Configurations
          • AhsayCBS
          • BackupAssist Classic
          • BackupAssist ER
          • BackupNinja
          • BackupSheep
          • Bacula Enterprise Edition
          • CloudBacko
          • CloudBerry Backup
          • Cloudron
          • cPanel
          • Comet
          • Commvault
          • Duplicacy
          • Ghost IPFS Storage Adapter
          • IPFS Pinning GitHub Action
          • JetBackup
          • Kopia
          • MoveBot
          • MSP360 Online Backup
          • oDrive
          • Photos+ Cloud Library
          • qBackup
          • S3 Uploader for GitHub Actions
          • SimpleBackups
          • SnapShooter
          • Strapi Provider Plugin
          • Veeam
          • Wordpress
            • Media Cloud
            • XCloner
          • Zerto
        • CLI Tools
          • Ansible
          • Apache Pulsar
          • AWS CLI
            • How To Delete Data with AWS CLI
            • What is Multipart Upload?
          • Bash
            • Backup Files to IPFS with Bash
            • Laravel Backup with Bash
            • MongoDB Backup with Bash
            • PostgreSQL Backup with Bash
            • Wordpress Backup with Bash
          • cURL
          • Elasticsearch
          • IPFS-CAR
          • IPFScrape
          • IPGet
          • Jenkins
          • JFrog Artifactory
          • Kubernetes
            • Backup and Restore InFluxDB to Filebase with TrilioVault
            • CSI-S3
            • Kasten K10
            • Kerberos Vault
            • Longhorn.io
            • Stash for Kubernetes
            • Velero
          • Litestream
          • Minty
          • MongoDB
          • MoSMB
          • MySQL
          • Next.js .CAR File Upload
          • NFT Image Generator
          • NGINX S3 Gateway
          • Pinning Docker Images to IPFS
          • Pinning Encrypted Files to IPFS
          • PowerShell
            • Calculate the Size of Filebase Buckets using PowerShell
          • Rclone
            • Backing Up DigitalOcean Spaces to Filebase using Rclone
          • Restic
          • S3cmd
          • S3Express
          • S3FS-FUSE
          • S3QL
          • S3Surfer
          • S4cmd
          • SeaweedFS
          • Tableland
        • Content Delivery Networks
          • Bunny CDN
          • CloudFront CDN
          • Fastly CDN
        • File Management Client Configurations
          • Airbyte
          • Arq
          • Astiga
          • AWS Rekognition
          • AWS S3 Manager - iOS App
          • BucketAnywhere for S3 - Android App
          • CentreStack
          • CloudFlyer
          • Cloudfser
          • Couchdrop
          • CrossFTP
          • CyberDuck
            • How To Delete Data with CyberDuck
          • Dropshare
          • Duplicati
          • FileBrowserGO
          • Flexify.IO
          • ForkLift
          • Goofys
          • Joplin
          • LucidLink
          • MASV
          • Matrix Synapse
          • MinIO Gateway for S3
          • Mountain Duck
          • NetDrive
          • Nexfs
          • NextCloud
          • Nodeum
          • ownCloud
          • Plesk
          • Pure Storage FlashBlade
          • RaiDrive
          • S3 Browser
          • ShareX
          • SmartFTP
          • StableBit Cloud Drive
          • Storage Made Easy Enterprise File Fabric
          • WinSCP
        • NAS Device Configurations
          • Buffalo TeraStation
          • Datadobi DobiProtect
          • Netapp ONTAP Select
          • OpenDrives Atlas
          • Synology Hyper Backup
          • TrueNAS CORE
      • Knowledge Base
        • Deep Dives
          • Deep Dive: Blockchains
          • Deep Dive: Decentralized Compute
          • Deep Dive: Decentralized Digital Identity
          • Deep Dive: Decentralized Storage
          • Deep Dive: Erasure Coding
          • Deep Dive: Geo-Redundancy
          • Deep Dive: Metadata
          • Deep Dive: Metaverse
          • Deep Dive: NFTs
          • Deep Dive: Web3
        • Filebase eBooks
        • Filebase One-Pagers
        • Filebase Whitepapers
        • Web3 Tutorials
          • Alchemy
            • Alchemy: Build a dApp That Provides Real-Time Ethereum Transaction Notifications
            • Alchemy: Create a Full-Stack dApp
            • Alchemy: Create a Hello World Smart Contract
            • Alchemy: Create Your Own ERC20 Cryptocurrency
            • Alchemy: Decentralized Youtube
            • Alchemy: How to Create and Mint an NFT using Filebase
            • Alchemy: How to Mint an NFT Using Web3.js
            • Alchemy: Using The Alchemy SDK with NFTs Minted Through thirdweb
          • Agoric
            • Agoric: Create a DeFi dApp Using Agoric That’s Stored on Filebase
          • AirSwap
            • AirSwap: Track NFT Contract Addresses with AirSwap CLI
          • ArcBlock
            • ArcBlock: Running an ArcBlock Blocket Server on IPFS
          • Ankr
            • Ankr: Create a Truffle Project with Ankr and Filebase
            • Ankr: Deploy a Smart Contract on Polygon using Ankr that is backed up to Filebase
          • Avalanche
            • Avalanche: How To Launch a Generative NFT Collection With Avalanche and IPFS
          • Backing Up NFTs
          • Brownie
            • Brownie: Create and Mint an NFT Using Brownie
          • Bueno
            • Bueno: How to Create a Generative NFT Collection with Bueno
          • Cardano
            • Cardano: Submit Cardano Blockchain Transactions with Embedded Metadata Stored on Filebase
          • Ceramic
            • Ceramic: How to Host a Ceramic Node Using Decentralized Storage
          • Create-IPFS-app
          • Cosmos
            • Cosmos: Storing Cosmos Chain Governance Metadata on IPFS
          • DeCommerce
          • Ethereum Name Service
            • ENS: Configure an ENS Domain to use a Filebase IPFS Dedicated Gateway
          • Figment Datahub
            • Figment Datahub and Avalanche: Make an e-Voting dApp Using Figment Datahub, Avalanche, and Filebase
            • Figment Datahub and Celo Network: Create an ERC1155 NFT on the Celo Network using Figment Datahub and Objects Stored on Filebase
          • Flow
            • Flow: How to Create an NFT Marketplace with Filebase + Flow
          • Fauna
            • Fauna: Host an Application on IPFS with IPFS Dedicated Gateways
          • Ganache
            • Ganache: Create a dApp Hosted on IPFS
          • GUN
            • GUN: Create a Decentralized Chat App with GUN and IPFS
          • Hardhat
            • Hardhat: Creating an NFT Contract using Hardhat and Setting NFT Metadata using IPFS on Filebase
          • Harmony
            • Harmony: Deploy an HRC721 NFT on Harmony with IPFS
          • Hosting a Form on IPFS
          • iExec
            • iExec: Using iExec and Tee Worker to Create Apps that Use Datasets Stored on Filebase
          • Infura
            • Infura: Build dApp Frontends with Infura, React, and IPFS
            • Infura: Create an NFT Contract Factory with Metadata stored on IPFS
          • Lens Protocol
            • Lens Protocol: Build a Decentralized Social Media Network Stored on IPFS
          • LIT Protocol
            • LIT Protocol: Create a MintLIT NFT with LIT Protocol and IPFS
          • LivePeer
            • LivePeer: Mint a Video NFT with LivePeer
          • Macrometa
            • Macrometa: Track IPFS Files with Macrometa
          • Mina Protocol
            • Mina Protocol: Create a Simple zkApp with Mina Protocol and IPFS
          • NEAR Protocol
            • NEAR Protocol: Storing Off-Chain Data on IPFS using Filebase
          • NFTPort
            • NFTPort: Create an NFT Collection with NFTPort
          • Ocean Protocol
            • Ocean Protocol: Publish Data NFTs Stored on IPFS using Ocean Protocol
          • Pin Tezos Tokens Tool
          • Polkadot
            • Polkadot: Deploy a Polkadot dApp on Decentralized Storage
          • Polygon
            • Polygon: Building an App NFT With Polygon
            • Polygon: Make a Donation App with IPFS and Polygon
          • Python
            • Generating NFT Metadata with Python
          • QuickNode
            • QuickNode: Create a Token dApp using QuickNode
          • Remix
            • Remix: Create a Web App with Remix to Upload to Decentralized Storage
          • Remix IDE
            • Remix IDE: Creating Interactive NFTs with IPFS and Remix IDE
          • Secret Network
            • Secret Network: Create an NFT on Secret Network with Data Stored on IPFS
          • Stargaze
            • Stargaze: Create an NFT Collection Using IPFS and Stargaze
          • Starknet
            • Starknet: Create a HardHat Project Using A Starknet Plugin Hosted On IPFS
          • Studio 721
            • Studio 721: Create an NFT Collection with Studio 721 and IPFS
          • Solana
            • Solana: Minting an NFT Using Sugar, Candy Machine, and Filebase
          • Subsquid
            • Subsquid: Querying NFT Data using Subsquid and a Filebase IPFS Dedicated Gateway
          • Tailwind CSS
            • Tailwind CSS: Build an Image Gallery App with IPFS and Tailwind CSS
          • Tatum
            • Tatum: How To Mint NFTs on Solana with Tatum
          • Tezos
            • Tezos: Create an NFT on the Tezos Network using IPFS on Filebase
          • thirdweb
            • thirdweb: Build an NFT Loot Box with thirdweb and IPFS
            • thirdweb: Build an NFT Minting Page with thirdweb, IPFS, RainbowKit, and WAGMI
            • thirdweb: Create a Discord Bot That Gives Roles to NFT Holders
            • thirdweb: Create a Gated Website Using NFTs and IPFS
            • thirdweb: Create an NFT Marketplace with thirdweb and IPFS
            • thirdweb: Release an NFT Drop Using thirdweb and IPFS
          • useDApp
            • useDApp: Create a dApp using useDApp and IPFS
          • Unstoppable Domains
            • Unstoppable Domains: Create a Decentralized Website Using Unstoppable Domains and IPFS Folders
            • Unstoppable Domains: Deploy a Decentralized Blog Using Unstoppable Domains, Akash, and IPFS
            • Unstoppable Domains: IPFS Configuration
          • Vultr
            • Vultr: Store Bedrock Minecraft Worlds on Decentralized Storage
            • Vultr: Store Forge Minecraft Worlds on Decentralized Storage
            • Vultr: Store PaperSpigot Minecraft Worlds on Decentralized Storage
            • Vultr: Store Vanilla Minecraft Worlds on Decentralized Storage
          • Waffle
            • Waffle: Deploy a Smart Contract with Waffle That’s Stored on IPFS
          • Walt.id
            • Walt.id: Mint an NFT with Walt.id and Filebase
          • Web3 Toolbox
            • Web3 Toolbox: Building an NFT Drop With Web3 Toolbox
Powered by GitBook
On this page
  • 1. First, we need an image to use as an NFT. We’ll start by uploading an image to Filebase for us to use.
  • 2. Select ‘Buckets’ from the left side bar menu, or navigate to console.filebase.com/buckets.
  • 3. Enter a bucket name and choose the IPFS storage network to create the bucket.
  • 4. Next, select the bucket from your list of buckets, then select ‘Upload’ in the top right corner to upload an image file.
  • 5. Select an image to be uploaded.
  • 6. You can view the object’s IPFS CID in the CID column, or you can click on your uploaded object to display the metadata for the object, which includes the IPFS CID.
  • 7. Now, let’s head over to Alchemy and either sign up for an account or login.
  • 8. From the Alchemy dashboard, we need to create an app.
  • 9. Create a new app. For our example, we called our app NFTs.
  • 10. Next, we need an Ethereum wallet.
  • 11. Once you have a Metamask account, change the network to the ‘Göerli Test Network’ in the top right corner.
  • 12. Next, head over to the Göerli Faucet and send your wallet some fake ETH to use:
  • 13. Next, let’s initialize our project.
  • 14. Now, we’ll use Node.js and npm for our project.
  • 15. Once installed, run the command:
  • 16. Now let’s install Hardhat, a development environment for us to deploy and test our Ethereum app on.
  • 17. Let’s create the Hardhat project now.
  • 18. From this menu prompt, select ‘Create an empty hardhat.config.js’.
  • 19. Next we’ll create two more folders inside our project directory to help keep it organized as we add more content.
  • 20. Now let’s write a piece of code for creating a smart contract.
  • 21. Next, install the OpenZeppelin contracts library into the contracts folder. To do this, run the following command:
  • 22. Now let’s connect Metamask and Alchemy to our NFT project.
  • 23. Then, create a file called .env and add your Alchemy API URL and Metamask private key to this file.
  • 24. Next, install the Ether.js library into your project directory using the following command:
  • 25. We need to update the hardhat.config.js file to reflect the dependencies we’ve installed.
  • 26. Our contract is ready to be compiled. Compile it with the following command:
  • 27. Now we need a deploy script to deploy the contract.
  • 28. It’s time to deploy our smart contract.
  • 29. Now that we have deployed a contract, let’s move onto minting the actual NFT.
  • 30. Next, create a new file in the scripts directory called mint-nft.js that has the following content:
  • 31. We need to configure the metadata for our NFT.
  • 32. After you’ve saved the metadata file, upload it to your Filebase IPFS bucket following the same process we used to upload the NFT image file at the beginning of this guide.
  • 33. Head back to Etherscan where we confirmed that our contract was successfully created and copy down the contract’s address.
  • 34. Add the following lines to your mint-nft.js file, replacing the contract address with the address you just copied from Etherscan.
  • 35. Open your .env file and add your public Metamask wallet account address to it with the following line:
  • 36. Add the following lines to your mint-nft.js script:
  • 37. Run the mint-nft script to deploy and mint your NFT:

Was this helpful?

  1. Archive
  2. Content Archive
  3. Knowledge Base
  4. Web3 Tutorials
  5. Alchemy

Alchemy: How to Create and Mint an NFT using Filebase

Learn how to create and mint an NFT using Filebase and Alchemy.

PreviousAlchemy: Decentralized YoutubeNextAlchemy: How to Mint an NFT Using Web3.js

Last updated 9 months ago

Was this helpful?

NFTs, or ‘non-fungible tokens’ are crypto assets with varying values and attributes. NFTs can be anything from digital art, to music or pieces of writing. NFTs have associated metadata with them which includes a unique token that acts as a certificate of authenticity for the NFT. This token can be used for authentication similar to access and secret key pairs.

NFTs can be made by anyone, and ‘minted,’ or created and sold on blockchain networks, in exchange for cryptocurrency. The value of NFTs depends on a wide variety of factors, including crypto price, collection marketing, and investors, and the NFT community.

In this guide, we’ll take an image file stored on Filebase, a decentralized storage provider, and use Alchemy, a blockchain developer platform, to mint NFTs on the Ethereum blockchain.

Prerequisites:

1. First, we need an image to use as an NFT. We’ll start by uploading an image to Filebase for us to use.

To do this, navigate to . If you don’t have an account already, , then log in.

2. Select ‘Buckets’ from the left side bar menu, or navigate to .

Select ‘Create Bucket’ in the top right corner to create a new bucket for your NFTs.

3. Enter a bucket name and choose the IPFS storage network to create the bucket.

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.

4. Next, select the bucket from your list of buckets, then select ‘Upload’ in the top right corner to upload an image file.

5. Select an image to be uploaded.

Once uploaded, it will be listed in the bucket.

6. You can view the object’s IPFS CID in the CID column, or you can click on your uploaded object to display the metadata for the object, which includes the IPFS CID.

Choose the method you prefer, and take note of the IPFS CID. We will reference this later.

8. From the Alchemy dashboard, we need to create an app.

Select the ‘Create App’ button to get started.

9. Create a new app. For our example, we called our app NFTs.

Set the environment to ‘Staging’, the chain to ‘Ethereum’, and the network to ‘Göerli’.

10. Next, we need an Ethereum wallet.

11. Once you have a Metamask account, change the network to the ‘Göerli Test Network’ in the top right corner.

This is so we aren’t dealing with actual currency.

13. Next, let’s initialize our project.

mkdir my-nft

cd my-nft

These commands make a new folder, also referred to as a directory, then place us inside that directory.

14. Now, we’ll use Node.js and npm for our project.

15. Once installed, run the command:

npm init

This will initialize a new npm project in your my-nft directory. This command will output a list of prompts. Here’s how to answer them:

We can install Hardhat with the following command:

npm install --save-dev hardhat

17. Let’s create the Hardhat project now.

Run the following command inside your my-nft directory:

npx hardhat

It should return the following welcome message and menu prompt:

18. From this menu prompt, select ‘Create an empty hardhat.config.js’.

19. Next we’ll create two more folders inside our project directory to help keep it organized as we add more content.

Run the following commands to add a contracts folder and a scripts folder.

mkdir contracts

mkdir scripts

Contracts will be for storing our NFT smart contracts, while scripts will be for storing the code used to mint and deploy our NFT.

20. Now let’s write a piece of code for creating a smart contract.

Open your favorite IDE software and create a new file called MyNFT.sol. Copy and paste the following code into this new file:

//Contract based on https://docs.openzeppelin.com/contracts/3.x/erc721
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.3;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract MyNFT is ERC721, Ownable {
	using Counters for Counters.Counter;
	Counters.Counter private _tokenIds;
	constructor() public ERC721("MyNFT", "NFT") {}
	function mintNFT(address recipient, string memory tokenURI)
		public onlyOwner
		returns (uint256)
	{
		_tokenIds.increment();
		uint256 newItemId = _tokenIds.current();
		_mint(recipient, newItemId);
		_setTokenURI(newItemId, tokenURI);

		return newItemId;
	}
}

21. Next, install the OpenZeppelin contracts library into the contracts folder. To do this, run the following command:

npm install @openzeppelin/contracts@3.1.0-solc-0.7

22. Now let’s connect Metamask and Alchemy to our NFT project.

Every transaction using your Metamask wallet requires a signature using your Metamask private key. To use our Alchemy app, we need it’s API key. Since we will frequently need both of these keys, we’ll store them in an environment file. To do this, first install the dotenv package into the project directory with the following command:

npm install dotenv --save

23. Then, create a file called .env and add your Alchemy API URL and Metamask private key to this file.

This file must be called .env, otherwise it will not work as expected.

Your .env file should look similar to this:

PRIVATE_KEY = "your-metamask-private-key"
API_URL = "https://eth-goerli.alchemyapi.io/v2/your-api-key"

24. Next, install the Ether.js library into your project directory using the following command:

npm install --save-dev @nomiclabs/hardhat-ethers "ethers@^5.0.0"

25. We need to update the hardhat.config.js file to reflect the dependencies we’ve installed.

Update the hardhat.config.js file to reflect the following:

/**
@type import('hardhat/config').HardhatUserConfig
/

require('dotenv').config();
require("@nomiclabs/hardhat-ethers");

const { API_URL, PRIVATE_KEY } = process.env;
module.exports = {
		solidity: "0.7.3",
		defaultNetwork: "ropsten",
		networks: {
			hardhat: {},
			ropsten: {
				url: API_URL,
				accounts: [`0x${PRIVATE_KEY}`]
				}
		},
}

26. Our contract is ready to be compiled. Compile it with the following command:

npx hardhat compile

27. Now we need a deploy script to deploy the contract.

Navigate to the scripts directory we made previously, then create a new file called deploy.js with the following contents:

async function main() {

		// Grab the contract factory
		const MyNFT = await ethers.getContractFactory("MyNFT");

		// Start deployment, returning a promise that resolves to a contract object
		const myNFT = await MyNFT.deploy(); // Instance of the contract
		console.log("Contract deployed to address:", myNFT.address);
}
main()
		.then(() => process.exit(0))
		.catch(error => {
				console.error(error);
				process.exit(1);
});

28. It’s time to deploy our smart contract.

Run the following command to use the deploy.js script:

npx hardhat run scripts/deploy.js --network ropsten

This script will return something resembling the following output:

Contract deployed to address: 0x9C33cD8e20c595Aad0C04ae58414916e5529ff6a

29. Now that we have deployed a contract, let’s move onto minting the actual NFT.

npm install @alch/alchemy-web3

30. Next, create a new file in the scripts directory called mint-nft.js that has the following content:

require('dotenv').config();
const API_URL = process.env.API_URL;
const { createAlchemyWeb3 } = require("@alch/alchemy-web3");
const web3 = createAlchemyWeb3(API_URL);
const contract = require("../artifacts/contracts/MyNFT.sol/MyNFT.json");

31. We need to configure the metadata for our NFT.

The NFT metadata allows for it to have properties such as NFT name, image, description, and other factors like collection and rarity.

In your project root directory, make a new file named nft-metadata.json with the following code:

{
"attributes" : [ {
		"trait_type" : "Type",
		"value" : "Robot"
}, {
		"trait_type" : "Color",
		"value" : "Silver"
} ],
"description" : "An NFT of the Filebase Robot",
"image" : "https://ipfs.filebase.io/ipfs/[IPFS-CID]",
"name" : "Filebase Robot"
}

Replace the ‘image’ CID with your Filebase object IPFS CID from the beginning of this guide, and configure the other attributes such as trait_type, name, and description to reflect your desired configuration.

32. After you’ve saved the metadata file, upload it to your Filebase IPFS bucket following the same process we used to upload the NFT image file at the beginning of this guide.

Copy the object’s IPFS CID and save it for reference later.

If you closed Etherscan, reopen it and search for your wallet address, then click on the transaction for your contract creation.

34. Add the following lines to your mint-nft.js file, replacing the contract address with the address you just copied from Etherscan.

const contractAddress = "0x3a1952952b04aba42b9b7943e3b617e456dc9db4";
const nftContract = new web3.eth.Contract(contract.abi, contractAddress);

35. Open your .env file and add your public Metamask wallet account address to it with the following line:

PUBLIC_KEY = "your-public-account-address"

36. Add the following lines to your mint-nft.js script:

const PRIVATE_KEY = process.env.PRIVATE_KEY;
async function mintNFT(tokenURI) {
const nonce = await web3.eth.getTransactionCount(PUBLIC_KEY, 'latest'); //get latest nonce

//the transaction
const tx = {
'from': PUBLIC_KEY,
'to': contractAddress,
'nonce': nonce,
'gas': 500000,
'maxPriorityFeePerGas': 1999999987,
'data': nftContract.methods.mintNFT(PUBLIC_KEY, tokenURI).encodeABI()
};

const signedTx = await web3.eth.accounts.signTransaction(tx, PRIVATE_KEY);
const transactionReceipt = await web3.eth.sendSignedTransaction(signedTx.rawTransaction);
console.log(`Transaction receipt: ${JSON.stringify(transactionReceipt)}`);
}

mintNFT("https://ipfs.filebase.io/ipfs/[IPFS-CID]");

These lines add a transaction function, sign the transaction with your private key, and log the transaction receipt. The last line uses the metadata file uploaded to Filebase when minting the NFT. Replace the IPFS-CID with the CID for this metadata file.

Overall, your mint-nft.js script should look like the following:

require('dotenv').config();
const API_URL = process.env.API_URL;
const PUBLIC_KEY = process.env.PUBLIC_KEY;
const PRIVATE_KEY = process.env.PRIVATE_KEY;

const { createAlchemyWeb3 } = require("@alch/alchemy-web3");
const web3 = createAlchemyWeb3(API_URL);
const contract = require("../artifacts/contracts/MyNFT.sol/MyNFT.json");
const contractAddress = "0x3a1952952b04aba42b9b7943e3b617e456dc9db4";
const nftContract = new web3.eth.Contract(contract.abi, contractAddress);

async function mintNFT(tokenURI) {
const nonce = await web3.eth.getTransactionCount(PUBLIC_KEY, 'latest'); //get latest nonce

//the transaction
const tx = {
'from': PUBLIC_KEY,
'to': contractAddress,
'nonce': nonce,
'gas': 500000,
'maxPriorityFeePerGas': 1999999987,
'data': nftContract.methods.mintNFT(PUBLIC_KEY, tokenURI).encodeABI()
};

const signedTx = await web3.eth.accounts.signTransaction(tx, PRIVATE_KEY);
const transactionReceipt = await web3.eth.sendSignedTransaction(signedTx.rawTransaction);
console.log(`Transaction receipt: ${JSON.stringify(transactionReceipt)}`);

}

mintNFT("https://ipfs.filebase.io/ipfs/[IPFS-CID]");

37. Run the mint-nft script to deploy and mint your NFT:

node scripts/mint-nft.js

Congratulations, you’ve successfully minted your first NFT! You can use this process to mint as many NFTs as you want! Just remember to use new metadata files for each transaction, otherwise you will create several duplicate NFTs.

7. Now, let’s head over to Alchemy and either for an account or .

For this, we’ll need a Metamask account. You can sign up for one for free . For additional information on how Ethereum transactions work, check out the Ethereum foundation’s information page .

12. Next, head over to the and send your wallet some fake ETH to use:

For this, we need to open the on our computer and run the following commands:

If you don’t have these installed already, download and install and .

16. Now let’s install , a development environment for us to deploy and test our Ethereum app on.

This code is based on the library’s ERC721 implementation.

For instructions on getting your Metamask private key, see .

For instructions on how to get your Alchemy API URL, see .

To do this, first we need to install the library. Install it in your project directory with the following command:

33. Head back to where we confirmed that our contract was successfully created and copy down the contract’s address.

You can confirm your transaction was successful by looking at your and viewing the transaction status. If successful, it should have the status ‘Mined’.

sign up
login
here
here
Göerli Faucet
command line
Node.js
npm
Hardhat
OpenZeppelin
here
here
Alchemy Web3
Etherscan
Alchemy Mempool
MetaMask
Install Node.js and npm
Sign up
console.filebase.com
sign up
console.filebase.com/buckets