web3.js icon indicating copy to clipboard operation
web3.js copied to clipboard

Add method decodeAbi to method interface

Open ofumbi opened this issue 2 years ago • 2 comments

The web3 method signature already has the encodeABI() method. contract.method.name().encodeABI() Im requesting that decodeABI() method be added to the signature contract.method.name().decodeABI(result) This is usefull when using multicall contracts, since we retrieve result hashes directly from the multicall contract

ofumbi avatar Jun 22 '23 01:06 ofumbi

Thanks @ofumbi for you suggestion. We will look into it. And it would be great if you provide a full example of your usage. Thanks,

Muhammad-Altabba avatar Jul 06 '23 17:07 Muhammad-Altabba

Here is an example taken from here:

const iface = new ethers.utils.Interface(['function swapExactETHForTokens(uint256 amountOutMin, address[] path, address to, uint256 deadline)'])

iface.decodeFunctionData('swapExactETHForTokens', '0x7ff36ab50000000000000000000000000000000000000000000000bc18ba4144048bbab00000000000000000000000000000000000000000000000000000000000000080000000000000000000000000c0c5eb43e2df059e3be6e4fb0284c283caa5991900000000000000000000000000000000000000000000000000000000614d87a80000000000000000000000000000000000000000000000000000000000000002000000000000000000000000bb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c00000000000000000000000008ba0619b1e7a582e0bce5bbe9843322c954c340')
// gives: [e, ["0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c", "0x08ba0619b1e7A582E0BCe5BBE9843322C954C340"], "0xC0C5eb43E2dF059e3Be6E4fb0284C283CAa59919", e] (4)

spacesailor24 avatar Jul 11 '23 16:07 spacesailor24