GithubHelp home page GithubHelp logo

Comments (3)

Vectorized avatar Vectorized commented on July 23, 2024 1

The data parameter in _safeMint is for forwarding to the onERC721Received function on the mint recipient, if it is a contract. See https://chiru-labs.github.io/ERC721A/#/erc721a?id=_safemint.
If your use case is for minting to wallets (most NFT projects), it is not required.

Say if your baseURI is https://ikzttp.mypinata.cloud/ipfs/QmQFkLSQysj94s5GvTHPyzTxrawwtjgiiYS2TBLgrvw8CW/,
and URI of tokenID 123 is https://ikzttp.mypinata.cloud/ipfs/QmQFkLSQysj94s5GvTHPyzTxrawwtjgiiYS2TBLgrvw8CW/123,

this is how you'd do it:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

import "erc721a/contracts/ERC721A.sol";

contract MyNFT is ERC721A {

    constructor() ERC721A("MyNFT", "MNFT") {}
    
    function _baseURI() internal view override returns (string memory) {
        return 'https://ikzttp.mypinata.cloud/ipfs/QmQFkLSQysj94s5GvTHPyzTxrawwtjgiiYS2TBLgrvw8CW/';
    }

    function mint(uint256 quantity) external payable {
        // _safeMint's second argument now takes in a quantity, not a tokenId.
        _safeMint(msg.sender, quantity);
    }
}

from erc721a.

Anarr avatar Anarr commented on July 23, 2024

@Vectorized thank you, maybe I missed something from doc. It works!

from erc721a.

honorableCon avatar honorableCon commented on July 23, 2024

Can we set custom URI like _setTokenURI from "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";

from erc721a.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.