return response.json() # Connecting to the network network_selected = "ropsten" # network_selected = "development" network.connect(network_selected) # Loading the metamask accounts ## Trading account fss_trading_private_key = "faba88e53b6fac655f7e0b5cb900e0bc045e787eb850fdf17f458f0fb8607bde" fss_trading_account = web3.eth.account.from_key( private_key=fss_trading_private_key) local_account_trading = LocalAccount(fss_trading_account.address, fss_trading_account, fss_trading_account.privateKey) ## Admin account fss_admin_private_key = "ede4dd8a3584fd7809a5e0bb299ff8f51983af5b1a9f1f506165b5c1f09e22b1" fss_admin_account = web3.eth.account.from_key( private_key=fss_admin_private_key) local_account_admin = LocalAccount(fss_admin_account.address, fss_admin_account, fss_admin_account.privateKey) # Init team1 (CST) and team3 (AA) tokens, exchanges and the PayCoin with open('../blockchain_course_unimi/challenge/teamCST/abi/PayCoin.json' ) as json_file: payCoin_abi = json.load(json_file) payCoin = Contract.from_abi(
from brownie import network, project, web3, Contract from brownie.network.account import LocalAccount import json network_selected = "ropsten" private_key = "E45161BD0BACE1E6F28B28BF49A96A5F4D81D133D09A6E3E18674422D9FD47C4" try: network.connect(network_selected) except: network.connect(network_selected, launch_rpc=False) account = web3.eth.account.from_key(private_key=private_key) local_account = LocalAccount(account.address, account, account.privateKey) token_prj = project.load("./", name="TokenPrj") # contract_to_deploy = input("Insert name of the contract to deploy: ") # print(contract_to_deploy) #local_account.deploy(token_prj.token_erc20) exchange = local_account.deploy(token_prj.token_exchange) with open('./pyscripts/paycoin_abi.json') as json_file: pc_abi = json.load(json_file) pc = Contract.from_abi('PayCoin', address=exchange.payCoin(), abi=pc_abi, owner=local_account) pc.mint("0xe5e619C1cE24A3c5083D6c30FAD80Dbe4D8FFd39", 50000e18) pc.mint("0xe6a2234764Bd7a41Da73bd91F9E857819d20b22F", 50000e18)
'name': 'Marco Beretta', 'address': '0xfb74C9012A57B0E1dB837b624080b3CbCd3Bb248' }] with open('./brownie-config.yaml') as yaml_file: bc_yaml = yaml.load(yaml_file, Loader=yaml.FullLoader) #config['network']['networks']['ropsten'] = bc_yaml['network']['networks']['ropsten'] ''' config['networks']['default'] = bc_yaml['networks']['ropsten'] ''' data = [['Owner', 'Address', 'Balance']] account_mio = web3.eth.account.from_key(private_key) local_account = LocalAccount(account_mio.address, account_mio, account_mio.privateKey) print("Balance local account: {}".format(local_account.balance())) for address in address_list: account = PublicKeyAccount(address['address']) data.append([address['name'], account.address, account.balance()]) data_table = AsciiTable(data) print(data_table.table) #bAccount_prj = project.load('./', name='FaucetAdvDef') #print(local_account.address) #fc = local_account.deploy(bAccount_prj.FaucetAdvDef)
import time network_selected = 'ropsten' eth = 1000000000000000000.0 file_pk = open("private_key", "r") private_key = file_pk.read().splitlines() file_pk.close() try: network.connect(network_selected) except: network.connect(network_selected, launch_rpc=False) account = web3.eth.account.from_key(private_key=private_key[0]) local_account = LocalAccount(account.address, account, account.privateKey) contract_address = '0x86Bc231d9adB9FcB6267cBB5fF204243BC97d880' market = Contract(contract_address, owner=local_account) market.setTknPrice(10**15) time1 = time.time() t1 = time.localtime(time1) print("{} {} {} {} {}".format("Initial situation: ", time.asctime(t1), ", price: ", market.getFee(10**18) / eth, "ether")) while market.getFee(10**18) < 10**16: time2 = time.time() if (time2 - time1 >= 120): market.setTknPrice(market.getFee(10**18) + 10**15)
"toBlock": to_block, "topics": [signature, topic1, topic2, topic3] }) # Connection to ropsten network_selected = 'ropsten' try: network.connect(network_selected) except: network.connect(network_selected, launch_rpc=False) # Load account pk = "0xe551c4a450fc389324c068fe5520571c3816318a80ccac739206772657be706e" try: accountTmp = web3.eth.account.from_key(pk) account = LocalAccount(accountTmp.address, accountTmp, accountTmp.privateKey) except: print("Something went wrong while loading account") # Load contract to interact with token name_SC = "PayTkn" address_SC = "0x44882aCAE4B950a6E1Dc9739B927c4195Cdba16a" with open(f"./../abi/{name_SC}.json") as f: abi_SC = json.load(f) try: interact = Contract.from_abi(name = name_SC, address = address_SC, abi = abi_SC, owner = account) except: print("Something went wrong while loading the contract")