0

I'm trying to deposit weth to aave on the goerli testnet. My approveErc20 function works and I confirmed that tokens are approved for transfer. This is my code:

def deposit_to_aave_goerli(privateKey, amount, lending_pool, web3, nonce=None):
    account=web3.eth.account.from_key(privateKey).address
    lendCon = web3.eth.contract(address=lending_pool,abi=lending_pool_abi)
    nonce = nonce if nonce else web3.eth.getTransactionCount(account)
    weth_address = web3.toChecksumAddress("0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6")
    tx = lendCon.functions.deposit(weth_address, amount, account, 0).buildTransaction(
        {
            "chainId": 5,
            "from": account,
            "nonce": nonce,
        }
    )
    signed_txn = web3.eth.account.sign_transaction(tx, private_key=privateKey)
    tx_hash = web3.eth.send_raw_transaction(signed_txn.rawTransaction)
    return web3.toHex(tx_hash)

I get a boatload of errors after this:

File "C:\Users\ilank\OneDrive\Desktop\Projects\borrowLend.py", line 71, in deposit_to_aave_goerli
    tx = lendCon.functions.deposit(weth_address, amount, account, 0).buildTransaction(
  File "C:\Users\ilank\AppData\Local\Programs\Python\Python310\lib\site-packages\web3\_utils\decorators.py", line 51, in wrapper
    return to_wrap(*args, **kwargs)
  File "C:\Users\ilank\AppData\Local\Programs\Python\Python310\lib\site-packages\web3\contract.py", line 1112, in buildTransaction
    return self.build_transaction(transaction)
  File "C:\Users\ilank\AppData\Local\Programs\Python\Python310\lib\site-packages\web3\contract.py", line 1099, in build_transaction
    return build_transaction_for_function(
  File "C:\Users\ilank\AppData\Local\Programs\Python\Python310\lib\site-packages\web3\contract.py", line 1672, in build_transaction_for_function
    prepared_transaction = fill_transaction_defaults(web3, prepared_transaction)
  File "cytoolz\functoolz.pyx", line 249, in cytoolz.functoolz.curry.__call__
  File "C:\Users\ilank\AppData\Local\Programs\Python\Python310\lib\site-packages\web3\_utils\transactions.py", line 114, in fill_transaction_defaults     
    default_val = default_getter(web3, transaction)
  File "C:\Users\ilank\AppData\Local\Programs\Python\Python310\lib\site-packages\web3\_utils\transactions.py", line 60, in <lambda>
    'gas': lambda web3, tx: web3.eth.estimate_gas(tx),
  File "C:\Users\ilank\AppData\Local\Programs\Python\Python310\lib\site-packages\web3\eth.py", line 868, in estimate_gas
    return self._estimate_gas(transaction, block_identifier)
  File "C:\Users\ilank\AppData\Local\Programs\Python\Python310\lib\site-packages\web3\module.py", line 57, in caller
    result = w3.manager.request_blocking(method_str,
  File "C:\Users\ilank\AppData\Local\Programs\Python\Python310\lib\site-packages\web3\manager.py", line 198, in request_blocking
    return self.formatted_response(response,
  File "C:\Users\ilank\AppData\Local\Programs\Python\Python310\lib\site-packages\web3\manager.py", line 170, in formatted_response
    apply_error_formatters(error_formatters, response)
  File "C:\Users\ilank\AppData\Local\Programs\Python\Python310\lib\site-packages\web3\manager.py", line 70, in apply_error_formatters
    formatted_resp = pipe(response, error_formatters)
  File "cytoolz\functoolz.pyx", line 666, in cytoolz.functoolz.pipe
  File "cytoolz\functoolz.pyx", line 641, in cytoolz.functoolz.c_pipe
  File "C:\Users\ilank\AppData\Local\Programs\Python\Python310\lib\site-packages\web3\_utils\method_formatters.py", line 576, in raise_solidity_error_on_revert
    raise ContractLogicError(response['error']['message'])
web3.exceptions.ContractLogicError: execution reverted: 2

I took the ABI from etherscan, got the lendingPool from aave's lending_pool_address_provider (and confirmed that it was correct),and followed all of Aave's docs. What went wrong?

1 Answer 1

1

Okay, solved. There are like a thousand weth contracts on goerli, you have to use the specific one for Aave's test network. Same with all the other erc20s, you have to get a faucet from the Aave testnet app.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.