-
Notifications
You must be signed in to change notification settings - Fork 8
/
config.py
39 lines (25 loc) · 948 Bytes
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from db import Database
from getpass import getpass
from web3 import Web3
class Connect:
def __init__(self):
bsc = "https://bsc-dataseed.binance.org/"
self.web3 = Web3(Web3.HTTPProvider(bsc))
self.db = Database()
def make_connection(self):
address = self.db.get_address()
if address:
addr = address[0]
else:
print("Can't find active address at database, insert you bsc address here...")
while True:
addr = input('Address: ')
key = getpass('Key: ')
try:
self.web3.eth.get_balance(addr)
except Exception as e:
print("Can't connect to blockchain: ",e,", check if address and network is correct")
else:
self.db.store_address(addr,key)
break
return addr