0

I want to mint NFT using ERC721A but I cant use the TokenURI.

function prizeDistribution(uint256 jackPotId)
    external
    payable
    override
    returns(uint256)
    {
        require(_dateTime._now() >= _jackPots[jackPotId]._endTime ,
        "Time has not passed enough for this JackPot");
        require(_dateTime.get15DaysSeconds() >= _jackPots[jackPotId]._endTime,"15 Days have not passed for this jackpot");
        //check time after endTime ,that has it been 15 days ?
        
        address[] memory participants = this.getParticipantAddresses(jackPotId);
        //SideNote to call another implemented external function, use this keyword
        //then make a function in which the participants list is passed
        
        address winner =  this.calculateRandomWinnerFromList(participants,jackPotId);
        //generate a single random number from the list of participants length
        //return that address and rest of the list excluding that winner
        
        IERC20(0xd9145CCE52D386f254917e481eB44e9943F39138).transfer(winner,_jackPots[jackPotId]._prizePool);
        _jackPots[jackPotId]._prizePool = 0;
        

        /*
        I want to use ERC721A and batch mint N amount of participants 
        that took part and transfer nfts to them
        */

        return 1;
    }
2

1 Answer 1

0

Unfortunately, ERC721A only allows you to batch mint NFT IDs to a single recipient address. If you have multiple recipients, then you will have to use a for loop and call _safeMint to each and every recipient address. And by doing so, you lose any batch mint advantages offered by ERC721A.

Note: using for loops in Solidity is heavily discouraged due to unexpected gas costs and the possibility of exceeding the max block gas limit.

3
  • ethereum.stackexchange.com/users/51644/ahmed-ihsan-tawfeeq Ok, So does ERC1155 provides the following functionality: 1) Send NFT to multiple Addresses 2) Use Stroage-URI ? Commented May 15, 2022 at 7:32
  • @SyedMurtazaAliShah No, there's nothing in the ERC1155 specification that suggests that it does. If you still want to mint to multiple participants, you will most-likely need to write a bulkMint function that takes address[] calldata accounts as input, and then use a for loop to mint one NFT per each account in accounts. This is better, since here you will always be able to control the number of iterations of the for loop by adjusting the input array size. Commented May 15, 2022 at 10:07
  • Though, you will probably need to adjust the entire list of participants into smaller input chunks and call bulkMint on each chunk at a time. Commented May 15, 2022 at 10:08

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.