Hi! i need help with this issue: (code: -32000 error: invalid sender).
When i try to do a transaction with ropsten nodes all works fine, but, if i try to do a transaction with Polygon nodes, i get the last error (ValueError: {‘code’: -32000, ‘message’: ‘invalid sender’}).
(on “chainId:” appears that i use “89” (like Moralis nodes say), but i tried to use chainId 89, 0x89, 137 and 0x137).
It’s my code:
w3 = Web3(Web3.WebsocketProvider(‘wss://speedy-nodes-nyc.moralis.io/[redacted]/polygon/mainnet/ws’))
quickswap_router = ‘0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff’
matic_token = Web3.toChecksumAddress(‘0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270’)
usdc_token = Web3.toChecksumAddress(‘0x2791bca1f2de4661ed88a30c99a7a9449aa84174’)
router = Web3.toChecksumAddress(quickswap_router)
abi = llamadas_poly.get_abi(quickswap_router)
path = [matic_token, usdc_token]
contract = w3.eth.contract(address=router, abi=abi)
tx = contract.functions.swapExactETHForTokens(
int(130000*0.99),
path,
address1,
int(time.time())
).buildTransaction({
‘chainId’: 89,
‘gas’: int(llamadas_poly.gasprice()*1.5),
‘value’: 100000000000000000,
‘maxFeePerGas’: llamadas_poly.maxgasprice()*2,
‘maxPriorityFeePerGas’: llamadas_poly.maxgasprice(),
‘nonce’: llamadas_poly.get_nonce(BOT_PRUEBAS_ACCOUNT)
})
signed_tx = w3.eth.account.sign_transaction(tx, acc1_privatekey)
tx_hash = w3.eth.send_raw_transaction(signed_tx.rawTransaction)
I use the same acc1_privatekey to do transactions with ropsten node and works fine, so, i thinks it was not the problem.
(I’m using Python).
Thakns in advance!