0

While testing NFT contract on Rinkeby I encountered a situation where I cannot transfer eth from my contract. I had 0.01 Eth on the contract and then I called transfer to withdraw 0.008 Eth (transaction)

    function transfer(address payable _to, uint256 _amount) public onlyOwner {
        (bool success, ) = _to.call{value: _amount}("");
        require(success, "Failed to send Ether");
    }

The transaction is successful, it deducts Eth from the contract but my wallet does not receive the value. Only thing that indicates any error is

ERC-20 Token Transfer Error (Unable to locate corresponding Transfer Event Logs), Check with Sender.

But according to my understanding I should not emit this event on my own, because it is not necessary in the official tutorials, e.g. in https://solidity-by-example.org/payable/.

Might there be a problem with the fact that the contract is inherited from ERC721?

1 Answer 1

0

The ether was transferred correctly. Most wallet don't show internal transaction and probably the wallet you are using isn't displaying a change, but the balance should reflect the change.

Etherscan believes it is a token transfer because of the function signature (transfer(address,uint256)). Since no Transfer event is emitted it shows the error ERC-20 Token Transfer Error.

TL;DR Function works correctly, ether is transferred.

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.