Solidity – Member ‘store’ Not Found or Not Visible After Argument-Dependent Lookup in Contract

solidity

I created a proxy contract, and I am now trying to update the information at the index point/ address of the contract. I am following a freecodecamp tutorial on youtube. When I try to create a function to update contract I get the error "Member "store" not found or not visible after argument-dependent lookup in contract."

//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./SimpleStoragePractice.sol";

contract SimpleStorageFactoryPractice {

    SimpleStoragePractice simpleStoragePractice;

    SimpleStoragePractice[] public ssfpArray;

    function addToSSFPArray () public {
        simpleStoragePractice = new SimpleStoragePractice();
        ssfpArray.push(simpleStoragePractice);
    }

    function storeToArray(uint _index, string memory _name) public {
       ssfpArray[_index].store(_name);
    }
  
}  

The line ssfpArray[_index].store(_name); is where I am getting the error. Here is the code for the contract that I imported.

//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract SimpleStoragePractice {

    struct People {
        uint customerId;
        string customerName; 
    }

    People[] public peopleArray;

    function addToPeopleArray (uint _customerId, string memory _customerName) public {
        peopleArray.push(People(_customerId, _customerName));
    }

    function updatePeopleArray (uint _peopleArrayIndex, uint _customerId, string memory _customerName) public{
        peopleArray[_peopleArrayIndex] = People(_customerId, _customerName);
    }

    function remove (uint _peopleArrayIndex) public {
        delete peopleArray[_peopleArrayIndex];
    }

}

Best Answer

In this case, the error message is pretty prescriptive - there is no function called store in the SimpleStoragePractice contract. If you change the addToPeopleArray function (which looks like it is trying to accomplish the same thing as store would) to the below, for example, it should work because it is calling a function that exists:

function storeToArray(uint _index, uint _customerId, string memory _name) public { 
  ssfpArray[_index].addToPeopleArray(_customerId, _name); 
}