使用python3编译并部署solidity合约

我c了,Mac配置半天一直报错,windows随便配置就ok

Os:Windows
PythonVersion:3.9.8(python3.10会报错,建议不要使用python3.10)

1.安装py-solc

pip3 install py-solc

 注释solc源码中 clone-bin,否则会报错

Traceback (most recent call last):
  File "C:\Users\Administrator\Desktop\dev\main.py", line 4, in <module>
    a = compile_files(sol_file)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\solc\main.py", line 135, in compile_files
    stdoutdata, stderrdata, command, proc = solc_wrapper(**compiler_kwargs)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\solc\utils\string.py", line 85, in inner
    return force_obj_to_text(fn(*args, **kwargs))
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\solc\wrapper.py", line 164, in solc_wrapper
    raise SolcError(
solc.exceptions.SolcError: An error occurred during execution
> command: `solc --combined-json abi,asm,ast,bin,bin-runtime,clone-bin,devdoc,interface,opcodes,userdoc hello.sol`
> return code: `1`
> stderr:

> stdout:
Invalid option to --combined-json: clone-bin

2.下载solc文件,并且放在项目文件夹下,或者增加环境变量(或者丢到system32)

 

Python Code

参考资料:

GitHub - ethereum/py-solc: Python wrapper around the solc Solidity compiler.

猜你喜欢

转载自blog.csdn.net/claysystem/article/details/125551239