How to build Mint Page for NFT collection

Hey guys, I am trying to build a minting page with plain JS for our NFT collection.

First of all: I am pretty new to web3 development and I found moralis as a good way to start. Reading through the documentation I managed to set up the login & logout function but I keep getting errors for the most important thing.

I want to perform the minting function on my smartContract and then perform the transaction of a specific amount of ETH from the user to the contract owner.

How can I do that?

You can read more about communicating to the smart contract here

1 Like

I implemented this:

const ABI = [{ ... }]

// connect to Moralis server
const serverUrl = "";
const appId = "hQp...ciq";
const NODE_URL = ''; //Rinkeby
const contractID = "0x40...9Dd";

const web3 = new Web3("");
const contract = new web3.eth.Contract(ABI, contractID);
const senderAddress = "0xC...e38"; //user who mints
const receiverAddress = contractID;
async function moralisWeb3() {
	// Get the EthersJs library
	const ethers = Moralis.web3Library;

	// Get a (ethers.js) web3Provider
	const web3Provider = await Moralis.enableWeb3();

	// Enable web3 and get the initialized web3 instance from Web3.js
	await Moralis.enableWeb3();
	const web3Js = new Web3(Moralis.provider);

	// connector
	const web3 = await Moralis.enableWeb3();

	const options = {
		contractAddress: contractID,
		functionName: "mint",
		abi: ABI,
		params: {
			_mintAmount: "2"
		// msgValue: Moralis.Units.ETH("0.1")

	const transaction = await Moralis.executeFunction(options);
	const receipt = await transaction.wait();

But for me there are only errors…

  1. MetaMask - RPC Error: execution reverted
  2. Uncaught (in promise) Error: cannot estimate gas; transaction may fail or may require manual gas limit (error={“code”:-32000,“message”:“execution reverted”}, method=“estimateGas”, transaction={“from”:“0xC…e38”,“to”:“0x4…9Dd”,“data”:“0xa…002”,“accessList”:null}, code=UNPREDICTABLE_GAS_LIMIT, version=providers/5.5.2)