Working with metamask, I have these two functions, which (for the most part) have almost identical calls to a smart contract:
localContract.methods
.presaleMint(window.ethereum.selectedAddress, ipfs)
.send({
from: window.ethereum.selectedAddress,
value: web3.utils.toWei(price * amount + "", "ether"),
gas: 240000 * (100 - amount * 4) / 100 * amount
})
localContract.methods.togglePresale().send({
from: window.ethereum.selectedAddress,
gas: 800000
})
The main difference I see is that the first function has params.
My question though is, why does metamask give the name of the called function for the second, but not the first? (first only shows 'Contract Interaction')
I can see that this was raised on metamask git years ago, i'm just surprised it's still set this way... https://github.com/MetaMask/metamask-extension/issues/8835
MetaMask uses a dictionary that translates function selector (0x
and the first 8 hex characters of the data
field) into a human-readable name.
If MM doesn't find the function selector in the dictionary, they use a generic label "Contract Interaction".
How to add your function selector (of the presaleMint()
function) to their dictionary: https://docs.metamask.io/guide/registering-function-names.html#verify