0

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); }

caarkii
  • 15
  • 5

2 Answers2

1

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.

Petr Hejda
  • 40,554
  • 8
  • 72
  • 100
  • Thanks for your answer! What would I need to change then to send it to the other wallet? – caarkii Apr 14 '22 at 08:57
  • 1
    @caarkii You can change the `seller` address value to send the funds to another wallet. – Petr Hejda Apr 14 '22 at 09:06
  • but I already have the seller address as the address which should receive the funds, but the smart-contract receives. – caarkii Apr 14 '22 at 09:09
  • 1
    @caarkii Sorry, not sure what you mean. Is your intention to redirect funds from the user (invoking the `sendMoney()` function) to the `0x9199...` (seller) address, the `0xa82bc...` (contract) address? Or to another one? – Petr Hejda Apr 14 '22 at 09:12
  • Yes the user invoking the sendMoney() method should transfer the funds to the seller address. So from one wallet to another wallet – caarkii Apr 14 '22 at 09:20
  • 1
    @caarkii That's already happening. Just because of how EVM works, it's shown only as an internal transaction - not as the main transaction... This blockchain explorer shows the internal transaction on the bottom of the page. – Petr Hejda Apr 14 '22 at 09:23
  • Thanks a lot. It seemed to work. Now i wanted to implement that I also send to the contract itself as part of a royalty. if I change the function to this it wont work anymore: address payable seller = payable(address(this)); https://blockscout.mantis.hexapod.network/tx/0x86a6dd4abb5387fb6204e7ba011cf54a3e07c1b81b0673ac4536bfda0068852d/internal-transactions – caarkii Apr 14 '22 at 10:04
  • @caarkii If ETH receiver is a contract, it needs to implement either the `fallback()` or the `receive()` function. Otherwise the ETH transfer fails, as happened in your case. Docs: https://docs.soliditylang.org/en/v0.8.13/contracts.html#special-functions – Petr Hejda Apr 14 '22 at 12:01
0

I had the same problem. But it is actually working fine, the ether is sent. My mistake was that I didn't change the denomination of ether, it was set to wei. So, I was trying to send 1 wei instead of 1 ether. The transaction goes through but I couldn't see the change as the quantity was so small.

Dinno Koluh
  • 111
  • 4