Stack Exchange Network
Stack Exchange network consists of 183 Q&A communities including
Stack Overflow
, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Visit Stack Exchange
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.
Sign up to join this community
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
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.
Output
:
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?
–
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);
Thanks for contributing an answer to Ethereum Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.