Search code examples
soliditytransfertruffleethererc721

When sending ether to another contract it sends it to the contract?


I try to send ether from one address to another. But in the transaction the receiver seems to be the contract address. My goal is to send from address 1 to address 2:

address1:0xDb7c83d499787E6b7660C961F8a9999E3C395AdE address2:0x9199D9323b25BA171De6b9189201Bb322Ba12274

contract-address:0xa82bcf321f584fe81e2e3cfb04eae97b422a4c4f

But the receiver in the transaction appears to be the contract: https://blockscout.mantis.hexapod.network/tx/0x9bc22ad45dbf60881151c3b94b3d3daa98bc84b1906f1ed131ee2ca9a89484eb/internal-transactions

Function:

function sendMoney() public payable {

address payable seller = payable(0x9199D9323b25BA171De6b9189201Bb322Ba12274);

seller.transfer(msg.value); }


Solution

  • When you're invoking the sendMoney() function, you're sending a transaction to the contract that implements this function.

    The seller.transfer(msg.value); is an internal transaction - a part of the main transaction.