-
Hello
from solcx import (
compile_standard,
install_solc,
) # <- pour compiler le code import the install_solc method
import json
from web3 import Web3
install_solc("0.6.0") # <- Add this line and run it at least once!
with open(
"./Simplestorage.sol", "r"
) as file: # On ouvre le ficheir simpleStorage, en mode read et nous l'apelon file
simple_storage_file = file.read() # On créer une variable pour lire le file
# 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)
with open("compiled_code.json", "w") as file:
json.dump(
compiled_sol, file
) # Prend le solcX compilé et le garde en json et créer le fichier compiled-code.json
# get ByteCode
bytecode = compiled_sol["contracts"]["SimpleStorage.sol"]["SimpleStorage"]["evm"][
"bytecode"
]["object"]
# get abi
abi = compiled_sol["contracts"]["SimpleStorage.sol"]["SimpleStorage"]["abi"]
# for connecting to ganache
w3 = Web3(Web3.HTPProvider("http://127.0.0.1:7545"))
chain_id = 5777
my_adress = "0x96A83923472C1122397BF3ce011451b4216f3D35"
private_key = "0xaea5901c2b8a15a661d3f8739edf89da16df93e7bfe7e8b47c9e0ceb130c1933"
# Create the contract in Python
SimpleStorage = w3.eth.contract(abi=abi, bytecode=bytecode)
print(SimpleStorage) And here you can chek my error message
|
Beta Was this translation helpful? Give feedback.
Answered by
cromewar
Jan 30, 2022
Replies: 1 comment
-
Hello @NinjaTurtles-cloud you have a typo: The correct form is HTTP no HTPP, give it a try ;) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
wilonweb
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello @NinjaTurtles-cloud you have a typo:
w3 = Web3(Web3.HTPProvider("http://127.0.0.1:7545")
The correct form is HTTP no HTPP, give it a try ;)