0

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];
    }

}
0

2 Answers 2

1

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); 
}
1

there is no function called store() in contract SimpleStoragePractice.

Changing

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

to

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

should fix the error and allow you to add new data to peopleArray.

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.