Skip to content

Issue with buildTranscaction #2134

@jhb10c

Description

@jhb10c
  • Version: 5.23.1
  • Python: 3.8.8
  • OS: osx
  • pip freeze output




### What was wrong?

When building the call data for a transaction using buildTransaction, error code -32016 keep occuring. Not sure why it is occuring

Please include any of the following that are applicable:

* The code which produced the error:
rece = router.functions.swapExactTokensForTokens(1,1,Path[:2],web3.toChecksumAddress('0xCA090945dF18fFd93F342Cb1e8B61d3f71e044a7'),1633501982).buildTransaction()



* The full output of the error:

  File "<ipython-input-144-66e457b9cef4>", line 1, in <module>
    rece = router.functions.swapExactTokensForTokens(1,1,Path[:2],web3.toChecksumAddress('0xCA090945dF18fFd93F342Cb1e8B61d3f71e044a7'),1633501982).buildTransaction()

  File "/opt/anaconda3/lib/python3.8/site-packages/web3/contract.py", line 1079, in buildTransaction
    return build_transaction_for_function(

  File "/opt/anaconda3/lib/python3.8/site-packages/web3/contract.py", line 1648, in build_transaction_for_function
    prepared_transaction = fill_transaction_defaults(web3, prepared_transaction)

  File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__

  File "/opt/anaconda3/lib/python3.8/site-packages/web3/_utils/transactions.py", line 102, in fill_transaction_defaults
    default_val = default_getter(web3, transaction)

  File "/opt/anaconda3/lib/python3.8/site-packages/web3/_utils/transactions.py", line 66, in <lambda>
    'gas': lambda web3, tx: web3.eth.estimate_gas(tx),

  File "/opt/anaconda3/lib/python3.8/site-packages/web3/eth.py", line 728, in estimate_gas
    return self._estimate_gas(transaction, block_identifier)

  File "/opt/anaconda3/lib/python3.8/site-packages/web3/module.py", line 57, in caller
    result = w3.manager.request_blocking(method_str,

  File "/opt/anaconda3/lib/python3.8/site-packages/web3/manager.py", line 187, in request_blocking
    return self.formatted_response(response,

  File "/opt/anaconda3/lib/python3.8/site-packages/web3/manager.py", line 168, in formatted_response
    raise ValueError(response["error"])



* Node:
Infura RPC


### How can it be fixed?

Work around was to build transaction call using the method .encodeABI like below:

    rece = router.encodeABI(fn_name='swapExactTokensForTokens',args=[amountIn,amountOutMin,path,to,deadline])


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions