Exemplo n.º 1
0
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
Exemplo n.º 2
0
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)