0
import json
from solcx import compile_standard, install_solc

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

print("Installing...")

install_solc('0.6.0')
compiled_sol = compile_standard(
    {
        "language": "Solidity",
        "sources": {"SimpleStorage.sol": {"content": simple_storage_file}},
        "settings": {
            "outputSelection": {
                "*": {
                    "*": ["abi", "metadata", "evm.bytecode", "evm.bytecode.sourceMap"]
                }
            }
        },
    },
    solc_version="v0.6.0",
)

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

Error message:

INFO: Could not find files for the given pattern(s).
Installing...
Traceback (most recent call last):
  File "C:\Users\mukhe\AppData\Local\Programs\Python\Python310\lib\site-packages\solcx\install.py", line 633, in _validate_installation
    installed_version = wrapper._get_solc_version(binary_path)
  File "C:\Users\mukhe\AppData\Local\Programs\Python\Python310\lib\site-packages\solcx\wrapper.py", line 17, in _get_solc_version    stdout_data = subprocess.check_output([str(solc_binary), "--version"], encoding="utf8")
  File "C:\Users\mukhe\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 420, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "C:\Users\mukhe\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 524, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['C:\\Users\\mukhe\\.solcx\\solc-v0.6.0\\solc.exe', '--version']' returned non-zero exit 
status 3221225595.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\mukhe\solidity\web3_py_simple_storage\deploy.py", line 14, in <module>
    install_solc("v0.6.0")
  File "C:\Users\mukhe\AppData\Local\Programs\Python\Python310\lib\site-packages\solcx\install.py", line 466, in install_solc    
    raise exc
  File "C:\Users\mukhe\AppData\Local\Programs\Python\Python310\lib\site-packages\solcx\install.py", line 459, in install_solc    
    _validate_installation(version, solcx_binary_path)
  File "C:\Users\mukhe\AppData\Local\Programs\Python\Python310\lib\site-packages\solcx\install.py", line 636, in _validate_installation
    raise SolcInstallationError(
solcx.exceptions.SolcInstallationError: Downloaded binary would not execute, or returned unexpected output.

1 Answer 1

0

I have deployed a solidity code on blockchain too, exactly like you. I think this example can help you.

https://github.com/amiralisahraei/Deploy_smart_contract_on_Rinkeby

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.