(Day 8/9 Deed/DeedMultiPayout)Unable to access withdraw function in a smart contract from my frontend

Hi,

Unable to access withdraw() function in a smart contract from my frontend for day8/day9

$withdraw.addEventListener(‘submit’, (e) => {
e.preventDefault();
deedMultiPayouts.methods
.withdraw()
.then(result => {
$widthdrawResult.innerHTML = Withdrawal succesful!;
refreshBalance();
refreshPaidPayouts();
refreshEarliest();
})
.catch(_e => {
$widthdrawResult.innerHTML = Ooops... there was an error while trying to widthdraw...;
});
});

Getting the following error
Uncaught TypeError: deedMultiPayouts.methods.withdraw(…).then is not a function

Tried with send in between the withdraw and then - that also didn’t work.

Any help will be appreciated.

Thanks,
Venkat

Try this

deedMultiPayouts.methods
.withdraw().send({from: accounts[0]})
.then(result => {

Any state change function it should be called with send(). Otherwise should use call().
It would be helpful if you read this documents.
https://web3js.readthedocs.io/en/v1.2.0/web3-eth-contract.html

1 Like