1

so Coinbase have an open edition mint going on. It is limited to 1 per wallet. Which means anyone could fund several wallets and mint 1 from each wallet, however this would be gas inefficientm

Interestingly i have found some complex transactions where developers are transferring eth for minting 100 in a single transaction made by a contract, and the nfts are sent to different addresses which also appear to be contracts, which they then sell in bundles to make substantial profits.

These all happen in a single transaction so even though the gas is high, it is profitable.

Been going through the web, but cannot see any solid article on how this can be achieved.

Can anyone explain this process or guide me to an article.

Here is an example of such a transaction

https://etherscan.io/tx/0x8728989411562127d024d5887f4e914c5371e1a5ed589132dbd6093e1f31750b

3 Answers 3

0

It's more complex than what Talha said here, actually.

  1. create a proxy contract
  2. mint with it
  3. transfer the NFT you minted to your own address
  4. a for loop of step 1 - 3

Here's a simple example (though it won't work for Coinbase's NFT)

// SPDX-License-Identifier: GPL-3.0

pragma solidity ^0.8.4;

interface INFT {
    function transferFrom(address from, address to, uint256 tokenId) external;
    function balanceOf(address account) external view returns (uint256);
    function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);
    function mint() external;
}

contract NFTBatchMinter {
    address private _nftAddress;
    
    constructor(address nftAddress) {
        _nftAddress = nftAddress;
    }
    
    function batchMint(uint256 times) public {
        for(uint i = 0; i < times; ++i) {
            try new NFTMinter(_nftAddress) {
            } catch Error(string memory reason) {
                revert(string(abi.encodePacked("NFTMinter creation failed: ", reason)));
            } catch {
                revert("NFTMinter creation failed: unknown error");
            }
        }
    }
}

contract NFTMinter {
    address private _nftAddress;
    address private _owner;
    
    constructor(address nftAddress) {
        _nftAddress = nftAddress;
        _owner = msg.sender;
        INFT(_nftAddress).mint();
        uint256 id = INFT(_nftAddress).tokenOfOwnerByIndex(address(this), 0);
        INFT(_nftAddress).transferFrom(address(this), _owner, id);
    }
}

2
  • Wow, this is what i had i mind when i asked, i will try this out on testnet and give feedback soon. Thank you Mar 6, 2023 at 6:56
  • Even though this isn't exactly what i wanted, it explains a similar logic, i will accept this answer May 10, 2023 at 16:50
0

Batch minting NFTs during a public mint with a contract can be done using a loop

function mint(address _to, uint256 _mintAmount) public payable {
        uint256 supply = totalSupply();
        require(supply + _mintAmount <= maxSupply);

        for (uint256 i = 1; i <= _mintAmount; i++) {
            _safeMint(_to, supply + i);
        }
    }

There will still be a limit for the amount of NFTs you can mint in one go

2
  • Thank you, i will try it out and mark your answer as accepted if it works Mar 3, 2023 at 10:03
  • Sure lemme know if you face any issue Mar 3, 2023 at 11:22
0

Good news, here's a contract that does exactly what you were asking for

https://etherscan.io/address/0xa39bf46ceee5bdac2c9bc95a28f959719e088f83#code

Have fun.

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.