def transfercheck(ctx, _acct, _txhash): w3 = ctx['web3instance'] if 'transfercheck' not in ctx['deployedcontracts'][_acct.address].keys(): try: tx_receipt = w3.eth.waitForTransactionReceipt(_txhash, timeout=120) except: return False _from = tx_receipt['from'] _to = tx_receipt['to'] if _to != _acct.address: return False try: balance = w3.eth.getBalance(_acct.address) except: return False if balance < MINSTARTBALANCE: p.pln( p.in_fg_color( "contructor Balance Not Enough, Please Send More ETH...", r.red4)) update_user_deploy_contracts(ctx, _acct.address, 'transfercheck', _from) return True else: return True
def finish_deploy(ctx, _acct): if 'mintforuser' in ctx['deployedcontracts'][_acct.address].keys(): mintforuser_txhash = ctx['deployedcontracts'][_acct.address]['mintforuser'] Printer.ppln(DEPLOY_SUCCESS_CELEBRATION) return bytes.fromhex(mintforuser_txhash.split("0x")[1]) else: exit(0)
def run(ctx): token = input("[-]input your token: ") token = token.strip() try: data = validate_then_decrypt(token, AES_KEY, HMAC_KEY) except Exception as err: print("[!]bad token") sys.exit(0) if len(data) != 74: #print(Printer.in_fg_color("[-]wrong token", r.red4)) print("[!]wrong token") sys.exit(0) acct = validate_game_account(ctx, data) if not balancecheck(ctx, acct): print( "[!]game account balance not enough, should >={} ETH, please send more..." .format(est_gas / 10**18)) sys.exit(0) montagy_address = deployer.run(ctx, acct) # generate new token data = acct.address.encode() + acct.key + montagy_address.encode() new_token = encrypt_then_mac(data, AES_KEY, HMAC_KEY) Printer.ppln( Printer.in_fg_color("[+]new token: {}".format(new_token), r.white1)) Printer.ppln( "[+]Your goal is to empty the Montagy contract's ETH balance.")
def newPuzzle2(ctx, _contract, _p2bytes, _acct, _acc_nonce): #p.ppln("[*] calling newPuzzle2...") err, txhash = setNewPuzzle2(ctx, _contract, _p2bytes, _acct, _acc_nonce) if err: p.ppln(p.in_fg_color(("[!] " + str(err)), r.red5)) exit(0) else: return None, txhash.hex()
def register2(ctx, _contract, _bytecode, _acct, _acc_nonce): #p.ppln("[*] calling registerCode2...") err, txhash = registerCode2(ctx, _contract, _bytecode, _acct, _acc_nonce) if err: p.ppln(p.in_fg_color(("[!] " + str(err)), r.red5)) exit(0) else: return None, txhash.hex()
def check_if_has_topic(ctx, _acct, montagy_addr): acc_nonce = get_acc_nonce(ctx, _acct) err, balance = balanceofflagtoken(ctx, montagy_addr, _acct, acc_nonce) if err: p.pln(p.in_fg_color(str(err), r.red4)) if balance == TOPIC: return True else: return False
def check_if_has_topic(ctx, _acct): acc_nonce = get_acc_nonce(ctx, _acct) flagtoken_addr = ctx['deployedcontracts'][_acct.address]['flagtoken'] gamer_account = ctx['deployedcontracts'][_acct.address]['transfercheck'] err, balance = balanceofflagtoken(ctx, flagtoken_addr, gamer_account, _acct, acc_nonce) if err: p.pln(p.in_fg_color(str(err), r.red4)) if (TOPIC < balance or TOPIC == balance) and balance < ONEHUNDRED: return True else: return False
def run(ctx): token = input("[-]input your token: ") token = token.strip() data = validate_then_decrypt(token, AES_KEY, HMAC_KEY) if len(data) != 74: print(Printer.in_fg_color("[+]wrong token", r.red4)) sys.exit(0) acct = validate_game_account(ctx, data) if not is_account_exist(ctx, acct.address): print(Printer.in_fg_color("[+]wrong token", r.red4)) sys.exit(0) transfer_txhash = input( "[-]input your transaction hash of transfer enough ETH to deployer: ") if not transfercheck(ctx, acct, transfer_txhash): print(Printer.in_fg_color("[+]wrong transaction hash", r.red4)) sys.exit(0) tx_hash = deployer.run(ctx, acct) # generate new token data = acct.address.encode() + acct.key + tx_hash new_token = encrypt_then_mac(data, AES_KEY, HMAC_KEY) Printer.ppln( Printer.in_fg_color("[+]new token: {}".format(new_token), r.white1)) Printer.ppln("[+]Your goal is to convert 1wei Chaitin into 80 Flag")
def newPuzzle1_review(ctx, _acct, _txhash): w3 = ctx['web3instance'] p.ppln("[*] Checking for newPuzzle1 status... ") try: tx_receipt = w3.eth.waitForTransactionReceipt(_txhash, timeout=720) except Exception as err: p.ppln(str(err)) exit(0) addr = tx_receipt['transactionHash'].hex() if not addr: p.pln(p.in_fg_color("[!] newPuzzle1 Broken down", r.red5)) else: p.ppln("[+] newPuzzle1 " + p.in_fg_color("success", r.green1) + " transaction hash: " + p.in_fg_color(addr, r.blue1))
def deploy(ctx, _acct, _acc_nonce): if 'chaitintoken' not in ctx['deployedcontracts'][_acct.address].keys(): p.ppln("[-] try to deploy chaitintoken contracts...") abi = ctx['compiledcontracts']['chaitintoken']['abi'] bin = ctx['compiledcontracts']['chaitintoken']['bin'] w3 = ctx['web3instance'] err, txhash = chaitintoken(w3, abi, bin, _acct, _acc_nonce) if err: p.ppln(p.in_fg_color(("[!] " + str(err)), r.red5)) exit(0) else: return None, txhash else: txhash = ctx['deployedcontracts'][_acct.address]['chaitintoken'] return None, txhash
def mint(ctx, _contract, _to_address, _amount, _acct, _acc_nonce): if 'mintflagtoken' not in ctx['deployedcontracts'][_acct.address].keys(): p.ppln("[-] try to mintflagtoken to deployer...") err, txhash = mintflagtoken(ctx, _contract, _to_address, _amount, _acct, _acc_nonce) if err: p.ppln(p.in_fg_color(("[!] " + str(err)), r.red5)) exit(0) else: update_user_deploy_contracts(ctx, _acct.address, 'mintflagtoken', txhash.hex()) return None, txhash.hex() else: txhash = ctx['deployedcontracts'][_acct.address]['mintflagtoken'] return None, txhash
def deploy(ctx, _acct, _acc_nonce): #p.ppln("[*] trying to deploy montagy contracts...") abi = ctx['compiledcontracts']['montagy']['abi'] bin = ctx['compiledcontracts']['montagy']['bin'] w3 = ctx['web3instance'] bin = re.sub('a265627a7a72315820.{64}64736f6c634300050b0032', 'a265627a7a72315820' + randhex(64) + '64736f6c634300050b0032', bin) #bin.repalce("627a7a72315820f044b77d8376499313d5239e6881baadb3dec8e7f36eca97638fed329186930964736f6c634300050b0032","627a7a" + ''.join(random.sample(string.hexdigits, 10)).lower()*9 + "0032") err, txhash = montagy(w3, abi, bin, _acct, _acc_nonce) if err: p.ppln(p.in_fg_color(("[!] " + str(err)), r.red5)) exit(0) else: return None, txhash
def addliquidity(ctx, _contract, _tokenA, _tokenB, _amountA, _amountB, _to_address, _acct, _acc_nonce): if 'addliquiditychaitinrouter' not in ctx['deployedcontracts'][ _acct.address].keys(): p.ppln("[-] try to addliquiditychaitinrouter to deployer...") err, txhash = addliquiditychaitinrouter(ctx, _contract, _to_address, _tokenA, _tokenB, _amountA, _amountB, _acct, _acc_nonce) if err: p.ppln(p.in_fg_color(("[!] " + str(err)), r.red5)) exit(0) else: update_user_deploy_contracts(ctx, _acct.address, 'addliquiditychaitinrouter', txhash.hex()) return None, txhash.hex() else: txhash = ctx['deployedcontracts'][ _acct.address]['addliquiditychaitinrouter'] return None, txhash
def review(ctx, _acct, _txhash): w3 = ctx['web3instance'] #p.ppln("[*] checking deployment statue... ") try: tx_receipt = w3.eth.waitForTransactionReceipt(_txhash, timeout=720) except Exception as err: p.p(str(err)) exit(0) addr = tx_receipt['contractAddress'] if not addr: p.pln(p.in_fg_color("[!] contract montagy deploy Broken down", r.red5)) exit(0) else: p.ppln("[+] contract Montagy deploy " + p.in_fg_color("success", r.green1) + ", address: " + p.in_fg_color(addr, r.blue1)) return addr
def approveflagtoken(ctx, _contract, _to, _amount, _from, _acc_nonce): w3 = ctx['web3instance'] store_var_contract = w3.eth.contract( address=_contract, abi=ctx['compiledcontracts']['flagtoken']['abi']) p.ppln(" approve transaction init success") construct_tx = store_var_contract.functions.approve( _to, _amount).buildTransaction({ 'chainId': 3, 'from': _from.address, 'nonce': _acc_nonce[0], 'gasPrice': 60000000000, 'gas': 3000000 #'value': w3.toWei(value, 'ether'), }) p.ppln(" approve transaction build success") try: signed_tx = _from.signTransaction(construct_tx) tx_hash = w3.eth.sendRawTransaction(signed_tx.rawTransaction) _acc_nonce[0] += 1 p.ppln(" approve transaction send success") except Exception as err: return err, None return None, tx_hash
def addliquidity_review(ctx, _acct, _txhash): w3 = ctx['web3instance'] p.ppln("[-] Check for addliquiditychaitinrouter successful... ") try: tx_receipt = w3.eth.waitForTransactionReceipt(_txhash, timeout=720) except Exception as err: p.ppln(str(err)) exit(0) addr = tx_receipt['transactionHash'].hex() if not addr: p.pln( p.in_fg_color("[!] addliquiditychaitinrouter Broken down", r.red5)) else: p.ppln("[+] addliquiditychaitinrouter " + p.in_fg_color("success", r.green1)) p.ppln("[!] addliquiditychaitinrouter transaction hash is " + p.in_fg_color(addr, r.blue1))
def review(ctx, _acct, _txhash): w3 = ctx['web3instance'] p.ppln("[-] Check for chaitintoken contract successful deployment... ") if 'chaitintoken' not in ctx['deployedcontracts'][_acct.address].keys(): try: tx_receipt = w3.eth.waitForTransactionReceipt(_txhash, timeout=720) except Exception as err: p.p(str(err)) exit(0) addr = tx_receipt['contractAddress'] update_user_deploy_contracts(ctx, _acct.address, 'chaitintoken', addr) else: addr = ctx['deployedcontracts'][_acct.address]['chaitintoken'] if not addr: p.pln( p.in_fg_color("[!] contract chaitintoken deploy Broken down", r.red5)) else: p.ppln("[+] contract chaitintoken deploy " + p.in_fg_color("success", r.green1)) p.ppln("[!] chaitintoken contract address is " + p.in_fg_color(addr, r.blue1))
def allpairs(ctx, _contract, _acct): if 'allpairschaitinfactory' not in ctx['deployedcontracts'][ _acct.address].keys(): p.ppln("[-] try to allpairschaitinfactory...") err, pair_addr = allpairschaitinfactory(ctx, _contract, _acct) if err: p.ppln(p.in_fg_color(("[!] " + str(err)), r.red5)) exit(0) else: update_user_deploy_contracts(ctx, _acct.address, 'allpairschaitinfactory', pair_addr) p.ppln("[+] allpairschaitinfactory " + p.in_fg_color("success", r.green1)) p.ppln("[!] chaitinToken-feiToken pair address is: " + p.in_fg_color(pair_addr, r.blue1)) return None, pair_addr else: pair_addr = ctx['deployedcontracts'][ _acct.address]['allpairschaitinfactory'] p.ppln("[!] chaitinToken-feiToken pair address is: " + p.in_fg_color(pair_addr, r.blue1)) return None, pair_addr
def run(ctx, _acct): p = Printer() processor = Processor(40) formator = Formator() #p.ppln(formator.in_all_left("[-] loading deploy cache...")) #p.ppln("[*] loading deploy cache...") ctx = comp(ctx) processor.update(3) acc_nonce = get_acc_nonce(ctx, _acct) processor.update(2) # 1 stage contracts deploy err, montagy_deploy_txhash = Montagy.deploy(ctx, _acct, acc_nonce) processor.update(5) montage_address = Montagy.review(ctx, _acct, montagy_deploy_txhash) processor.update(5) # 2 stage P1 P2 deploy # input_p1code = "00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000740608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506106e0806100606000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c806319ff1d211461005c5780635d831619146100df5780637b76ac911461016c57806381a20b0a1461018a578063fd922a421461040a575b600080fd5b610064610454565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100a4578082015181840152602081019050610089565b50505050905090810190601f1680156100d15780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61015260048036036101008110156100f657600080fd5b810190808035906020019092919080359060200190929190803590602001909291908035906020019092919080359060200190929190803590602001909291908035906020019092919080359060200190929190505050610491565b604051808215151515815260200191505060405180910390f35b6101746104c1565b6040518082815260200191505060405180910390f35b610408600480360360808110156101a057600080fd5b81019080803590602001906401000000008111156101bd57600080fd5b8201836020820111156101cf57600080fd5b803590602001918460018302840111640100000000831117156101f157600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192908035906020019064010000000081111561025457600080fd5b82018360208201111561026657600080fd5b8035906020019184600183028401116401000000008311171561028857600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290803590602001906401000000008111156102eb57600080fd5b8201836020820111156102fd57600080fd5b8035906020019184600183028401116401000000008311171561031f57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192908035906020019064010000000081111561038257600080fd5b82018360208201111561039457600080fd5b803590602001918460018302840111640100000000831117156103b657600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192905050506104c9565b005b610412610686565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b60606040518060400160405280601081526020017f526561645772697465436154466c616700000000000000000000000000000000815250905090565b600062726365828486181886888a168b8d1818181710156104b157600080fd5b6001905098975050505050505050565b600080905090565b671234567890abcdef60c01b77ffffffffffffffffffffffffffffffffffffffffffffffff191683805190602001208580519060200120161461050b57600080fd5b67abcdef123456789060c01b77ffffffffffffffffffffffffffffffffffffffffffffffff191682805190602001208480519060200120181461054d57600080fd5b67a1b2c3d4e5f6098760c01b77ffffffffffffffffffffffffffffffffffffffffffffffff191682805190602001208580519060200120171461058f57600080fd5b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166376fe1e92826040518263ffffffff1660e01b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561061c578082015181840152602081019050610601565b50505050905090810190601f1680156106495780820380516001836020036101000a031916815260200191505b5092505050600060405180830381600087803b15801561066857600080fd5b505af115801561067c573d6000803e3d6000fd5b5050505050505050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff168156fea265627a7a723158206302876a93a2f8c254feea0484f042ce2eeea0380fd5fca199b197d71e2e656e64736f6c634300050b0032" # input_p1code = re.sub('a265627a7a72305820.{64}64736f6c634300050b0032', 'a265627a7a72305820'+randhex(64)+'64736f6c634300050b0032', input_p1code) #input_p1code.repalce("627a7a723158206302876a93a2f8c254feea0484f042ce2eeea0380fd5fca199b197d71e2e656e64736f6c634300050b0032", "627a7a" + ''.join(random.sample(string.hexdigits, 10)).lower()*9 + "0032") input_p2code = "000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000005a2608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610542806100606000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c806304f77cfa146100515780634059e88714610073578063fd922a42146101c5578063ffa644851461020f575b600080fd5b61005961028e565b604051808215151515815260200191505060405180910390f35b6101c36004803603604081101561008957600080fd5b81019080803590602001906401000000008111156100a657600080fd5b8201836020820111156100b857600080fd5b803590602001918460018302840111640100000000831117156100da57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192908035906020019064010000000081111561013d57600080fd5b82018360208201111561014f57600080fd5b8035906020019184600183028401116401000000008311171561017157600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050610362565b005b6101cd61049e565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61028c600480360361012081101561022657600080fd5b810190808035906020019092919080359060200190929190803590602001909291908035906020019092919080359060200190929190803590602001909291908035906020019092919080359060200190929190803590602001909291905050506104c3565b005b6000806009546008546007541818600654600554600454181860035460025460015418180101905060006009546006546003540101600854600554600254010160075460045460015401011818905063aabbccdd818301106102ef57600080fd5b708261e26b90505061031256e5afb60721cb821161030c57600080fd5b8082027ef35b6080614321368282376084810151606401816080016143855161051756101561033a57600080fd5b6f65e670d9bd540cea22fdab97e36840e2818303101561035957600080fd5b60019250505090565b61036a61028e565b61037357600080fd5b716111d850336107ef16565b908018915a905660701b6dffffffffffffffffffffffffffff19168280519060200120141561049a576000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166376fe1e92826040518263ffffffff1660e01b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561043557808201518184015260208101905061041a565b50505050905090810190601f1680156104625780820380516001836020036101000a031916815260200191505b5092505050600060405180830381600087803b15801561048157600080fd5b505af1158015610495573d6000803e3d6000fd5b505050505b5050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b88600181905550876002819055508660038190555085600481905550846005819055508360068190555082600781905550816008819055508060098190555050505050505050505056fea265627a7a723158205b60025b8060051461049a57818160041b1c61ffff16919060010161051a564d64736f6c634300050b0032" #000000000000000000000000000000000000000000000000000000000000 input_p2code = re.sub( 'a265627a7a723158205b60025b8060051461049a57818160041b1c61ffff16919060010161051a56.{2}64736f6c6343.{6}0032', 'a265627a7a723158205b60025b8060051461049a57818160041b1c61ffff16919060010161051a56' + randhex(2) + '64736f6c6343' + randhex(6) + '0032', input_p2code) #input_p2code.repalce("627a7a723158205b60025b8060051461049a57818160041b1c61ffff16919060010161051a564d64736f6c634300050b0032", "627a7a" + ''.join(random.sample(string.hexdigits, 10)).lower()*9 + "0032") #input_3_startGame = "0000000000000000000000000000000000000000000000000000000000000001" #err, p1_deploy_txhash = IMontagy.register1(ctx, montage_address, input_p1code, _acct, acc_nonce) #processor.update(5) err, p2_deploy_txhash = IMontagy.register2(ctx, montage_address, input_p2code, _acct, acc_nonce) processor.update(5) #IMontagy.register1_review(ctx, _acct, p1_deploy_txhash) #processor.update(5) IMontagy.register2_review(ctx, _acct, p2_deploy_txhash) processor.update(5) # 3 stage New Puzzle ''' err, newpuzzle1_txhash = IMontagy.newPuzzle1(ctx, montage_address, input_p1code, _acct, acc_nonce) processor.update(5) IMontagy.newPuzzle1_review(ctx, _acct, newpuzzle1_txhash) processor.update(5) p1_address = IMontagy.getPAddress(ctx, montage_address, acc_nonce) processor.update(5) ''' err, newpuzzle2_txhash = IMontagy.newPuzzle2(ctx, montage_address, input_p2code, _acct, acc_nonce) processor.update(5) IMontagy.newPuzzle2_review(ctx, _acct, newpuzzle2_txhash) processor.update(5) p2_address = IMontagy.getPAddress(ctx, montage_address, acc_nonce) processor.update(5) # finish deployer return finish_deploy(montage_address)
def finish_deploy(montage_address): Printer.ppln(DEPLOY_SUCCESS_CELEBRATION) #return bytes.fromhex(montage_address.split("0x")[1]) return montage_address.split("0x")[1]
from src.utils.prettyprint.Red import Printer, Formator _p = Printer() _f = Formator() deploy_panic_imp_info = "人们不能预见、不可避免、不能克服的自然、社会现象客观情况。社会及自然现象包括但不限于天灾人祸如地震、战争、市政工程建设、其它政府政策或矿工不给你打包交易" MENU = ''' We design a pretty easy contract game. Enjoy it! 1. Create a game account 2. Deploy a game contract 3. Request for flag Game environment: ropsten testnet Option 1, get an account which will be used to deploy the contract; Before option 2, please transfer some eth to this account (for gas); Option 2, the robot will use the account to deploy the contract for the problem; Option 3, use this option to obtain the flag after the event is triggered. You can finish this challenge in a lot of connections. ''' WELCOME = _f.in_column_center(_p.in_fg_color('.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.\r', 40))+\ _f.in_column_center(_p.in_fg_color('.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.\n', 40))+\ _f.in_column_center(_p.in_fg_color('( Welcome to EasyDefi! )\n', 41))+\ _f.in_column_center(_p.in_fg_color(' )we will give you 1 wei Chaitin token, (\n', 42))+\ _f.in_column_center(_p.in_fg_color('( And you need to exchange it for 80 FlagTokens )\n', 43))+\ _f.in_column_center(_p.in_fg_color('"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"\n', 44)) SRC_TEXT = ''' https://github.com/PandaTea/NightCity-backup '''
def run(ctx): new_token = input("[-]input your new token: ") new_token = new_token.strip() try: data = validate_then_decrypt(new_token, AES_KEY, HMAC_KEY) except Exception as err: print("[!]bad token") sys.exit(0) if len(data) != 114: print("[!]wrong token") sys.exit(0) data, msg = data[:-40], data[-40:] acct = validate_game_account(ctx, data) res = check_if_has_topic(ctx, acct, "0x" + msg.decode()) if res: flag = getflag() p.ppln(p.in_fg_color("[+] Congratulation! Here's the flag:", white1)) p.ppln(p.in_fg_color(flag, red1)) else: p.ppln( p.in_fg_color("[!] It seems that you didn't solve the puzzle.", white1)) p.ppln( p.in_fg_color( "[!] Note that it may take time for ethereum to update, so please try 1 min latter if you feel necessary.", white1)) #mov2(PANIC_INFO, SORRY_INFO, sz_col, sz_row)
def run(ctx, _acct): p = Printer() processor = Processor(150) formator = Formator() p.ppln(formator.in_all_left("[-] loading deploy cache...")) ctx = comp(ctx) processor.update(3) acc_nonce = get_acc_nonce(ctx, _acct) processor.update(2) # 1 stage contracts deploy err, chaitintoken_deploy_txhash = ChaitinToken.deploy(ctx, _acct, acc_nonce) processor.update(5) err, feitoken_deploy_txhash = FeiToken.deploy(ctx, _acct, acc_nonce) processor.update(5) err, flagtoken_deploy_txhash = FlagToken.deploy(ctx, _acct, acc_nonce) processor.update(5) err, weth9_deploy_txhash = WETH9.deploy(ctx, _acct, acc_nonce) processor.update(5) err, factory_deploy_txhash = Factory.deploy(ctx, _acct, acc_nonce) processor.update(5) ChaitinToken.review(ctx, _acct, chaitintoken_deploy_txhash) processor.update(5) FeiToken.review(ctx, _acct, feitoken_deploy_txhash) processor.update(5) FlagToken.review(ctx, _acct, flagtoken_deploy_txhash) processor.update(5) WETH9.review(ctx, _acct, weth9_deploy_txhash) processor.update(5) Factory.review(ctx, _acct, factory_deploy_txhash) processor.update(5) # 2 stage contracts deploy factory_addr = ctx['deployedcontracts'][_acct.address]['chaitinfactory'] weth9_addr = ctx['deployedcontracts'][_acct.address]['weth9'] chaitintoken_addr = ctx['deployedcontracts'][_acct.address]['chaitintoken'] err, router_deploy_txhash = Router.deploy(ctx, _acct, acc_nonce, factory_addr, weth9_addr, chaitintoken_addr) processor.update(5) Router.review(ctx, _acct, router_deploy_txhash) processor.update(5) # 3 stage mint approve and add liquidity chaitinrouter_addr = ctx['deployedcontracts'][_acct.address]['chaitinrouter'] err, chaitintoken_mint_txhash = IChaitinToken.mint(ctx, chaitintoken_addr, _acct.address, ONEHUNDRED, _acct, acc_nonce) processor.update(5) err, chaitintoken_approve_txhash = IChaitinToken.approve(ctx, chaitintoken_addr, chaitinrouter_addr, ONEHUNDRED, _acct, acc_nonce) processor.update(5) IChaitinToken.mint_review(ctx, _acct, chaitintoken_mint_txhash) processor.update(5) IChaitinToken.approve_review(ctx, _acct, chaitintoken_approve_txhash) processor.update(5) feitoken_addr = ctx['deployedcontracts'][_acct.address]['feitoken'] err, feitoken_mint_txhash = IFeiToken.mint(ctx, feitoken_addr, _acct.address, ONEHUNDRED, _acct, acc_nonce) processor.update(5) err, feitoken_approve_txhash = IFeiToken.approve(ctx, feitoken_addr, chaitinrouter_addr, ONEHUNDRED, _acct, acc_nonce) processor.update(5) IFeiToken.mint_review(ctx, _acct, feitoken_mint_txhash) processor.update(5) IFeiToken.approve_review(ctx, _acct, feitoken_approve_txhash) processor.update(5) err, chaitinrouter_addliquidity_txhash = IChaitinRouter.addliquidity(ctx, chaitinrouter_addr, chaitintoken_addr, feitoken_addr, ONEHUNDRED, ONEHUNDRED, _acct.address, _acct, acc_nonce) processor.update(5) IChaitinRouter.addliquidity_review(ctx, _acct, chaitinrouter_addliquidity_txhash) processor.update(5) # 4 stage get pair and deploy bank flagtoken_addr = ctx['deployedcontracts'][_acct.address]['flagtoken'] err, pair_addr = IChaitinFactory.allpairs(ctx, factory_addr, _acct) processor.update(5) err, bank_deploy_txhash = ChaitinBank.deploy(ctx, feitoken_addr, _acct.address, flagtoken_addr, pair_addr, chaitinrouter_addr, _acct, acc_nonce) processor.update(5) ChaitinBank.review(ctx, _acct, bank_deploy_txhash) processor.update(5) # 5 stage Mint Flag to ChaitinBank chaitinbank_addr = ctx['deployedcontracts'][_acct.address]['chaitinbank'] err, flagtoken_mint_txhash = IFlagToken.mint(ctx, flagtoken_addr, chaitinbank_addr, ONEHUNDRED, _acct, acc_nonce) processor.update(5) IFlagToken.mint_review(ctx, _acct, flagtoken_mint_txhash) processor.update(5) # 6 stage get Gamer address and Mint ChaitinToken to him gamer_address = ctx['deployedcontracts'][_acct.address]['transfercheck'] err, gamer_mint_txhash = IChaitinToken.mintforuser(ctx, chaitintoken_addr, gamer_address, 1, _acct, acc_nonce) processor.update(5) IChaitinToken.mintforuser_review(ctx, _acct, gamer_mint_txhash) processor.update(5) # finish deployer return finish_deploy(ctx, _acct)