0

I'm using web3py on polygon network, through the RPC provided from MaticVigil

I'm trying to borrow using the following python code :

nonce = web3.eth.get_transaction_count(ether_address)

contract = web3.eth.contract(address=aave_lendingpool_contract, abi=aave_lendingpool_abi)

fct = contract.functions.borrow(asset=borrowasset, amount=amountETH, interestRateMode=2, referralCode=0, onBehalfOf=ether_address).buildTransaction({
    "chainId": 137,
    "nonce": nonce
})

That last line fail with the error : ContractLogicError: execution reverted: 59

I cannot find out what is wrong. It's not even signed and sent yet.

If I try the parameters directly on the contract here polygonscan it work.

==> any idea what is wrong ?

my parameters are :

nonce : calculated each time, used in another part of the code, this part work

borrowasset: '0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063' it's DAI

amountETH: 1000000000000000000

ether_address: my public address

aave_lendingpool_contract: '0x8dFf5E27EA6b7AC08EbFdf9eB090F32ee9a30fcf'

related part from the abi aave_lendingpool_abi comming from here :

    {
        "inputs": [
            {
                "internalType": "address",
                "name": "asset",
                "type": "address"
            },
            {
                "internalType": "uint256",
                "name": "amount",
                "type": "uint256"
            },
            {
                "internalType": "uint256",
                "name": "interestRateMode",
                "type": "uint256"
            },
            {
                "internalType": "uint16",
                "name": "referralCode",
                "type": "uint16"
            },
            {
                "internalType": "address",
                "name": "onBehalfOf",
                "type": "address"
            }
        ],
        "name": "borrow",
        "outputs": [],
        "stateMutability": "nonpayable",
        "type": "function"
    },

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.