Invalid sender on signed transaction - Mumbai Polygon


I have the same smart contract deployed on mumbai as I do on ropsten to mint nfts, nothing too fancy. I then set up some python code with the web3 library to call the minting function. The code works properly when I test on ropsten but it fails when I try on mumbai. I have concerns about this failing on the polygon main net as well. I am using the proper chainId for each respective network. The error code I get when signing a transaction and sending the raw version is: {‘code’: -32000, ‘message’: ‘invalid sender’} . Do you know what could be going on?


the code looks something like what’s below

nonce = w3.eth.get_transaction_count(acct.address)
test = ''
tx_hash = contract_instance.functions.autoMint(acct.address, test).buildTransaction({
    'from': acct.address,
    'chainId': 80001, # mumbai
    #'chainId': 3, # ropsten
    'gas': int(1e6),
    'maxFeePerGas': w3.toWei('2', 'gwei'),
    'maxPriorityFeePerGas': w3.toWei('1', 'gwei'),
    'nonce': nonce

signed_txn = w3.eth.account.sign_transaction(tx_hash, private_key=acct.privateKey)
tx_sent = w3.eth.send_raw_transaction(signed_txn.rawTransaction)

Hello @Kyle_Pearson Welcome to the Infura community, can you try using the fee struct from before 1559?

Hi Lily, thanks for the suggestion! I was able to get it working on mumbai by changing my transaction to this:

tx_hash = contract_instance.functions.automint(acct.address, test).buildTransaction({
    'chainId': 0x13881, # mumbai
    #'chainId': 3, # ropsten
    'gasPrice': w3.toHex(w3.toWei('20', 'gwei')),
    'nonce': nonce,
    'from': acct.address
1 Like

Excellent, @Kyle_Pearson!

I’m glad you figured it out and thank you for sharing your solution with the community!