I couldn't get results when I write compiled code in Visual Studio Code, I run python deploy.py and it gives me error. what I have to edit in my code

Question:

I have just started coding and it seems that there is something missing in the code, this is a compiled code. the error message that it gives me after running python deploy.py
I checked it many times but still has the same error.

the code is from a lesson I am working on in this link:
https://github.com/PatrickAlphaC/web3_py_simple_storage
The code in this link: https://github.com/PatrickAlphaC/web3_py_simple_storage/blob/main/deploy.py

here’s the code and the error message, thank you so much in advance 🙂

Code:

from solcx import compile_standard

with open("SimpleStorage.sol", "r") as file:
    simple_storage_file = file.read()

compiled_sol = compile_standard(
    {
        "language": "solidity",
        "sources": {"simpleStorage.sol": {"content": simple_storage_file}},
        "settings": {
            "outputSelection": {
                "*": {"*": ["abi", "metadata", "evm.bytecode", "evm.sourceMap"]}
            }
        },
    },
    solc_version="0.6.0",
)

print(compiled_sol)

Error:

INFO: Could not find files for the given pattern(s).
Traceback (most recent call last):
  File "C:Usersuserweb3_py_simple_storagedeploy.py", line 8, in <module>
    compiled_sol = compile_standard(
  File "C:UsersuserAppDataLocalProgramsPythonPython310libsite-packagessolcxmain.py", line 394, in compile_standard
    raise SolcError(
solcx.exceptions.SolcError: Only "Solidity" or "Yul" is supported as a language.

command: `C:Usersuser.solcxsolc-v0.6.0solc.exe --standard-json`
return code: `0`
stdout:
{"errors":[{"component":"general","formattedMessage":"Only "Solidity" or "Yul" is supported as a language.","message":"Only "Solidity" or "Yul" is supported as a language.","severity":"error","type":"JSONError"}]}
Asked By: Hala Al-Zayat

||

Answers:

change "language": "solidity", to
"language": "Solidity",

Answered By: Amitosh Jain

You have two typos

compiled_sol=compile_standard({
    # not "solidity"
    "language":"Solidity",
    # not "simpleStorage"
    "sources":{"SimpleStorage.sol":{"content":simple_storage_file}},
    "settings":{
        "outputSelection":{
            "*":{
                "*":["abi","metadata","evm.bytecode","evm.sourceMap"]
            }
        }
    }
},
Answered By: Yilmaz

TRY THIS:


from solcx import compile_standard, install_solc

with open("./SimpleStorage.sol", "r") as file:
    simple_storage_file = file.read()

print("Installing...")
install_solc("0.6.0")


compiled_sol = compile_standard(
    {

        "language": "Solidity",
        "sources": {"SimpleStorage.sol": {"content": simple_storage_file}}, 
        "settings": {
            "outputSelection": {
                "*": {"*": ["abi", "metadeta", "evm.bytecode", "evm.sourceMap"]}
            }
        },
    },
    solc_version="0.6.0",
)
print(compiled_sol) 
Answered By: Ansa Zanjbeel