0

I'm getting this strange error:

TypeError: Type function (uint256) pure returns (uint256[] memory) is 
not implicitly convertible to expected type uint[256] memory.

The error appears on each of the first 3 lines of code in my getBoughtImages() function. So every one of my 3 variables is "guilty" of whatever this is.

Not really sure what's going on - here's the full code:

struct Img {
    uint IDNumber;
    string color;
    address ownerAddress;
}


Img[] public imgsBoughtArray;



function getBoughtImages() public view returns (uint256[] memory imgsIDs, string[] memory imgsColors, address[] memory ownerIds) {
    uint[] memory boughtImgsIdsArray = new uint[];
    string[] memory imgsColorsArray = new string[];
    address[] memory ownersAddressesArray =  new address[];

    for (uint i = 0; i < 10; i++) {
        boughtImgsIdsArray[i] = (imgsBoughtArray[i].IDNumber);
        imgsColorsArray[i] = (imgsBoughtArray[i].color);
        ownersAddressesArray[i] = (imgsBoughtArray[i].ownerAddress);
    }
    return (boughtImgsIdsArray, imgsColorsArray, ownersAddressesArray);
}

Any ideas what's going on here?

  • usually the code starts with pragma... what is that struct doing there ? – OWADVL Nov 1 '18 at 15:50
1
pragma experimental ABIEncoderV2;

contract d {
    struct Img {
        uint IDNumber;
        string color;
        address ownerAddress;
    }

    Img[] public imgsBoughtArray;

    function getBoughtImages() public returns (uint256[] memory imgsIDs, string[] memory imgsColors, address[] memory ownerIds) {
        uint[] memory boughtImgsIdsArray = new uint[](10);
        string[] memory imgsColorsArray = new string[](10);
        address[] memory ownersAddressesArray =  new address[](10);

        for (uint i = 0; i < 10; i++) {
            boughtImgsIdsArray[i] = (imgsBoughtArray[i].IDNumber);
            imgsColorsArray[i] = (imgsBoughtArray[i].color);
            ownersAddressesArray[i] = (imgsBoughtArray[i].ownerAddress);
        }
        return (boughtImgsIdsArray, imgsColorsArray, ownersAddressesArray);
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.