Method eth_signTransaction not supported(Solve)

Edit: Never mind I found the problem. It was the code I wrote that was wrong.

I am running into an error eth_signTransaction not supported which stops me from trying to make a transaction.
I was running this on VS code python web3.py.
So, I was following the freecampcode video on Solidity(The 16 hours).
How do I fix this
I followed as the video suggested and got stuck on when trying to use web3 with ganache(the user interface one, not the command prompt version).

Thank you in advance.
This is the code


w3 = Web3(Web3.HTTPProvider("http://127.0.0.1:8545"))
chain_id = 1337
my_address = "0x83C00C2cA9c05c448C5f88e28F5146Fc83d236bD"
private_key = os.getenv("PRIVATE_KEY")


# Create the contract in python
SimpleStorage = w3.eth.contract(abi=abi, bytecode=bytecode)
# Get the latest transaction
nonce = w3.eth.getTransactionCount(my_address)

# 1. Build a transaction
# 2. Sign a transaction
# 3. Send a transaction
transaction = SimpleStorage.constructor().buildTransaction(
    {
        "gasPrice": w3.eth.gas_price,
        "chainId": chain_id,
        "from": my_address,
        "nonce": nonce,
    }
)
#problem start here
sign_txn = w3.eth.sign_transaction(transaction, private_key)

tx_hash = w3.eth.send_raw_transaction(sign_txn)

This is the error message

PS C:\Users\ryan3\Documents\python\demos\web3_py_simple_storage> python deploy.py
INFO: Could not find files for the given pattern(s).
Traceback (most recent call last):
  File "C:\Users\ryan3\Documents\python\demos\web3_py_simple_storage\deploy.py", line 62, in <module>
    sign_txn = w3.eth.sign_transaction(transaction, private_key)
  File "C:\Users\ryan3\AppData\Local\Programs\Python\Python39\lib\site-packages\web3\module.py", line 57, in caller
    result = w3.manager.request_blocking(method_str,
  File "C:\Users\ryan3\AppData\Local\Programs\Python\Python39\lib\site-packages\web3\manager.py", 
line 198, in request_blocking
    return self.formatted_response(response,
  File "C:\Users\ryan3\AppData\Local\Programs\Python\Python39\lib\site-packages\web3\manager.py", 
line 171, in formatted_response
    raise ValueError(response["error"])
ValueError: {'message': 'Method eth_signTransaction not supported.', 'code': -32000, 'data': {'stack': 'Error: Method eth_signTransaction not supported.\n    at GethApiDouble.handleRequest (C:\\Program Files\\WindowsApps\\GanacheUI_2.5.4.0_x64__5dg5pnz03psnj\\app\\resources\\static\\node\\node_modules\\ganache-core\\lib\\subproviders\\geth_api_double.js:70:16)\n    at next (C:\\Program Files\\WindowsApps\\GanacheUI_2.5.4.0_x64__5dg5pnz03psnj\\app\\resources\\static\\node\\node_modules\\ganache-core\\node_modules\\web3-provider-engine\\index.js:136:18)\n    at GethDefaults.handleRequest (C:\\Program Files\\WindowsApps\\GanacheUI_2.5.4.0_x64__5dg5pnz03psnj\\app\\resources\\static\\node\\node_modules\\ganache-core\\lib\\subproviders\\gethdefaults.js:15:12)\n    at next (C:\\Program Files\\WindowsApps\\GanacheUI_2.5.4.0_x64__5dg5pnz03psnj\\app\\resources\\static\\node\\node_modules\\ganache-core\\node_modules\\web3-provider-engine\\index.js:136:18)\n    at SubscriptionSubprovider.FilterSubprovider.handleRequest (C:\\Program Files\\WindowsApps\\GanacheUI_2.5.4.0_x64__5dg5pnz03psnj\\app\\resources\\static\\node\\node_modules\\ganache-core\\node_modules\\web3-provider-engine\\subproviders\\filters.js:89:7)\n    at SubscriptionSubprovider.handleRequest (C:\\Program Files\\WindowsApps\\GanacheUI_2.5.4.0_x64__5dg5pnz03psnj\\app\\resources\\static\\node\\node_modules\\ganache-core\\node_modules\\web3-provider-engine\\subproviders\\subscriptions.js:137:49)\n    at next (C:\\Program Files\\WindowsApps\\GanacheUI_2.5.4.0_x64__5dg5pnz03psnj\\app\\resources\\static\\node\\node_modules\\ganache-core\\node_modules\\web3-provider-engine\\index.js:136:18)\n 
   at DelayedBlockFilter.handleRequest (C:\\Program Files\\WindowsApps\\GanacheUI_2.5.4.0_x64__5dg5pnz03psnj\\app\\resources\\static\\node\\node_modules\\ganache-core\\lib\\subproviders\\delayedblockfilter.js:31:3)\n    at next (C:\\Program Files\\WindowsApps\\GanacheUI_2.5.4.0_x64__5dg5pnz03psnj\\app\\resources\\static\\node\\node_modules\\ganache-core\\node_modules\\web3-provider-engine\\index.js:136:18)\n    at RequestFunnel.handleRequest (C:\\Program Files\\WindowsApps\\GanacheUI_2.5.4.0_x64__5dg5pnz03psnj\\app\\resources\\static\\node\\node_modules\\ganache-core\\lib\\subproviders\\requestfunnel.js:32:12)\n    at next (C:\\Program Files\\WindowsApps\\GanacheUI_2.5.4.0_x64__5dg5pnz03psnj\\app\\resources\\static\\node\\node_modules\\ganache-core\\node_modules\\web3-provider-engine\\index.js:136:18)\n    at Web3ProviderEngine._handleAsync (C:\\Program Files\\WindowsApps\\GanacheUI_2.5.4.0_x64__5dg5pnz03psnj\\app\\resources\\static\\node\\node_modules\\ganache-core\\node_modules\\web3-provider-engine\\index.js:123:3)\n    at Timeout._onTimeout (C:\\Program Files\\WindowsApps\\GanacheUI_2.5.4.0_x64__5dg5pnz03psnj\\app\\resources\\static\\node\\node_modules\\ganache-core\\node_modules\\web3-provider-engine\\index.js:107:12)\n    at listOnTimeout (internal/timers.js:531:17)\n    at processTimers (internal/timers.js:475:7)', 'name': 'Error'}}

Could you please try to use
w3.eth.account.sign_transaction(transaction, private_key)
instead of
w3.eth.sign_transaction(transaction, private_key)

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.