-
Hello! I installed web3 successfully and when I wrote: Here is my code: from solcx import compile_standard, install_solc
import solcx
import json
from web3 import Web3
solcx.install_solc("0.8.7") # or whatever version we want
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.sourceMap"]}
}
},
},
solc_version="0.6.0",
)
# print(compiled_sol)
with open("compiled_code.json", "w") as file:
json.dump(compiled_sol, file)
# get bytecode
bytecode = compiled_sol["contracts"]["SimpleStorage.sol"]["SimpleStorage"]["evm"][
"bytecode"
]["object"]
# get abi
abi = json.loads(
compiled_sol["contracts"]["SimpleStorage.sol"]["SimpleStorage"]["metadata"]
)["output"]["abi"]
w3 = Web3(Web3.HTTPProvider("http://127.0.0.1:7545"))
chain_id = 5777
my_address = "0x3B7468eF9172d14001878C4181D846d3A1320f35"
private_key = "0x0a3667b39f3fed7a299c615063932f63c96395815e19177165820163ecf0994a"
SimpleStorage = w3.eth.contract(abi=abi, bytecode=bytecode)
print(SimpleStorage) The error message: |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Hello @HalaAura, in the line Best regards, Cromewar. |
Beta Was this translation helpful? Give feedback.
-
Thank you so much!! :) I edited it and now this is the output: |
Beta Was this translation helpful? Give feedback.
Hello @HalaAura, in the line
"sources": {"simpleStorage.sol": {"content": simple_storage_file}},
the line is SimpleStorage.sol with upper case.Best regards, Cromewar.