Open gurjeetsinghvirdee opened 1 year ago
{args:[]}
inside the publishCampaign
client/src/context/index.js
// Here we are connecting web3 with the client
import React, { useContext, createContext } from 'react';
import { useAddress, useContract, useMetamask, useContractWrite } from '@thirdweb-dev/react';
import { ethers } from "ethers";
const StateContext = createContext();
export const StateContextProvider = ({ children }) => {
const { contract } = useContract('0x7045fe828a26e4B24B46A6902998C5F73aeF7144');
const { mutateAsync: createCampaign } = useContractWrite(contract, 'createCampaign')
const address = useAddress();
const connect = useMetamask();
const publishCampaign = async (form) => {
try {
const data = await createCampaign({args: [
address, // owner
form.title, // title
form.description, // description
form.target,
new Date(form.deadline).getTime(), // deadline
form.image // image
]});
console.log("contract call success", data)
} catch (error) {
console.log("contract call failure", error)
}
}
return (
<StateContext.Provider
value={{
address,
contract,
connect,
createCampaign: publishCampaign,
}}
>
{children}
</StateContext.Provider>
)
}
export const useStateContext = () => useContext(StateContext);
mutation.ts:261 Error: Function "createCampaign" requires 6 arguments, but 0 were provided. Expected function signature: contract.call("createCampaign", [_owner: string, _title: string, _description: string, _target: BigNumberish, _deadline: BigNumberish, _image: string]): Promise
at ContractWrapper.call (contract-publisher-29ba9ed4.browser.esm.js:8532:13)
at SmartContract.call (contract-publisher-29ba9ed4.browser.esm.js:20300:33)
at Object.mutationFn (useTransactions-5b3be9b8.browser.esm.js:2859:21)
at Object.fn (mutation.ts:179:31)
at run (retryer.ts:147:31)
at createRetryer (retryer.ts:204:5)
at executeMutation (mutation.ts:174:22)
at Mutation.execute (mutation.ts:216:26)
at async publishCampaign (index.jsx:18:26)
at async CreateCampaign.jsx:32:9