I am able to deposit amount of Ether into my smart contract via the depositFunds
function like below:
async function depositFunds() {
console.log(`Depositing Funds...`);
if (typeof window.ethereum !== "undefined") {
const provider = new ethers.providers.Web3Provider(window.ethereum);
const signer = provider.getSigner();
const contract = new ethers.Contract(contractAddress, abi, signer);
const transactionResponse = await contract.depositFunds({
value: ethers.utils.parseEther("1"),
});
}
}
I am now trying to withdraw a portion of the funds (i.e. not all of them), but I cannot figure out how to pass the data to the withdrawFunds
function of my contract.
async function withdrawFunds() {
console.log(`Withdrawing Funds...`);
if (typeof window.ethereum !== "undefined") {
const provider = new ethers.providers.Web3Provider(window.ethereum);
const signer = provider.getSigner();
const contract = new ethers.Contract(contractAddress, abi, signer);
const transactionResponse = await contract.withdrawFunds({
data: "0.5",
});
}
}
Below is the ABI for my withdrawFunds
function:
{
inputs: [
{
internalType: "uint256",
name: "_weiToWithdraw",
type: "uint256",
},
],
name: "withdrawFunds",
outputs: [],
stateMutability: "nonpayable",
type: "function",
}
Any ideas on how to approach this? Thanks!