I am getting this error when I try to access a string from a dynamic array
call revert exception; VM Exception while processing transaction: reverted with panic code 50 [ See: https://links.ethers.org/v5-errors-CALL_EXCEPTION ] (method="getTasks(uint256)", data="0x4e487b710000000000000000000000000000000000000000000000000000000000000032", errorArgs=[{"type":"BigNumber","hex":"0x32"}], errorName="Panic", errorSignature="Panic(uint256)", reason=null, code=CALL_EXCEPTION, version=abi/5.7.0)
This is the code I wrote in the client side
const fetchTasks = async () => {
try {
const prov = await getProviderOrSigner();
const contract = await contractInstance(prov);
const query = await contract.getTasks(1);
console.log(query);
} catch (error) {
console.error("Query failed", error.message);
}
};
This is the smart contract I try to read
function getTasks(uint i) external view returns (string memory) {
return users[msg.sender].tasks[i];
}
The interesting thing is that getTasks() function works properly in Remix. When I put 1 as an argument there, it returns the string but somehow, I cannot return from the client side