Metamask showing 0 token transfer in custom functions

Hi All,

Does anyone know why metamask shows 0 tokens transferring when calling custom functions from the contract.

I’m using custom functions so i know why the user was transferring the tokens - how could i get around this?

Hi Bobm, welcome to open zeppelin.

Can you please show an example of this issue.

It might be because the Smart Contract isn’t properly emitting events. It might be because they are transferring in an odd way.

Please provide the code, and what you are seeing in metamask.


Hi @Yoshiko Thanks for the welcome…

As a new user, i can only post one image, so here is a screenshot of the post i wrote:

When calling custom functions from the web3.js it all works as expected and this is how i can tell the tokens are being transferred over to the contract, its just metamask showing 0 tokens…

Does it do the same when you call it through the web3 interface in etherscan/bscscan?

It might be something unintended with msg.sender, but I could be uncertain.

Open Zeppelin has a standard Context Contract.

You can read from the note of why they made it

 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).

Maybe there is something with that, not sure though.

so there are two things you can try, let me know if either one works.

I believe MetaMask recognizes the function signature that you’re calling. It doesn’t simulate the transaction to figure out what events it will emit. So if the function is not the standard ERC20 transfer function it will not be detected prior to submitting the transaction.

thanks my issue has been fixed.

1 Like