tronprotocol / tronweb

Javascript API Library for interacting with the TRON Network
MIT License
413 stars 271 forks source link

error on call tronWeb.utils.abi.decodeParamsV2ByABI() #464

Closed VannaKarenina closed 6 months ago

VannaKarenina commented 8 months ago

error on call

tronWeb.utils.abi.decodeParamsV2ByABI(
        {
          "constant": false,
          "outputs": [
            {
              "name": "_to",
              "type": "address"
            },
            {
              "name": "_value",
              "type": "uint256"
            }
          ],
          "name": "transfer",
          "payable": false,
          "stateMutability": "nonpayable",
          "type": "function"
        },   
'a9059cbb00000000000000000000004112afe011e48f1bb557b3f3305431b25325e841c9000000000000000000000000000000000000000000000000000000000002e630'
)

transaction: https://tronscan.org/#/transaction/074da622d44ff303b756dc8a4a1bcc02944a28fcbdcadf350ec1376c4738daca

error: invalid arrayify value (argument=\"value\", value=\"a9059cbb00000000000000000000004112afe011e48f1bb557b3f3305431b25325e841c9000000000000000000000000000000000000000000000000000000000002e630\", code=INVALID_ARGUMENT, version=bytes/5.7.0)"}

start940315 commented 8 months ago

First, the leading 8 chars of your data is the hash of the function, you have to remove it. Then, since we are using ethers decoder, you have to remove the leading '41' of your address in data. Last, data should be prefixed with '0x'. So finally, you need to change data to '0x00000000000000000000000012afe011e48f1bb557b3f3305431b25325e841c9000000000000000000000000000000000000000000000000000000000002e630';