Etherscan and other blockchain explorers use their own custom key-value database of function selectors to their names that is not available through the site API, nor JSON RPC API (or its wrappers such as web3
and ethers.js
).
They have a collection of contract source codes and ABIs from the verification process, allowing them to translate a function selector available through the RPC method getTransaction
field data
(e.g. 0xa0712d68
) to a function definition (e.g. mint(uint256)
), and then simply convert it to a human-readable format: Mint
.
If you want to translate the function selector to a function name, you'll need to build your own dictionary, or use one of the few available online tools that have an already populated database, for example this one.