0

I'm learning how to deploy a smart contract using a Python script and I keep getting the following error:

> py deploy.py

INFO: Could not find files for the given pattern(s).
Traceback (most recent call last):
  File "C:\Users\Lucas\Dropbox\Code\tutorials\blockchain\web3\deploy.py", line 10, in <module>
    compiled_sol = compile_standard(
  File "C:\Users\Lucas\AppData\Local\Programs\Python\Python39\lib\site-packages\solcx\main.py", line 391, in compile_standard
    raise SolcError(
solcx.exceptions.SolcError: Unknown key "*"
> command: `C:\Users\Lucas\.solcx\solc-v0.8.0\solc.exe --standard-json`
> return code: `0`
> stdout:
{"errors":[{"component":"general","formattedMessage":"Unknown key \"*\"","message":"Unknown key \"*\"","severity":"error","type":"JSONError"}]}

> stderr:

This is the script for deploy.py:

import solcx
from solcx import compile_standard
solcx.install_solc('0.8.0')

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

# compile solidity
compiled_sol = compile_standard(
    {
        'language': 'Solidity',
        'sources': {'SimpleStorage.sol': {'content': simple_storage_file}},
        'settings': {'*': {'*': ['abi', 'metadata', 'evm.bytecode', 'evm.sourceMap']}},
    },
    solc_version = '0.8.0'
)

print(compiled_sol)

I should probably mention that I'm following along a tutorial from freeCodeCamp on YouTube. Any help would be greatly appreciated, thank you!

1
  • What if you omit solcx.install_solc('0.8.0')? Sep 22 at 14:35
0

You need to fix your compile_standard call:

# compile solidity
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.8.0",
)

Refer to the course reference code here: https://github.com/PatrickAlphaC/web3_py_simple_storage/blob/main/deploy.py

2
  • Btw, I found this question by looking for a fix for the "INFO: Could not find files for the given pattern(s)." warning that's caused by the solcx import. If you know how to fix that please let me know.
    – blazeline
    Sep 22 at 18:09
  • I discovered that the INFO warning is caused by a call to 'where.exe solc' in the _get_which_solc function in the install.py of the solcx package. The code works despite that warning because it ends up using the solc that gets installed by the call to install_solc.
    – blazeline
    Sep 22 at 20:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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