我试图使用以下3部分教程启动nft:https://ethereum.org/en/developers/tutorials/how-to-write-and-deploy-an-nft/
我一直跟踪到课程的第三部分,但是当我去那里的时候,以太扫描页面并没有显示TokenID或contractID。
以下是我的薄荷-nft代码:
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")请帮帮忙
发布于 2022-12-18 08:09:21
我刚刚检查了您在Goerli contractAddress = "0x81c587EB0fE773404c42c1d2666b5f557C470eED"上使用的合同地址,它看起来不像合同,而是EOA。
检查以上钱包的tx。您可能需要的合同地址是:0x3A632C370dFE7d32F74Da5A84b7e72571bD6Da7C,但我还没有测试它。
希望它对社会有帮助和欢迎!
https://ethereum.stackexchange.com/questions/141403
复制相似问题