I have sent/deposited Ether to my smart contract using ReactJS as front-end and web3 as interface using the below code.
await this.state.Bank.methods.desposit().send({value:amountInEther.toString(),from:this.state.account})
and while trying to receive ether from the smart contract using frontend Reactjs i have used this code
(React code) await this.state.Bid.methods.withDraw(this.state.account).call()
dbank.sol(solidity below code):
function withDraw(address payable receiver)public{
receiver.transfer(accounts[receiver]);
accounts[receiver]=0;
}
when i tried this it didn't work but when I changed the react code from call to send with address it worked
await this.state.Bid.methods.withDraw().send({from:this.state.account})
But WHY? and also when i use this metamask is taking some gas fees to run this. Don't you think smart contract has to give the ether to us and it should pay the Gas fee. We are paying Gas fee while sending the ether to the contarct Is okay acceptable but why should we pay the gas fee to receive our ether from the contract?