【发布时间】:2021-12-11 20:14:47
【问题描述】:
我刚开始编码,似乎代码中缺少某些内容,这是编译后的代码。运行 python deploy.py 后它给我的错误消息 我检查了很多次,但仍然有同样的错误。
代码来自我在此链接中正在学习的课程: https://github.com/PatrickAlphaC/web3_py_simple_storage 此链接中的代码:https://github.com/PatrickAlphaC/web3_py_simple_storage/blob/main/deploy.py
这是代码和错误消息,提前非常感谢您:)
代码:
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)
错误:
INFO: Could not find files for the given pattern(s).
Traceback (most recent call last):
File "C:\Users\user\web3_py_simple_storage\deploy.py", line 8, in <module>
compiled_sol = compile_standard(
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\solcx\main.py", line 394, in compile_standard
raise SolcError(
solcx.exceptions.SolcError: Only "Solidity" or "Yul" is supported as a language.
command: `C:\Users\user\.solcx\solc-v0.6.0\solc.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"}]}
【问题讨论】:
-
错误可能提示您必须使用字词
Solidity(上面是S)而不是solidity(下面是s) -
我读到了“如何提问”。谢谢,给克里斯带来的不便,我深表歉意。
-
furas,我在问题中添加了链接,并感谢您的 cmets 我不时编辑 Solidity(带有上 S)它给了我相同的错误消息。
-
在 json 中尝试
simpleStorage.sol->SimpleStorage.sol
标签: python blockchain ethereum solidity smartcontracts