I am building a crowdfunding blockchain application and I am getting the above error.
Uncaught (in promise) Error: Function "getDonators" requires 1 arguments, but undefined were provided. Expected function signature: contract.call("getDonators", _id: BigNumberish): Promise<string[], BigNumber[]>
This the code for the part where I am calling getDonators function
const getDonations = async (pId) => {
const donations = await contract.call('getDonators', pId); //HERE!
const numberOfDonations = donations[0].length;
const parsedDonations = [];
for(let i = 0; i < numberOfDonations; i++) {
parsedDonations.push({
donator: donations[0][i],
donation: ethers.utils.formatEther(donations[1][i].toString())
})
}
return parsedDonations;
}
This is the code that is present in the Solidity File
function getDonators(uint256 _id) view public returns (address[] memory, uint256[] memory) {
return (campaigns[_id].donators, campaigns[_id].donations);
Please help me resolve this issue. Am I not passing the parameters correctly ?
I tried to pass parameters in various ways but it didnt really fixed the issue. Also I tried to call the function(in .sol file) in a different manner like this :
await contract.donateToCampaign(pId, {
value: ethers.utils.parseEther(amount.toString())
});