Forced Ether Transfer

via selfdestrcut method ether can be transferred without using payable key word. here is the example.

// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.7.0 <0.9.0;


contract selfDestructContracttoendEther{

    address targetContract;
    constructor(address _addr) payable {
        targetContract = _addr;
    }


    function destruct()public {
        selfdestruct(payable(targetContract));
    }
    
    function getbalance()public view returns(uint){
        return address(this).balance;
    } 
}

contract targetReceiver{
    
    function getbalance()public view returns(uint){
        return address(this).balance;
    } 
}

By Shabair

Frontend | Blockchain | Smart Contract Developer