0

I've written a smart contract which, like many smart contracts, has a withdrawal message. This withdrawal message will liquidate all holdings of msg.sender and transfer holdings to them.

The actual code I use to do this is taken directly from the SafeTransfer library in Uniswap's codebase.

The piece of the function in question looks like:

processWithdrawal(_customerAddr, totalWithdralAmountInEth);
emit Withdrawal(msg.sender, totalWithdralAmountInEth);

With the process withdrawal looking like:

function processWithdrawal(address _customerAddr, uint256 value) internal {
        //pattern https://solidity-by-example.org/sending-ether/
        (bool sent, ) = _customerAddr.call{value: value}(new bytes(0));
        require(sent, "Failed to send Ether");
    }

However, in Metamask the event 'Withdrawal' is shown but it shows zero ETH transferred as a result of the transfer.

no withdrawal amount show

What's super weird is that the actual amount withdrawn DOES show up in the accounts balance in Metamask. I'm using a hardhat fork locally and I've also console.log present in the contract itself so I know for sure the ETH is leaving the contract. This seems to be isolated to the Metamask activity log. Anyone else have this happen? Thank you.

1
  • Hi, it's actually the amount of ETH you're sending to the contract (when calling its specific function). Metamask never shows how much ETH or other tokens you're gonna get when calling a function of a contract. But some functions are payable, which means that they require some amount of ETH to execute their logic, that's why Metmask shows the amount of ETH you're transferring to the contract during a function call. Jul 14, 2021 at 11:54

1 Answer 1

0

Looks like it has to do with how MetaMask sources function signatures. This lives outside of web3, ethersjs, or the contract. MetaMask will reference a public signature repository on the main net block chain.

MetaMask shows "UNKNOWN FUNCTION" when calling method send function

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.