0

I am trying to send funds in solidity using the below code

/ SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.7.0 <0.9.0;

contract SendEther
{
    function sendAmount() payable public
    {
        address _to = 0x90E3EC58Eb437204ad071339d6CE97740e7eadd0;
        payable(_to).transfer(msg.value);
    }
}

However, I am getting a entirely different address on metamask wallet. Please check the metamask wallet sender address here

2 Answers 2

1

I'm speculating that the frontend is trying to call contract.SendAmount{value: ???}(), and metamask is asking you to approve the call to the contract. So the address you're seeing is actually the contract address.

You don't need to approve every individual operation inside the contract's function, so you should never see you hardcoded _to address in metamask.

1
  • Actually I am using remix IDE to test my code. I was following a tutorial and performed the exact operation. However I am not getting the desired output Commented Jan 18, 2022 at 6:14
0

Transfers performed by a contract are usually called "internal transaction".

Unfortunately Metamask doesn't support displaying internal transaction.

In your case it is showing the contract interaction executin the sendAmount function.

6
  • So, may I know a way to get the job done Commented Jan 18, 2022 at 7:28
  • @ManiDeepakTelaprolu What are you trying to do? The contract does transfer whatever ether amount it receives to the address 0x90E3EC58Eb437204ad071339d6CE97740e7eadd0. If you want Metamask to display an "internal transaction" that's not possible.
    – Ismael
    Commented Jan 18, 2022 at 8:07
  • When I executed the above smart contract, the funds got redirected to another address. I check on etherscan also. Funds redirected. If you don't mind can you please run the contract on your remix IDE? Commented Jan 18, 2022 at 8:45
  • @ManiDeepakTelaprolu Do you have the transaction hash?
    – Ismael
    Commented Jan 18, 2022 at 14:10
  • Thanks for reaching out to help me. I got to know the issue and funds were reflected in the state of transaction Commented Jan 20, 2022 at 9:00

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.