Transaction hash give input data like this "0xa9059cbb00000000000000000000000024c38db6c4a85b3e6b58631de2334105f6209da300000000000000000000000000000000000000000000000000000dca4f1516a8". if i call this function let encodedFunctionSignature = web3.eth.abi.encodeFunctionSignature('transfer(address,uint256)');
it give me this "0xa9059cbb".etherscan call this methodId
My question is how i get the transfer(address,uint256) back from this "0xa9059cbb"
The function selector is the first four bytes of the keccak256 hash of the canonicalized function signature. In this case, web3.sha3('transfer(address,uint256)').substring(0, 10) === "0xa9059cbb"
.
Reversing this process is not generally possible unless the contract's code or ABI is provided. That said, as long as someone else has used a given function selector before and provided its original name, you can use that information instead.
One list of commonly used function selectors is here: https://github.com/ethereum-lists/4bytes, and in fact transfer(addresss,uint256)
is the first example given.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With