0

I have the following solidity function that a wallet calls:

    function giveupStake(uint amount) public payable {
        if (initialStakes[msg.sender] >= amount) {
            initialStakes[msg.sender] -= amount;
            (bool success, ) = payable(msg.sender).call{value: amount}("");
            require(success, "Transfer failed");
        }
    }

The function is supposed to transfer "amount" eth from the contract to the caller of the function. And I'm calling the function using ether.js like so and checking whether the amount was transferred or not:

yieldToken.connect(signers[1]).giveupStake(1000);     
balance = await signers[1].getBalance(); 

But the new balance doesn't reflect the payment that the giveupStake function is supposed to make to the sender. How to fix this?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.