Exemplo n.º 1
0
 def test_configure(self):
     client = in3.Client('goerli')
     self.assertIsInstance(client, in3.Client)
     client = in3.Client('goErli')
     self.assertIsInstance(client, in3.Client)
     client = in3.Client('goerli', in3.model.ClientConfig())
     self.assertIsInstance(client, in3.Client)
Exemplo n.º 2
0
 def test_configure(self):
     client = in3.Client('kovan')
     self.assertIsInstance(client, in3.Client)
     client = in3.Client('koVan')
     self.assertIsInstance(client, in3.Client)
     client = in3.Client('kovan', in3.model.ClientConfig())
     self.assertIsInstance(client, in3.Client)
Exemplo n.º 3
0
 def test_configure(self):
     client = in3.Client()
     self.assertIsInstance(client, in3.Client)
     client = in3.Client('mainnet')
     self.assertIsInstance(client, in3.Client)
     client = in3.Client('mainNet')
     self.assertIsInstance(client, in3.Client)
     client = in3.Client(in3_config=in3.model.ClientConfig())
     self.assertIsInstance(client, in3.Client)
Exemplo n.º 4
0
 def setUp(self):
     # self.client = in3.Client('goerli', in3_config=mainchain_mock_config)
     self.client = in3.Client('goerli',
                              in3_config=mainchain_mock_config,
                              cache_enabled=False,
                              transport=mock_transport,
                              test_instance=True)
Exemplo n.º 5
0
 def test_send_transact_without_key(self):
     main = ContractActivities(in3.Client("goerli"))
     main.setVisible(True)
     self.assertEqual(main.convict_modal.isVisible(), False)
     self.assertEqual(main.no_key_error_label.isHidden(), True)
     main.people_buttons[1].click()
     self.assertEqual(main.convict_modal.isHidden(), True)
     self.assertEqual(main.no_key_error_label.isHidden(), False)
Exemplo n.º 6
0
 def test_send_admin_transact_with_nonadmin_key(self):
     main = ContractActivities(in3.Client("goerli"))
     main.setVisible(True)
     main.p_key = "bae4f8f1b2778d75625157b108d4de1a469ad330f88c6d699703d2b309dd7744"
     self.assertEqual(main.remove_node_modal.isVisible(), False)
     self.assertEqual(main.no_key_error_label.isHidden(), True)
     main.admin_buttons[0].click()
     self.assertEqual(main.remove_node_modal.isHidden(), True)
     self.assertEqual(main.no_key_error_label.isHidden(), False)
Exemplo n.º 7
0
 def test_correct_account_addition(self):
     main = ContractActivities(in3.Client("goerli"))
     cont = ContractModal(main)
     self.assertEqual(cont.isVisible(), False)
     cont.setVisible(True)
     cont.new_addr_line.setText("0xFB55cC4bE5496629169219FeeEFDF98d423AFf8B")
     cont.modal_add.click()
     # self.assertEqual(acc.isHidden(), True)
     self.assertEqual(cont.modal_error_label.isVisible(), False)
     self.assertEqual(cont.new_addr_line.text(), "")
Exemplo n.º 8
0
 def test_wrong_contract_addition(self):
     main = ContractActivities(in3.Client("goerli"))
     cont = ContractModal(main)
     self.assertEqual(cont.isVisible(), False)
     cont.setVisible(True)
     cont.new_addr_line.setText("Hello darkness")
     cont.modal_add.click()
     # self.assertEqual(acc.isHidden(), True)
     self.assertEqual(cont.modal_error_label.isVisible(), True)
     self.assertEqual(cont.new_addr_line.text(), "")
Exemplo n.º 9
0
 def test_instantiate(self):
     with self.assertRaises(AssertionError):
         in3.Client(None)
     with self.assertRaises(AssertionError):
         in3.Client(1)
     with self.assertRaises(AssertionError):
         in3.Client(-1)
     with self.assertRaises(AssertionError):
         in3.Client('œ∑´´†√¨')
     with self.assertRaises(AssertionError):
         in3.Client('!@# asd')
     with self.assertRaises(AssertionError):
         in3.Client({1: 1})
     with self.assertRaises(AssertionError):
         in3.Client((1))
     with self.assertRaises(AssertionError):
         in3.Client([1])
Exemplo n.º 10
0
 def test_configure(self):
     with self.assertRaises(AssertionError):
         in3.Client(in3_config=1)
     with self.assertRaises(AssertionError):
         in3.Client(in3_config=-1)
     with self.assertRaises(AssertionError):
         in3.Client(in3_config='œ∑´´†√¨')
     with self.assertRaises(AssertionError):
         in3.Client(in3_config={1: 1})
     with self.assertRaises(AssertionError):
         in3.Client(in3_config=(1))
     with self.assertRaises(AssertionError):
         in3.Client(in3_config=[1])
Exemplo n.º 11
0
    def __init__(self, network="goerli"):
        QWidget.__init__(self)

        # check if the app is connected to the network
        self.client = in3.Client(network)
        try:
            check = self.client.eth.block_number()
        except ClientException:
            print("Unable to connect to the" + network)
            return

        self.p_key = ""
        self.server_listing_box = ServerListing(self.client)
        self.buttons_listing_box = ContractActivities(self.client)
        self.server_listing_box.setMinimumWidth(800)

        # Private key setup button creation(assigned to the top right corner)
        self.top = QWidget()
        self.account_layout = QVBoxLayout()
        self.settings_button = QToolButton()
        self.settings_button.setIcon(QIcon("./resources/account.png"))
        self.account_layout.addWidget(self.settings_button)
        self.account_layout.setAlignment(Qt.AlignRight)
        self.top.setLayout(self.account_layout)

        # Main layout, with all of the functionality on it
        self.main_layout = QFormLayout()
        self.main_layout.addRow(QLabel("Network: " + network), self.top)
        self.main_layout.addRow(self.server_listing_box,
                                self.buttons_listing_box)
        self.setLayout(self.main_layout)

        # Connecting the signal
        self.settings_button.clicked.connect(self.account_click)

        # Modal window to set up user's account
        self.add_account_modal = AccountModal(self)
Exemplo n.º 12
0
import in3


def _print():
    print('\nAddress for {} @ {}: {}'.format(domain, chain, address))
    print('Owner for {} @ {}: {}'.format(domain, chain, owner))


# Find ENS for the desired chain or the address of your own ENS resolver. https://docs.ens.domains/ens-deployments
domain = 'depraz.eth'

print('\nEthereum Name Service')

# Instantiate In3 Client for Goerli
chain = 'goerli'
client = in3.Client(chain)
address = client.ens_address(domain)

# Instantiate In3 Client for Mainnet
chain = 'mainnet'
client = in3.Client(chain)
address = client.ens_address(domain)
owner = client.ens_owner(domain)
_print()

# Instantiate In3 Client for Kovan
chain = 'kovan'
client = in3.Client(chain)
try:
    address = client.ens_address(domain)
    owner = client.ens_owner(domain)
Exemplo n.º 13
0
"""
Resolves ENS domains to Ethereum addresses
ENS is a smart-contract system that registers and resolves `.eth` domains.
"""
import in3

# Find ENS for the desired chain or the address of your own ENS resolver. https://docs.ens.domains/ens-deployments
# Instantiate In3 Client for the Ethereum main net disabling cache to get the freshest address.
client = in3.Client(cache_enabled=False)
domain = 'depraz.eth'

if __name__ == '__main__':

    try:
        print('\nEthereum Name Service')
        address = client.ens_address(domain)
        owner = client.ens_owner(domain)
        print('\nAddress for {} @ {}: {}'.format(domain, 'mainnet', address))
        print('Owner for {} @ {}: {}'.format(domain, 'mainnet', owner))
    except in3.ClientException as e:
        print('Network might be unstable, try again later.\n Reason: ', str(e))

# Produces
"""
Ethereum Name Service

Address for depraz.eth @ mainnet: 0x0b56ae81586d2728ceaf7c00a6020c5d63f02308
Owner for depraz.eth @ mainnet: 0x6fa33809667a99a805b610c49ee2042863b1bb83
"""
Exemplo n.º 14
0
 def setUp(self):
     # self.client = in3.Client('goerli', in3_config=mock_config)
     self.client = in3.Client('goerli', in3_config=mock_config, transport=mock_transport)
Exemplo n.º 15
0
 def setUp(self):
     # self.client = in3.Client(in3_config=mainchain_mock_config)
     self.client = in3.Client(in3_config=mainchain_mock_config,
                              cache_enabled=False,
                              transport=mock_transport)
Exemplo n.º 16
0
"""
Connects to Ethereum and fetches attested information from each chain.
"""
import in3

if __name__ == '__main__':

    client = in3.Client()
    try:
        print('\nEthereum Main Network')
        latest_block = client.eth.block_number()
        gas_price = client.eth.gas_price()
        print('Latest BN: {}\nGas Price: {} Wei'.format(
            latest_block, gas_price))
    except in3.ClientException as e:
        print('Network might be unstable, try again later.\n Reason: ', str(e))

    goerli_client = in3.Client('goerli')
    try:
        print('\nEthereum Goerli Test Network')
        latest_block = goerli_client.eth.block_number()
        gas_price = goerli_client.eth.gas_price()
        print('Latest BN: {}\nGas Price: {} Wei'.format(
            latest_block, gas_price))
    except in3.ClientException as e:
        print('Network might be unstable, try again later.\n Reason: ', str(e))

# Produces
"""
Ethereum Main Network
Latest BN: 9801135
Exemplo n.º 17
0
sg.theme('DarkAmber')  # Add a touch of color
# All the stuff inside your window.
layout = [[sg.Button("Mainnet")], [sg.Button("Kovan")], [sg.Button("Goerli")],
          [sg.Button("EWC")], [sg.Button("Exit")]]

# Create the Window
window = sg.Window('Fetch Ethereum Data', layout)
# Event Loop to process "events" and get the "values" of the inputs

while True:
    event, values = window.read()
    if event == sg.WIN_CLOSED or event == 'Cancel':  # if user closes window or clicks cancel
        break
    elif event == "Mainnet":
        # on every event, the client is instantiated differently and the list of client nodes are refreshedgt
        client = in3.Client("Mainnet")
        node_list = client.refresh_node_list()

        sg.Print('\nIncubed Registry:')
        sg.Print('\ttotal servers:{}'.format(node_list.totalServers))
        sg.Print('\tlast updated in block:{}'.format(
            node_list.lastBlockNumber))
        sg.Print('\tregistry ID:{}'.format(node_list.registryId))
        sg.Print('\tcontract address:{}'.format(node_list.contract))
        sg.Print('\nNodes Registered:\n')
        for node in node_list.nodes:
            sg.Print('\turl:{}'.format(node.url))
            sg.Print('\tdeposit:', node.deposit)
            sg.Print('\tweight:', node.weight)
            sg.Print('\tregistered in block:', node.registerTime)
            sg.Print('\n')
Exemplo n.º 18
0
import in3
import time

conf = in3.Config()
conf.chainId = str(in3.Chain.KOVAN)

eth = in3.Client(in3_config=conf).eth

filter = eth.new_block_filter()

count = 0
while (count < 10):
    changes = eth.get_filter_changes(filter)
    time.sleep(10)
    print(changes)
    count += 1
    print(">>>")
Exemplo n.º 19
0
 def setUp(self):
     self.client = in3.Client(in3_config=mainchain_mock_config,
                              transport=mock_transport,
                              test_instance=True)
Exemplo n.º 20
0
 def setUp(self):
     self.client = in3.Client()
Exemplo n.º 21
0
"""
import json
import in3
import time

# On Metamask, be sure to be connected to the correct chain, click on the `...` icon on the right corner of
# your Account name, select `Account Details`. There, click `Export Private Key`, copy the value to use as secret.
# By reading the terminal input, this value will stay in memory only. Don't forget to cls or clear terminal after ;)
sender_secret = input("Sender secret: ")
receiver = input("Receiver address: ")
#     1000000000000000000 == 1 ETH
#              1000000000 == 1 Gwei Check https://etherscan.io/gasTracker.
value_in_wei = 1463926659
# None for Eth mainnet
chain = 'goerli'
client = in3.Client(chain if chain else 'mainnet')
# A transaction is only final if a certain number of blocks are mined on top of it.
# This number varies with the chain's consensus algorithm. Time can be calculated over using:
# wait_time = blocks_for_consensus * avg_block_time_in_secs
# For mainnet and paying low gas, it might take 10 minutes.
confirmation_wait_time_in_seconds = 30
etherscan_link_mask = 'https://{}{}etherscan.io/tx/{}'

print('-= Ethereum Transaction using Incubed =- \n')
try:
    sender = client.eth.account.recover(sender_secret)
    tx = in3.eth.NewTransaction(to=receiver, value=value_in_wei)
    print('[.] Sending {} Wei from {} to {}. Please wait.\n'.format(
        tx.value, sender.address, tx.to))
    tx_hash = client.eth.account.send_transaction(sender, tx)
    print('[.] Transaction accepted with hash {}.'.format(tx_hash))
Exemplo n.º 22
0
"""
Manually calling the ENS smart-contract
![UML Sequence Diagram of how Ethereum Name Service ENS resolves a name.](https://lh5.googleusercontent.com/_OPPzaxTxKggx9HuxloeWtK8ggEfIIBKRCEA6BKMwZdzAfUpIY6cz7NK5CFmiuw7TwknbhFNVRCJsswHLqkxUEJ5KdRzpeNbyg8_H9d2RZdG28kgipT64JyPZUP--bAizozaDcxCq34)
"""
import in3

client = in3.Client('goerli')

if __name__ == '__main__':

    try:
        print('-= Smart-Contract Call on Ethereum using Incubed =- \n')
        domain_name = client.ens_namehash('depraz.eth')
        ens_registry_addr = '0x00000000000c2e074ec69a0dfb2997ba6c7d2e1e'
        ens_resolver_abi = 'resolver(bytes32):address'

        # Find resolver contract for ens name
        resolver_tx = {
            "to": ens_registry_addr,
            "data": client.eth.contract.encode(ens_resolver_abi, domain_name)
        }
        tx = in3.eth.NewTransaction(**resolver_tx)
    except in3.ClientException as e:
        print('Something went wrong converting data.\n Reason: ', str(e))
    try:
        # Make the smart contract call
        print('Calling the ENS registry contract.')
        encoded_resolver_addr = client.eth.contract.call(tx)
        resolver_address = client.eth.contract.decode(ens_resolver_abi,
                                                      encoded_resolver_addr)
    except in3.ClientException as e:
Exemplo n.º 23
0
"""
Connects to Ethereum and fetches attested information from each chain.
"""
import in3

print('\nEthereum Main Network')
client = in3.Client()
latest_block = client.eth.block_number()
gas_price = client.eth.gas_price()
print('Latest BN: {}\nGas Price: {} Wei'.format(latest_block, gas_price))

print('\nEthereum Kovan Test Network')
client = in3.Client('kovan')
latest_block = client.eth.block_number()
gas_price = client.eth.gas_price()
print('Latest BN: {}\nGas Price: {} Wei'.format(latest_block, gas_price))

print('\nEthereum Goerli Test Network')
client = in3.Client('goerli')
latest_block = client.eth.block_number()
gas_price = client.eth.gas_price()
print('Latest BN: {}\nGas Price: {} Wei'.format(latest_block, gas_price))

# Produces
"""
Ethereum Main Network
Latest BN: 9801135
Gas Price: 2000000000 Wei

Ethereum Kovan Test Network
Latest BN: 17713464
Exemplo n.º 24
0
 def setUp(self):
     conf = in3.Config()
     conf.chainId = str(in3.Chain.KOVAN)
     self.in3_client = in3.Client(in3_config=conf)
Exemplo n.º 25
0
           sg.InputText()], [sg.Submit(), sg.Cancel()]]

window = sg.Window('Resolve ENS to an Ethereum Address', layout)

while True:  # The Event Loop
    event, values = window.read()

    def _print():
        sg.Print('\nAddress for {} @ {}: {}'.format(domain, chain, address))
        sg.Print('Owner for {} @ {}: {}'.format(domain, chain, owner))

    domain = str(values[0])

    # Instantiate In3 Client for Goerli
    chain = 'goerli'
    client = in3.Client(chain, cache_enabled=False)
    address = client.ens_address(domain)
    owner = client.ens_owner(domain)
    _print()

    # Instantiate In3 Client for Mainnet
    chain = 'mainnet'
    client = in3.Client(chain, cache_enabled=False)
    address = client.ens_address(domain)
    owner = client.ens_owner(domain)
    _print()

    # Instantiate In3 Client for Kovan
    chain = 'kovan'
    client = in3.Client(chain, cache_enabled=True)
    try: