python solidity 编译器的语法问题

python sintax problem for solidity compilator

我在连接 python 时遇到问题。我想使用 python 编译 solidity 文件。但是出现错误。

    import json


from solcx import compile_standard, install_solc



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



# Solidity source code
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.9.0",
)

with open("compiled_code.json", "w") as file:
    json.dump(compiled_sol, file)

**第一个 python 出现错误,第二个确实很好 **

enter image description here

enter image description here

还没有 0.9.0 solc 版本。检查官方 releases 列表并使用可用的列表。如果你想使用最新的,修改你的代码为:

solc_version="0.8.13",