-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from MetaMask/method-registry
add function signature registry steps
- Loading branch information
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
01_Main_Concepts/07_Best_Practices/00_Function_Signature_Registry.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
|
||
# How to get your function name displayed on the MetaMask Confirm Screen instead of "unknown function" | ||
|
||
_MetaMask uses the parity on-chain registry of function signatures to display method names on the confirm screen._ | ||
|
||
To add your contract's function names to this registry, follow the below steps. | ||
|
||
1. Go to the [mainnet parity signature registration contract on etherscan](https://etherscan.io/address/0x44691b39d1a75dc4e0a0346cbb15e310e6ed1e86#writeContract) | ||
|
||
2. Connect MetaMask | ||
|
||
3. Use etherscan's write contract feature to input the string value (without quotes) to the register function | ||
|
||
for example: | ||
|
||
`getOwners()` | ||
|
||
`execTransaction(address,uint256,bytes,uint8,uint256,uint256,uint256,address,address,bytes)` | ||
|
||
4. Press write | ||
|
||
5. Approve the transaction through MetaMask (you only pay gas) | ||
|
||
|
||
##### Verify | ||
|
||
`web3.sha3('getOwners()') => 0xa0e67e2bdc0a6d8a09ccd6c353c9df590807ad66ff5e6630c4f31a86dfa84821` | ||
|
||
take the first 10 characters `0xa0e67e2b` | ||
and input into **[this demo app](https://jennypollack.github.io/function_signature_registry/) that checks the on-chain registry** (mainnet or rinkeby) | ||
|
||
##### Alternate steps using remix.ethereum.org: | ||
|
||
Paste the contract code from [bokky's blog post](https://www.bokconsulting.com.au/blog/a-quick-look-at-paritys-signature-registry-contract/) into [remix](remix.ethereum.org) | ||
|
||
Set the correct compiler version based on the contract. | ||
|
||
Use remix's write functionality to add to the registry. | ||
|
||
You can look at the FUNCTIONHASHES section on remix.ethereum.org by loading the signature registry contract, press the Details button on the compile tab. | ||
|
||
##### Additional Info | ||
You can also use the [signature registry](https://rinkeby.etherscan.io/address/0x0c0831fb1ec7442485fb41a033ba188389a990b4) deployed on rinkeby but should note that **MetaMask reads from the mainnet eth-method-registry endpoint, regardless of user's network** | ||
|
||
[eth-method-registry](https://github.com/danfinlay/eth-method-registry) is used to lookup methods in MetaMask. | ||
|
||
This [stack exchange](https://ethereum.stackexchange.com/questions/59678/metamask-shows-unknown-function-when-calling-method-send-function) answer is a good **tldr**. |