Hello When i Try to initialized contract this error is coming can anyone help me to fix this error
export const getStaticProps=async(context)=>{
const provider=new ethers.providers.JsonRpcProvider(
AlchemyProvider
);
const contract=new ethers.Contract(
context.params.address,
Campaign.abi,
provider
);
const donated=contract.filters.donated();
const allDonations=await contract.queryFilter(donated);
const title=await contract.campaignTitle();
const storyUrl=await contract.story();
const requiredAmount=await contract.requireAmount();
const receivedAmount=await contract.receiveAmount();
const image=await contract.image();
const owner=await contract.campaignOwner();
const Data={
address:context.params.address.toString(),
title,
storyUrl,
requiredAmount:ethers.utils.formatEther(requiredAmount),
receivedAmount:ethers.utils.formatEther(receivedAmount),
image,
owner
}
allDonations.map((e)=>{
return{
donar:e.args.owner,
amount:e.args.amount,
timestamp:e.args.timestamp
}
});
return{
props:{
allDonations,
Data
}
}
}
Here is my Contract
//SPDX-License-Identifier:Unlicensed
pragma solidity >0.8.0;
contract campaignFactory{
address [] public deployedCampaigns;
event createdCampaign(
address indexed owner,
string indexed category,
uint indexed timestamp,
string title,
string storyUrI,
uint requireAmount,
string imageUrI,
address campaignAddress
);
function createCampaign(
string memory title,
string memory storyUrI,
uint requireAmount,
string memory category,
string memory imageUrI
)public{
Campaign newCampaign=new Campaign(title,storyUrI,requireAmount,msg.sender,imageUrI);
deployedCampaigns.push(address(newCampaign));
emit createdCampaign(msg.sender, category, block.timestamp, title, storyUrI, requireAmount, imageUrI,address(newCampaign));
}
}
contract Campaign{
event donated(address indexed owner,uint indexed amount,uint indexed timestamp);
string public campaignTitle;
string public story;
uint public requireAmount;
uint public receivedAmount;
address payable public campaignOwner;
string public image;
constructor(
string memory _campaignTitle,
string memory _story,
uint _requireAmount,
address _owner,
string memory _image
){
campaignTitle=_campaignTitle;
story=_story;
requireAmount=_requireAmount;
campaignOwner=payable(_owner);
image=_image;
}
function donate()payable public{
require(requireAmount>receivedAmount,"Require Amount is fullfilled");
campaignOwner.transfer(msg.value);
receivedAmount+=msg.value;
emit donated(msg.sender, msg.value, block.timestamp);
}
}