简体   繁体   中英

Solidity transfer funds is redirecting to another address

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 enter image description here

The 0xab29... address that you see in MetaMask is the contract address.

In order to execute the sendAmount() function, effectively redirecting the funds to the 0x90E3... address, you need to send a transaction to the contract address (with the corresponding value of the data field of the transaction, representing the sendAmount() function signature).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM