def check_founders(smy_token_address=None, founders=None): i = 0 isFundedList = [] for founder in founders: samy_contract_instance = w3.eth.contract(smy_token_address, abi=samy_contract_interface['abi']) founder_contract_instance = w3.eth.contract(founder['address'], abi=founder_contract_interface['abi']) start = founder_contract_instance.functions.start().call() start_date = datetime.fromtimestamp(float(start)).strftime('UTC-%Y-%m-%dT%H-%M-%S.%fZ') cliff = founder_contract_instance.functions.cliff().call() cliff_date = datetime.fromtimestamp(float(cliff)).strftime('UTC-%Y-%m-%dT%H-%M-%S.%fZ') duration = founder_contract_instance.functions.duration().call() + start end_date = datetime.fromtimestamp(float(duration)).strftime('UTC-%Y-%m-%dT%H-%M-%S.%fZ') print('Current Datetime: %s' % datetime.fromtimestamp(float(time.time())).strftime('UTC-%Y-%m-%dT%H-%M-%S.%fZ')) print('Founder %s Contract Vesting Start Datetime: %s' % (founder['name'], start_date)) print('Founder %s Contract Vesting Cliff Datetime: %s' % (founder['name'], cliff_date)) print('Founder %s Contract Vesting End Datetime: %s' % (founder['name'], end_date)) smyBalance = samy_contract_instance.functions.balanceOf(founder['address']).call() smyBalance = Web3.fromWei(smyBalance, 'ether') print('Founder %s Contract SMY Token Balance: %s' % (founder['name'], smyBalance)) ethBalance = founder_contract_instance.functions.releasableAmount(smy_token_address).call() ethBalance = Web3.fromWei(ethBalance, 'ether') print('Founder %s Contract Releaseable Amount: %s' % (founder['name'], ethBalance)) if smyBalance == 0: return False
def fund_founders(smy_token_address=None, owner_address=None, owner_key=None, founders=None): i = 0 for founder in founders: try: i += 1 print('Funding Founder %s' % founder['name']) _amount = int(_initialSupply * .05) # 5% to founders _amount = Web3.toWei(_amount, 'ether') _amount = int(_amount / 3) # 33% to each founder samy_contract_instance = w3.eth.contract(smy_token_address, abi=samy_contract_interface['abi']) gas_price = w3.eth.gasPrice * 2 block = w3.eth.getBlock("latest") gas_limit = block["gasLimit"] - 30000 nonce = w3.eth.getTransactionCount(owner_address) built_transaction = { 'nonce': nonce, 'gasPrice': gas_price, 'gas': gas_limit, #'chainId': None 'chainId': 3 } transaction = samy_contract_instance.functions.transfer(founder['address'], _amount).buildTransaction(built_transaction) signed = w3.eth.account.signTransaction(transaction, owner_key) tx_hex = Web3.toHex(signed.rawTransaction) tx_hash = w3.eth.sendRawTransaction(tx_hex) print(Web3.toHex(tx_hash)) startTime = time.time() while w3.eth.getTransactionReceipt(tx_hash) == None: time.sleep(5) print('Waiting on Tranasaction') tx_receipt = w3.eth.getTransactionReceipt(tx_hash) print(tx_receipt) print('Elapsed Time: %s' % (int(time.time()) - int(startTime))) except Exception as e: print('Error Funding Founder %s; Error: %s' % (founder['name'], e)) break
def revoke_founders(smy_token_address=None, owner_address=None, owner_key=None, founders=None): i = 0 for founder in founders: try: i += 1 founder_contract_instance = w3.eth.contract(founder['address'], abi=founder_contract_interface['abi']) gas_price = w3.eth.gasPrice * 2 block = w3.eth.getBlock("latest") gas_limit = block["gasLimit"] - 30000 nonce = w3.eth.getTransactionCount(owner_address) built_transaction = { 'nonce': nonce, 'gasPrice': gas_price, 'gas': gas_limit, #'chainId': None 'chainId': 3 } transaction = founder_contract_instance.functions.revoke(smy_token_address).buildTransaction( built_transaction) signed = w3.eth.account.signTransaction(transaction, owner_key) tx_hex = Web3.toHex(signed.rawTransaction) tx_hash = w3.eth.sendRawTransaction(tx_hex) print(Web3.toHex(tx_hash)) startTime = time.time() while w3.eth.getTransactionReceipt(tx_hash) == None: time.sleep(5) print('Waiting on Tranasaction') tx_receipt = w3.eth.getTransactionReceipt(tx_hash) print('Founder %s funds revoked' % founder['name']) print('Elapsed Time: %s' % (int(time.time()) - int(startTime))) except Exception as e: print(e) break
def deploy_samy(owner_address=None, owner_key=None): try: gas_price = w3.eth.gasPrice block = w3.eth.getBlock("latest") gas_limit = block["gasLimit"] - 30000 nonce = w3.eth.getTransactionCount(owner_address) built_transaction = { 'nonce': nonce, 'gasPrice': gas_price, 'gas': gas_limit, #'chainId': None - SamyNet 'chainId': 3 } transaction = samy_contract.constructor().buildTransaction( built_transaction) signed = w3.eth.account.signTransaction(transaction, owner_key) tx_hex = Web3.toHex(signed.rawTransaction) tx_hash = w3.eth.sendRawTransaction(tx_hex) print(Web3.toHex(tx_hash)) while w3.eth.getTransactionReceipt(tx_hash) == None: time.sleep(5) print('Waiting on Tranasaction') tx_receipt = w3.eth.getTransactionReceipt(tx_hash) contract_address = tx_receipt['contractAddress'] data = {'address': contract_address} with open('SMYToken.json', 'w') as outfile: json.dump(data, outfile) return contract_address except Exception as e: print('Error Deploying SMY Token Contract; Error: %s', e)
def check_samy(samy_token_address=None, address=None, name=None): try: samy_token_contract_instance = w3.eth.contract( samy_token_address, abi=samy_contract_interface['abi']) balance = samy_token_contract_instance.functions.balanceOf( address).call() balance = Web3.fromWei(balance, 'ether') print('%s Account SMY Token Balance: %s' % (name, balance)) balance = w3.eth.getBalance(address) balance = Web3.fromWei(balance, 'ether') print('%s Account Eth Balance: %s' % (name, balance)) except Exception as e: print('Error Checking SMY Token Contract; Error: %s', e)
def change_status(smy_token_address=None, owner_address=None, owner_key=None): try: samy_token_contract_instance = w3.eth.contract( smy_token_address, abi=samy_contract_interface['abi']) isActive = samy_token_contract_instance.functions.isActive().call() if isActive == False: gas_price = w3.eth.gasPrice * 2 block = w3.eth.getBlock("latest") gas_limit = block["gasLimit"] - 30000 nonce = w3.eth.getTransactionCount(owner_address) built_transaction = { 'nonce': nonce, 'gasPrice': gas_price, 'gas': gas_limit, 'chainId': 3 } transaction = samy_token_contract_instance.functions.start( ).buildTransaction(built_transaction) signed = w3.eth.account.signTransaction(transaction, owner_key) tx_hex = Web3.toHex(signed.rawTransaction) tx_hash = w3.eth.sendRawTransaction(tx_hex) print(Web3.toHex(tx_hash)) while w3.eth.getTransactionReceipt(tx_hash) == None: time.sleep(5) print('Waiting on Tranasaction') tx_receipt = w3.eth.getTransactionReceipt(tx_hash) print('SMY Token is Active %s' % tx_receipt) except Exception as e: print('Error Checking SMY Token Contract; Error: %s', e)
def send(user_address=None, owner_address=None, owner_key=None): try: gas_price = w3.eth.gasPrice * 2 block = w3.eth.getBlock("latest") gas_limit = block["gasLimit"] - 30000 nonce = w3.eth.getTransactionCount(owner_address) _value = Web3.toWei(.5, 'ether') transaction = { 'nonce': nonce, 'gasPrice': gas_price, 'gas': gas_limit, #'chainId': None, 'chainId': 3, 'to': user_address, 'value': _value } signed = w3.eth.account.signTransaction(transaction, owner_key) tx_hex = Web3.toHex(signed.rawTransaction) tx_hash = w3.eth.sendRawTransaction(tx_hex) print(Web3.toHex(tx_hash)) startTime = time.time() while w3.eth.getTransactionReceipt(tx_hash) == None: time.sleep(5) print('Waiting on Tranasaction') tx_receipt = w3.eth.getTransactionReceipt(tx_hash) print(tx_receipt) print('Elapsed Time: %s' % (int(time.time()) - int(startTime))) except Exception as e: print('Error Sending Transaction: %s' % e)
def deploy_founders(owner_address=None, owner_key=None, founders=None): try: founder_list = [] i = 0 for founder in founders: i += 1 try: _beneficiary = founder['address'] _start = int(time.time()) _cliff = int(60) _duration = int(63072000) # 2 Years in seconds _revocable = True gas_price = w3.eth.gasPrice * 2 block = w3.eth.getBlock("latest") gas_limit = block["gasLimit"] - 30000 nonce = w3.eth.getTransactionCount(owner_address) built_transaction = { 'nonce': nonce, 'gasPrice': gas_price, 'gas': gas_limit, #'chainId': None 'chainId': 3 } transaction = founder_contract.constructor(args=(_beneficiary, _start, _cliff, _duration, _revocable), ).buildTransaction(built_transaction) signed = w3.eth.account.signTransaction(transaction, owner_key) tx_hex = Web3.toHex(signed.rawTransaction) tx_hash = w3.eth.sendRawTransaction(tx_hex) print(Web3.toHex(tx_hash)) startTime = time.time() while w3.eth.getTransactionReceipt(tx_hash) == None: time.sleep(5) print('Waiting on Tranasaction') tx_receipt = w3.eth.getTransactionReceipt(tx_hash) contract_address = tx_receipt['contractAddress'] print('Founder {} Contract Address: {}'.format(founder['name'], contract_address)) print('Elapsed Time: %s' % (int(time.time()) - int(startTime))) data = { 'name': '%s' % founder['name'], 'address': contract_address } founder_list.append(data) except Exception as e: print('Error Deploying Founder %s Contract: %s' % (founder['name'], e)) break with open('Founders.json', 'w') as outfile: json.dump(founder_list, outfile) except Exception as e: print('Error Deploying Founder Contracts; Error: %s', e)
def check(address=None, name=None): balance = w3.eth.getBalance(address) balance = Web3.fromWei(balance, 'ether') print('%s Account Eth Balance: %s' % (name, balance)) return balance