-1

I'm new to Solidity and Smart contracts stuff.

The code is taken from the repository provided by PatrickAlphaC under here

This is the code snippet I'm currently using.

from solcx import compile_standard, install_solc

install_solc("0.6.0")
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.bytecode.sourceMap"]
                }
            }
        },
    },
    solc_version="0.6.0",
)

I've tried different solcx versions and it still throws some error.

this is the error that I'm getting

PS C:\Users\hp\web3_py_simple_storage> python -u "c:\Users\hp\web3_py_simple_storage\deploy.py"
solc, the solidity compiler commandline interface
Version: 0.6.0+commit.26b70077.Windows.msvc
Traceback (most recent call last):
  File "c:\Users\hp\web3_py_simple_storage\deploy.py", line 7, in <module>
    compiled_sol = compile_standard(
                   ^^^^^^^^^^^^^^^^^
  File "C:\Users\hp\AppData\Local\Programs\Python\Python311\Lib\site-packages\solcx\main.py", line 158, in compile_standard
    stdoutdata, stderrdata, command, proc = solc_wrapper(
                                            ^^^^^^^^^^^^^
  File "C:\Users\hp\AppData\Local\Programs\Python\Python311\Lib\site-packages\solcx\utils\string.py", line 85, in 
inner
    return force_obj_to_text(fn(*args, **kwargs))
                             ^^^^^^^^^^^^^^^^^^^
TypeError: solc_wrapper() got an unexpected keyword argument 'solc_version'
PS C:\Users\hp\web3_py_simple_storage>

Can somebody help? The Maintainer on the GitHub page isn't responding.

TylerH
  • 20,799
  • 66
  • 75
  • 101

1 Answers1

0

try this:

from solcx import compile_standard, install_solc

install_solc("0.6.0")
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.bytecode.sourceMap"]
                }
            }
        },
    },
    version="0.6.0",
)

Walkthrough of my answer:

I am not familiar with solc package, however it seems that you are installing an old version of it install_solc("0.6.0"). So I went to the git of solcx and change the tag to the right version and found the function solc_wrapper link. I couldn't find any argument as solc_version but it seems that version is what the author meant.

Avizipi
  • 502
  • 6
  • 16