【问题标题】:ContractsNotFound: Input JSON does not contain any sourcesContractsNotFound:输入 JSON 不包含任何来源
【发布时间】:2022-07-26 01:38:58
【问题描述】:

我正在尝试在 VS Code 终端中运行它以获取 Solidity 教程。我的代码是否有错误,或者这可能是我的环境有问题?

代码:

from solcx import compile_standard, install_solc

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

    # Compile Our Solidity
    install_solc("0.6.0")
    compiled_sol = compile_standard(
        {
            "language": "solidity",
            "source": {"SimpleStorage.sol": {"content": simple_storage_file}},
            "settings": {
                "ouputSelection": {
                    "*": {"*": ["abi", "metadata", "evm.bytecode", "evm.sourceMap"]}
                }
            },
        },
        solc_version="0.6.0",
    )
print(compiled_sol)

错误:

  File "/Users/eddiebraddock/demos/web3_py_simple_storage/deploy.py", line 8, in <module>
    compiled_sol = compile_standard(
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/solcx/main.py", line 365, in compile_standard
    raise ContractsNotFound(
solcx.exceptions.ContractsNotFound: Input JSON does not contain any sources
> command: ``
> return code: `None`
> stdout:
None
> stderr:
None

【问题讨论】:

    标签: python blockchain solidity web3py


    【解决方案1】:

    输入 JSON 不包含任何来源

    这意味着sources 属性未定义。在“来源”中使用来源:

     "sources": {"SimpleStorage.sol": {"content": simple_storage_file}},
    

    另外,我不确定它是否会影响,但语言应该是大写的“Solidity”

    【讨论】:

      猜你喜欢
      • 2020-06-22
      • 1970-01-01
      • 2010-10-16
      • 2020-07-03
      • 1970-01-01
      • 1970-01-01
      • 2016-04-24
      • 2022-01-02
      • 1970-01-01
      相关资源
      最近更新 更多