0

I am trying to launch an nft using this 3 part tutorial: https://ethereum.org/en/developers/tutorials/how-to-write-and-deploy-an-nft/

I followed everything up to the 3rd part of the course, but the etherscan page isn't showing a TokenID nor a contractID when I go there: https://goerli.etherscan.io/tx/0x1a04a57c82e8624a049be299e27ab4585c4f4d22ae99dbdefe7e649b73473f14

Here is my mint-nft code:


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 = "0x81c587EB0fE773404c42c1d2666b5f557C470eED"
const nftContract = new web3.eth.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,
    data: nftContract.methods.mintNFT(PUBLIC_KEY, tokenURI).encodeABI(),
  }

  const signPromise = web3.eth.accounts.signTransaction(tx, PRIVATE_KEY)
  signPromise
    .then((signedTx) => {
      web3.eth.sendSignedTransaction(
        signedTx.rawTransaction,
        function (err, hash) {
          if (!err) {
            console.log(
              "The hash of your transaction is: ",
              hash,
              "\nCheck Alchemy's Mempool to view the status of your transaction!"
            )
          } else {
            console.log(
              "Something went wrong when submitting your transaction:",
              err
            )
          }
        }
      )
    })
    .catch((err) => {
      console.log("Promise failed:", err)
    })
}

mintNFT("ipfs://QmQgvyZRVBQeDHBP6zLPvvjDy6f9QBSCkrrzSF7H8K7wgx")

Please help

1 Answer 1

0

I've just checked the contract address you are using on Goerli const contractAddress = "0x81c587EB0fE773404c42c1d2666b5f557C470eED" and it doesn't look like a contract, is a EOA.

Checking the tx of the above wallet. probably the contract address you need is this one: 0x3A632C370dFE7d32F74Da5A84b7e72571bD6Da7C, but I haven't test it.

Hope it helps and welcome to the community!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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