6

I'm trying to configure communication between a web front end and a deployed Ethereum contract (on Rinkeby). I'm trying to call a simple method that updates a value, which looks something like this:

uint public value;

function someFunction(uint newValue) public {
    value = newValue;
}

And I'm calling the function like this from the client:

myContract.methods.someFunction(newValue).send({
    from: myAccount,
});

When MetaMask pops up, it says "UNKNOWN FUNCTION" above the value to be sent to the client (it's also doing this when I try to call methods that actually require ether value). Is there any way to address the issue? It seems that this would probably be distressing for users if actual ether were involved.

enter image description here

1 Answer 1

7

To have MetaMask recognise the signature of your function, you need to register is at:
https://etherscan.io/address/0x44691B39d1a75dC4E0A0346CBB15E310e6ED1E86#writeContract

This is where MetaMask pulls data to determine the function corresponding to a function hash.

i.e. in your example, call the register function of the above contract, passing in:
someFunction(uint256)

3
  • can you elaborate a bit because I don't get it? From where should I call the register function? From which account? From the web interface?
    – arisalexis
    Nov 9, 2018 at 0:03
  • You can call the register function from anywhere (e.g. MEW, Mist) that lets you interact with smart contracts. etherscan.io now supports writing to contracts as well (see above link) using MetaMask. The account shouldn't matter when registering a function - all you're doing is associating the function name with it's signature and recording this association in the smart contract. You would need to pay gas for the call but nothing else.
    – Adam Dossa
    Nov 9, 2018 at 8:37
  • See docs: github.com/MetaMask/metamask-docs/blob/…
    – TeNNoX
    May 11, 2021 at 14:07

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.