-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwalletloader.py
More file actions
61 lines (47 loc) · 1.7 KB
/
Copy pathwalletloader.py
File metadata and controls
61 lines (47 loc) · 1.7 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import sys
#import solcx
#import web3-ethereum-defi
import asyncio
from web3 import Web3, HTTPProvider, exceptions
from os import getenv
from dotenv import load_dotenv
from chain import Chain
from contract import Contract
from wallet import Wallet
from pool import Pool
import json
import random
from eth_account import Account
# If you haven't already installed the Solidity compiler, uncomment the following line
# solcx.install_solc()
class WalletLoader:
def __init__(self, newChainName, walletName):
# Need to enable an unstable feature of this lib
Account.enable_unaudited_hdwallet_features()
self.chain = Chain(newChainName)
self.wallet = Wallet(walletName)
print("----------------------")
# Wallet Address
print(f"Wallet Address: {self.wallet.address}")
#print(f"Private Key: {wallet.privKey}")
# Print eth in wallet
weiBalance = self.wallet.getBalance(self.chain)
ethBalance = self.wallet.getBalanceETH(self.chain)
print(f"Balance: {ethBalance} ETH")
print(f"Balance: {weiBalance} WEI")
print("----------------------")
# Test
if len(sys.argv) > 2:
chainName = sys.argv[1]
walletName = sys.argv[2]
wv = WalletLoader(chainName, walletName)
# All additional contracts are arguments
for contractAddr in sys.argv[3:]:
contract = Contract("MyToken.sol")
contract.loadABI(Contract.ABI_PATH_ERC20)
contract.setContractAddress(contractAddr)
pool = Pool(wv.chain, contract)
pool.load(wv.wallet)
pool.printBalance(wv.wallet)
else:
print("Usage: python walletloader.py <chain> <walletName> [contract1, contract2, ...]")