I have a function to mint no of NFTs got in function parameter randomly. My Logic is Below: It is giving the following error as TX.


The transaction has been reverted to the initial state.

Note: The called function should be payable if you send value and the value you send should be less than your current balance. Debug the transaction to get more information.

The decoded output shows:

    "error": "Failed to decode output: Error: overflow (fault=\"overflow\", operation=\"toNumber\", value=\"35408467139433450592217433187231851964531694900788300625387963629091585785856\", code=NUMERIC_FAULT, version=bignumber/5.5.0)"

Solidity code:

function CryptoRandomMint(address user_addr, uint noOfMints)  contractIsNotPaused public payable returns (uint[] memory,string[] memory) {
     require(noOfMints<4 && noOfMints>0,"You can mint 1-3 NFTs");
     require(TotalNFTsMinted<1000, "Max Minting Limit reached");
     require(msg.value == mintFees*noOfMints, "Not Enough Balance");
     uint[] memory x; 
     string[] memory y;
        for(uint i=0;i<noOfMints;++i){
            (x[i], y[i]) = randomMinting(user_addr);
        depositAmount(_msgSender(), msg.value);
        return (x,y);    

Anyone can help what is the issue?


1 Answer 1


Solildity expects length for every memory array created inside the function. In your code include length to memory arrays x and y . I assume noOfMints will be length of both x and y, Then the code can be modified as:

uint[] memory x = new uint[](noOfMints);
string[] memory y= new string[](noOfMints);

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.