Burn batch function call error

Hi,

I'm trying to call the burnBatch function from the standard erc721 implementation, but I get these errors:

"Invalid implicit conversion from uint8[3] memory to uint256 memory requested"
"Invalid implicit conversion from uint256[3] memory to uint256 memory requested"

Code:

function landOnPlanet(uint[] memory ships, uint16 planetID, bool successful) private {
         
        uint256 numberOfLight_Ships;
        uint256 numberOfMedium_Ships;
        uint256 numberOfLarge_Ships;
         
        for(uint8 i= 0; i<ships.length; i++) { 
            require(containsInSpace(ships[i],planetID), "dont have that ship");
           
            whichShipsAtSpace[msg.sender][planetID][shipIndexInFromSpace(ships[i], planetID)] = whichShipsAtSpace[msg.sender][planetID][whichShipsAtSpace[msg.sender][planetID].length - 1];
            
            whichShipsAtSpace[msg.sender][planetID].pop();
            
            if(successful){
                whichShipsAtPlanet[msg.sender][planetID].push(shipsArray(ships[i]));
            }
            
            if(ships[i]==1){
                numberOfLight_Ships += 1;
            }
            
            if(ships[i]==2){
                numberOfMedium_Ships += 1;
            } 
            
            if(ships[i]==3){
                numberOfLarge_Ships += 1;
            }  
        }
         
        if(successful){
                setPlanetOwner(planetID);
            } else {
               //ERROR LINE!!!
                burnBatch(msg.sender,[1,2,3],[numberOfLight_Ships,numberOfMedium_Ships,numberOfLarge_Ships]);
            }  
    }

Don't know how to pass the values, when I try on remix I can call the burnBatch function directly with [1,2,3].

Thanks!!!

Array literals are static-size arrays, which are not compatible with dynamic-sized arrays as the batch functions expect.

This is from the Solidity docs on Array Literals:

If you want to initialize dynamically-sized arrays, you have to assign the individual elements:

// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.16 <0.9.0;

contract C {
    function f() public pure {
        uint[] memory x = new uint[](3);
        x[0] = 1;
        x[1] = 3;
        x[2] = 4;
    }
}
1 Like