问题创建NFT“ ERC721” (名称,符号)

发布于 2025-01-24 12:24:19 字数 1580 浏览 0 评论 0原文

我正在尝试创建一个NFT创建站点(ERC721),任何用户都可以上传他想要的NFT,只需填写“名称”,“符号”和“ URL”的详细信息。 我有一个问题,无法更改“名称”和“符号”。 的库

// SPDX-License-Identifier: MIT

pragma experimental ABIEncoderV2;
pragma solidity >=0.6.0 <0.8.0;
import "../ERC721/ERC721.sol";

contract newNFT is ERC721 {
 uint internal counterNFT;
    constructor () public{
     counterNFT = 1;
  }
 
  function mint(string memory uri,string memory name,string memory symbol) public {
       name_symbol(name,symbol);
       _safeMint(msg.sender, counterNFT);
        _setTokenURI(counterNFT, uri);
        counterNFT++;
  }
}

第一个创建后,每个上传NFT的用户都会给出第一个用户的“名称”和“符号”。我使用“ openzeppelin” ** openzeppelin **

    constructor () public {
        // register the supported interfaces to conform to ERC721 via ERC165
        _registerInterface(_INTERFACE_ID_ERC721);
        _registerInterface(_INTERFACE_ID_ERC721_METADATA);
        _registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE);
    }

     function name_symbol(string memory nameNFT,string memory symbolNFT) internal virtual{
         _name = nameNFT;
        _symbol = symbolNFT;
    }

**我想创建一个与任何用户的智能合约可以轻松上传NFT 通过“名称”“符号”和他选择的URL。问题在于,在第一个用户用他的名字和图标上传NFT之后,“名称”和“符号”不会改变我。任何追随他并填写详细信息的用户都不会在交易中“多边形”中更改“名称”和“符号”。

例如,上传NFT的网站上的第一个用户 名称=龙珠 符号=龙 url = wwww.exmaple.co.il

在第一个示例中,所有用户选择的“名称”和“符号”中可以看到的一切都可以很好地工作。

网站的第二用户: 名称=口袋妖怪 符号= PK url = wwww.exmaple.co.il

在用户填写详细信息输入polygonscan之后的第二个示例中,只有名称和图标仍将像第一个示例一样,他们不会以这种方式更改任何后续用户将获得名称和图标第一个示例。 这是我无法解决的问题。

I am trying to create an NFT creation site (ERC721) where any user could upload an NFT he wants he just needs to fill in details of "name","symbol" and "url".
I'm having a problem I can't change the "name" and "symbol". After the first creation each user who uploads NFT is given the "name" and "symbol" of the first user filled in. I use the library of "openzeppelin"

// SPDX-License-Identifier: MIT

pragma experimental ABIEncoderV2;
pragma solidity >=0.6.0 <0.8.0;
import "../ERC721/ERC721.sol";

contract newNFT is ERC721 {
 uint internal counterNFT;
    constructor () public{
     counterNFT = 1;
  }
 
  function mint(string memory uri,string memory name,string memory symbol) public {
       name_symbol(name,symbol);
       _safeMint(msg.sender, counterNFT);
        _setTokenURI(counterNFT, uri);
        counterNFT++;
  }
}

** openzeppelin **

    constructor () public {
        // register the supported interfaces to conform to ERC721 via ERC165
        _registerInterface(_INTERFACE_ID_ERC721);
        _registerInterface(_INTERFACE_ID_ERC721_METADATA);
        _registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE);
    }

     function name_symbol(string memory nameNFT,string memory symbolNFT) internal virtual{
         _name = nameNFT;
        _symbol = symbolNFT;
    }

I want to create a smart contract with which any user can easily upload NFT
By "name" "symbol" and url he chooses. The problem is that the "name" and "symbol" do not change for me after the first user uploaded the NFT with his name and icon. Any user who comes after him and fills in the details will not change the "name" and "symbol" in "polygonscan" in the transaction.

For example the first user on a site that uploads NFT
name = dragonBallZ
symbol = Dragon
url = wwwww.exmaple.co.il

In the first example everything will work well you can see in polygonscan the "name" and "symbol" that the user has selected.

Second user of the site:
name = pokemon
symbol = PK
url = wwwww.exmaple.co.il

In the second example after a user has filled in details entering polygonscan only the name and icon will still be as in the first example they will not change that way any subsequent user will get the name and icon of the first example.
And this is the problem I can not solve.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦冥 2025-01-31 12:24:19

您完全误解了名称和符号应该如何工作。他们应该确定收集或将代表的一个NFT。

说例如无聊的猿:name =“无聊的猿”symbol =“ bayc”
然后,如果我有猴子抽雪茄,它将成为该特定令牌的元数据(tokenuri)的一部分(例如无聊的ape#1344 ,带有tokenuri =” Smokename:“雪茄”,haircolor:“ black”}“),

因此您不应为每个薄荷而言是chan的名称和符号。

You are fully missunderstanding how name and symbol are supposed to work. They should identify the collection or the one NFT they will represent.

Say for example Bored Apes: name="Bored Apes" and symbol = "BAYC".
Then if I have the monkey smoking a cigar it's gonna be part of the metadata (the tokenURI) of that specific token ( for example Bored Ape #1344 with tokenURI="{smokes: true, smokeName: "cigar", hairColor:"black"}")

So you shouldn't be chaning name and symbol for every mint.

静赏你的温柔 2025-01-31 12:24:19

我不能发表评论,很抱歉,这一定是一个答案,如果您要创建NFT或使用该nft创建新合同以创建名称和符号您必须使自己的稳固性设置为tokenuri并与那个tokenuri造成NFT,然后在您的JavaScript中创建元数据,然后使用该元数据上传,然后使用该元数据上传并铸造NFT,如果您的目标是您的目标,则是您的目标片段

与此类似的坚固合同很简单,您可以检查eddrop.io,以查看该方法如何工作

contract EdDrop is ERC721, ERC721URIStorage, Ownable {
    using Counters for Counters.Counter;

    Counters.Counter private _tokenIdCounter;

    constructor() ERC721("EdDrop", "EDN") {}
   
    //No Set Mint Cost, Educators just pay a Gas fee.

    function safeMint(address to, string memory uri) public  {
        uint256 tokenId = _tokenIdCounter.current();
        _tokenIdCounter.increment();
        _safeMint(to, tokenId);
        _setTokenURI(tokenId, uri);
    }

    // The following functions are overrides required by Solidity.
    //
    function _burn(uint256 tokenId) internal override(ERC721, ERC721URIStorage) {
        super._burn(tokenId);
    }
    //Sets the tokenURI the pinata link created from input on page.
    function tokenURI(uint256 tokenId)
        public
        view
        override(ERC721, ERC721URIStorage)
        returns (string memory)
    {
        return super.tokenURI(tokenId);
    }
}

JavaScript以传递数据以功能

   const quantityAsNumber = +quantity
    for (let i=1; i < quantity; ++i) {
      await mintNFT(
        name,
        instructor,
        platform,
        description,
        dates,
        content,
        skills,
        roster,
        external_url,
        score,
        image,
      );
    }

实际的薄荷功能

 export const mintNFT = async(name,instructor,platform, description, dates, content, skills, roster, external_url, score, image, quanitity) => {

//error handling

//make metadata
const metadata = new Object();
metadata.name = name;
metadata.description = description;
metadata.external_url = external_url;
metadata.attributes = {
instructor,
platform,
dates,
content,
skills,
roster,
score,
}

metadata.image= image;

//pinata pin request
const pinataResponse = await pinJSONToIPFS(metadata);
console.log(pinataResponse)
if (!pinataResponse.success) {
return {
success: false,
status: "

I can not comment so sorry this must be an answer, I have no clue if you are creating an NFT or creating a new contract for said NFT with it with the goal of creating a Name and Symbol but if you are creating NFTs upon your contract you must have your solidity a function that sets a tokenURI and mints an nft with that tokenURI and then in your javascript create the metadata that then uploads to say IPFS and mints the NFT using that metadata, here is some code snippets if this is your goal

Solidity Contract similar to this this one is simple and you can check eddrop.io to see how this one works

contract EdDrop is ERC721, ERC721URIStorage, Ownable {
    using Counters for Counters.Counter;

    Counters.Counter private _tokenIdCounter;

    constructor() ERC721("EdDrop", "EDN") {}
   
    //No Set Mint Cost, Educators just pay a Gas fee.

    function safeMint(address to, string memory uri) public  {
        uint256 tokenId = _tokenIdCounter.current();
        _tokenIdCounter.increment();
        _safeMint(to, tokenId);
        _setTokenURI(tokenId, uri);
    }

    // The following functions are overrides required by Solidity.
    //
    function _burn(uint256 tokenId) internal override(ERC721, ERC721URIStorage) {
        super._burn(tokenId);
    }
    //Sets the tokenURI the pinata link created from input on page.
    function tokenURI(uint256 tokenId)
        public
        view
        override(ERC721, ERC721URIStorage)
        returns (string memory)
    {
        return super.tokenURI(tokenId);
    }
}

Javascript to pass data to function

   const quantityAsNumber = +quantity
    for (let i=1; i < quantity; ++i) {
      await mintNFT(
        name,
        instructor,
        platform,
        description,
        dates,
        content,
        skills,
        roster,
        external_url,
        score,
        image,
      );
    }

The Actual Mint Function

 export const mintNFT = async(name,instructor,platform, description, dates, content, skills, roster, external_url, score, image, quanitity) => {
   
  
    //error handling

  
    //make metadata
    const metadata = new Object();
    metadata.name = name;
    metadata.description = description;
    metadata.external_url = external_url;
    metadata.attributes = {
        instructor,
        platform,
        dates,
        content,
        skills,
        roster,
        score,
    }
 
    metadata.image= image;


    //pinata pin request
    const pinataResponse = await pinJSONToIPFS(metadata);
    console.log(pinataResponse)
    if (!pinataResponse.success) {
        return {
            success: false,
            status: "???? Something went wrong while uploading your tokenURI.",
        }
    } 
    const tokenURI = pinataResponse.pinataUrl;  

    //load smart contract
    window.contract = new web3.eth.Contract(contractABI, contractAddress);//loadContract();

    //set up your Ethereum transaction
    const transactionParameters = {
        to: contractAddress, // Required except during contract publications.
        from: window.ethereum.selectedAddress, // must match user's active address.
        'data': window.contract.methods.safeMint(window.ethereum.selectedAddress, tokenURI).encodeABI() //make call to NFT smart contract 
    };
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文