0

I have a fallback function like this. So I am able to send and increase the amount in "contract address". Assume I sent 2 transactions like 10 and 20, the sum is 30 is successfully shown.

I am very much confused how to reduce the amount of contract address. I am using Remix and when i try to reduce it is actually reducing from Account adress. How to choose contract address and reduce amount of contract. Can you please mention a piece of code.

Actually in Remix only 10 Account address are shown but not the contract addresses

pragma solidity 0.4.25;
contract sendether{

     function receiveEther() payable public{
     }

}

1 Answer 1

1

The contract is the only one able to reduce its balance.

You need to add a function in the contract, that function will be able to send ether to a recipient

function rescueETH() public onlyOwner {
   payable(msg.sender).transfer(address(this).balance);
}

now send a tx that calls contract.rescueETH().

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.