2

Help me, please!

I don't understand, why i can't do approve from my token contract. I do so always and this code worked. But now I've got error.

My code:

def approves(w3, token_contract, router_contract, my_account, my_pk):
    allowance_value = token_contract.functions.allowance(
        my_account, router_contract.address).call()
    print('allowance_value: ', allowance_value)
    if allowance_value <= 1000000000000000:
        approve_est_gas = token_contract.functions.approve(
            router_contract.address,
            100000000000000000000000
        ).estimateGas(
            {
                'from': my_account,
                'nonce': w3.eth.get_transaction_count(my_account)
            }
        )

        approve_tx_builder = token_contract.functions.approve(
            router_contract.address,
            100000000000000000000000
        ).buildTransaction(
            {
                'from': my_account,
                'nonce': w3.eth.get_transaction_count(my_account),
                'gas': approve_est_gas
            }
        )

        signed_tx = w3.eth.account.sign_transaction(approve_tx_builder, my_pk)
        tx_hash = w3.eth.send_raw_transaction(signed_tx.rawTransaction)
        print('tx_hash: ', tx_hash.hex())

I've got this mistake:

ValueError: {'code': -32601, 'message': 'the method eth_maxPriorityFeePerGas does not exist/is not available'}
Ivan
  • 303
  • 3
  • 13
  • looks like the ETH hard fork might have been changed in this update and you cannot use the method anymore. – Tamil Selvan Dec 09 '21 at 10:11
  • @TamilSelvan Thanks, I understood. I tried to execute this method with web3==5.24.0, and this method work, but i can't to do swap via router v2 does not matter. i received 'transfer from failed'. – Ivan Dec 09 '21 at 10:25
  • Does this answer your question? [ValueError: Method eth\_maxPriorityFeePerGas not supported, web3.py with ganache](https://stackoverflow.com/questions/70104101/valueerror-method-eth-maxpriorityfeepergas-not-supported-web3-py-with-ganache) – Rouhollah Joveini Feb 01 '22 at 08:41

0 Answers0