Closed RedArrow-Main closed 2 years ago
Solidity Version: 0.6.0 Python Version: Python 3.10.5
from solcx import compile_standard import solcx solcx.install_solc('0.6.0') import web3 import json with open("./simplestorage.sol" , "r") as file: simple_storage_file= file.read() 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", ) bytecode = compiled_sol["contracts"]["simplestorage.sol"]["simplestorage"]["evm"]["bytecode"]["object"] abi = json.loads(compiled_sol["contracts"]["simplestorage.sol"]["simplestorage"]["metadata"])["output"]["object"] w3 =web3(web3.HTTPProvider("HTTP://127.0.0.1:7545")) chain_id= 5777; my_address=0x7B2Cc4A701Ad26c7bC22a7D423CA476DA62866ae; private_key="ef257796f6688a92315f0b740a2c60d19d5f1676de5e14f8bd22b8c63f871a07"; simplestorage=w3.eth.contract(abi=abi , bytecode=bytecode) nonce = w3.eth.getTransactionCount(my_address) transaction=simplestorage.constructor().buildTransaction({ "chainId": chain_id, "gasPrice": w3.eth.gas_price, "from":my_address, "nonce":nonce, } ) #Sign the Transaction signed_txn= w3.eth.sign_transaction(transaction,private_key=private_key) print("Deploying Contract") #Send It tx_hash=w3.eth.send_raw_transaction(signed_txn.rawTransaction) # Wait for the transaction to be mined, and get the transaction receipt print("Waiting for transaction to finisj") txn_receipt = w3.eth.wait_for_transaction_receipt(tx_hash) print(f"Done! Contract deployed to {txn_receipt.contractAddress}") print(compiled_sol)
Can you ask this in the full repo?
https://github.com/smartcontractkit/full-blockchain-solidity-course-py
Solidity Version: 0.6.0 Python Version: Python 3.10.5