smartcontractkit / full-blockchain-solidity-course-py

Ultimate Solidity, Blockchain, and Smart Contract - Beginner to Expert Full Course | Python Edition
MIT License
10.8k stars 2.9k forks source link

Lesson 4: Invalid Syntax Error #1553

Open Akshat9999 opened 2 years ago

Akshat9999 commented 2 years ago

Hello Dear,

I hope you and your family are doing well.

Time of video 3:44:37 While deploying the code the following message is shown.

"sources":{"SimpleStorage.sol": {"content": simple_storage_file}}}, ^ SyntaxError: invalid syntax

Thank You

cromewar commented 2 years ago

Hello @Akshat9999 We will need more information on this, please give a look to #980 and reformulate. Anyway you may have a extra comma somewhere or a indentation error, but please share the entire code here ;)

Akshat9999 commented 2 years ago

Hello @Akshat9999 We will need more information on this, please give a look to #980 and reformulate. Anyway you may have a extra comma somewhere or a indentation error, but please share the entire code here ;)

Hello @cromewar, Thank you for your response. Here is the entire code as you suggested. I have directly reported the issue here because I didn't know what to do.


from solcx import compile_standard

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

#Compile our solidity
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)

and here is the output:-

File "C:\Users\sriva\demos\web3_py_simple_storage\deploy.py", line 10 "sources":{"SimpleStorage.sol": {"content": simple_storage_file}} ^ SyntaxError: invalid syntax

There is no Brownie involved here upto this point.

cromewar commented 2 years ago

For me seems to be a formatting error, do you have the auto-format on save option activate?

Akshat9999 commented 2 years ago

For me seems to be a formatting error, do you have the auto-format on save option activate?

No I will do it and share the result after that.

Akshat9999 commented 2 years ago

Hey Vasiliy, Thank you for such a quick response. I have activated the auto- format on save option and the same error is being displayed. What can be done now?

On Wed, Jun 22, 2022 at 8:28 PM Vasiliy Gualoto @.***> wrote:

For me seems to be a formatting error, do you have the auto-format on save option activate?

— Reply to this email directly, view it on GitHub https://github.com/smartcontractkit/full-blockchain-solidity-course-py/issues/1553#issuecomment-1163216690, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWC2TK7PLUF5HK3B7XOVSODVQMSX3ANCNFSM5ZMYFTGQ . You are receiving this because you were mentioned.Message ID: <smartcontractkit/full-blockchain-solidity-course-py/issues/1553/1163216690 @github.com>

cromewar commented 2 years ago

Sometimes python just freaks out, mostly without reason, just to verify, please delete that part of the code and replace it with this:

# Solidity source code
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.6.0",
)

Does it works?

Akshat9999 commented 2 years ago

Sometimes python just freaks out, mostly without reason, just to verify, please delete that part of the code and replace it with this:

# Solidity source code
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.6.0",
)

Does it works?

No dear it is still showing the same message.

File "C:\Users\sriva\demos\web3_py_simple_storage\deploy.py", line 10 "sources":{"SimpleStorage.sol": {"content": simple_storage_file}} ^ SyntaxError: invalid syntax