1

When I use 'approveAndCall' to transfer tokens to a contract, the MetaMask verification screen doesn't show the amount, or the token name.

let contract = new web3.eth.Contract(gsERC20abi, '0x1f0735E0CaA3e2dc0f6C213274981FbF9D8F4CDA');
contract.methods.approveAndCall("0x9AF3BC7541D38B729F46fdd47B403AF5B229f6CF", 6, web3.utils.fromAscii("0")).send({from: "0xaBd70Cb55617EBC738607E0786aBE76Ad61e2f37"})
.on('transactionHash', function(hash){
  console.log(hash);
});

The MetaMask verification screen shows "0" as the amount for the "APPROVE AND CALL" process, and doesn't show the token name. The tokens are successfully transferred from the active account to the contract, but the MetaMask verification screen doesn't show what is about to happen. That is not good!

However, when I instead transfer tokens to an account, the MetaMask verification screen correctly shows the amount and the token name:

let contract = new web3.eth.Contract(gsERC20abi, '0x1f0735E0CaA3e2dc0f6C213274981FbF9D8F4CDA');
contract.methods.transfer("0x2f4Edafe16509913198950226Bf148616D91BeE3", 3).send({from: "0xaBd70Cb55617EBC738607E0786aBE76Ad61e2f37"})
.on('transactionHash', function(hash){
  console.log(hash);
});
| improve this question | | | | |
1

Metamask picks up the standard ERC20 method called transfer() to identify whether its token transfer or not. Metamask Documentation

enter image description here

So, if you call ApproveAndCall method or any other methods, it is not identified as Token transfer, and thus can not be displayed as Token name/amount.

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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