Hi,
I am trying to approve the uniswap router to spend a certain amount of WETH. I have written a script that does this for me and it seems to work on the BSC (WBNB and PancakeSwap router).
However, now I try to do it on the Ethereum blockchain (WETH and Uniswap Router). This ends op giving me an error: {'code': -32601, 'message': 'Method not found'}
I have copied the abi from https://etherscan.io/address/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
UNISWAP_ROUTER = "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D"
WETH = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
web3 = Web3(HTTPProvider(PROVIDER))
token = web3.eth.contract(address=WETH, abi=abi)
nonce = web3.eth.get_transaction_count(WALLET_ADDRESS)
amount = web3.to_wei(0.01, 'ether')
block = web3.eth.get_block('latest')
next_gas_price = math.ceil(block.baseFeePerGas)
x = token.functions.approve(UNISWAP_ROUTER, amount).build_transaction({
"from": WALLET_ADDRESS,
"maxFeePerGas": next_gas_price,
"gas": 100_000,
"nonce": nonce
})
Thanks