Last active
August 27, 2022 22:03
-
-
Save numanturle/2363d4d9ed6792f7a9d9e1693b4412fd to your computer and use it in GitHub Desktop.
solve-paradigm.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from solcx import compile_source | |
from web3 import Web3 | |
setup_txt = open("Setup.sol", "r").read() | |
setup_compiled_source = compile_source(setup_txt, output_values=['abi']) | |
setup_abi = list(setup_compiled_source.items())[0][1]['abi'] | |
random_txt = open("Random.sol", "r").read() | |
random_compiled_source = compile_source(random_txt, output_values=['abi']) | |
random_abi = list(random_compiled_source.items())[0][1]['abi'] | |
rpc_endpoint = 'http://34.66.135.107:8545/74e8ff9f-8a07-4c8b-af6e-88c8dc2b8a54' | |
private_key = "0x5e2960941eb6c4dccf415c8334451597b96a9e8a21f6352c654d7bd9903f3abf" | |
w3 = Web3(Web3.HTTPProvider(rpc_endpoint)) | |
account = w3.eth.account.privateKeyToAccount(private_key) | |
from_address = account.address | |
setup_address = "0x3203c55ffF1a20585281fcD67a6dd075e9DaAfbe" | |
UUID = '74e8ff9f-8a07-4c8b-af6e-88c8dc2b8a54' | |
print("Connection status:", w3.isConnected()) | |
solv = w3.eth.contract(address=setup_address, abi=setup_abi) | |
random_address = solv.functions.random().call() | |
solv2 = w3.eth.contract(address=random_address, abi=random_abi) | |
transaction_hash = solv2.functions.solve(4).transact() | |
receipt = w3.eth.wait_for_transaction_receipt(transaction_hash) | |
print(receipt) | |
print() | |
print("Check if solved") | |
print(solv.functions.isSolved().call()) | |
transaction_hash = solv.functions.isSolved().transact() | |
receipt = w3.eth.wait_for_transaction_receipt(transaction_hash) | |
print(receipt) | |
print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment