首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >未在Goerli网络上创建NFT

未在Goerli网络上创建NFT
EN

Ethereum用户
提问于 2022-12-17 22:54:00
回答 1查看 58关注 0票数 0

我试图使用以下3部分教程启动nft:https://ethereum.org/en/developers/tutorials/how-to-write-and-deploy-an-nft/

我一直跟踪到课程的第三部分,但是当我去那里的时候,以太扫描页面并没有显示TokenID或contractID。

以下是我的薄荷-nft代码:

代码语言:javascript
复制
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")

请帮帮忙

EN

回答 1

Ethereum用户

发布于 2022-12-18 08:09:21

我刚刚检查了您在Goerli contractAddress = "0x81c587EB0fE773404c42c1d2666b5f557C470eED"上使用的合同地址,它看起来不像合同,而是EOA。

检查以上钱包的tx。您可能需要的合同地址是:0x3A632C370dFE7d32F74Da5A84b7e72571bD6Da7C,但我还没有测试它。

希望它对社会有帮助和欢迎!

票数 0
EN
页面原文内容由Ethereum提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://ethereum.stackexchange.com/questions/141403

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档