Skip to content

Commit

Permalink
fix abi
Browse files Browse the repository at this point in the history
  • Loading branch information
zaivanza committed Aug 13, 2023
1 parent 3dcde38 commit b47bf62
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
20 changes: 10 additions & 10 deletions modules/nft_checker.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from data.data import DATA
from config import WALLETS, outfile
from config import WALLETS, outfile, ERC20_ABI
from setting import value_nft_checker
from .helpers import evm_wallet, round_to, check_balance

Expand All @@ -14,38 +14,38 @@

RESULT = {}

async def check_balance(web3, wallet, address_contract, abi):
async def check_balance(web3, wallet, address_contract):
try:

try:
wallet = web3.eth.account.from_key(wallet).address
except Exception as error:
wallet = wallet

token_contract = web3.eth.contract(address=Web3.to_checksum_address(address_contract), abi=abi)
token_contract = web3.eth.contract(address=Web3.to_checksum_address(address_contract), abi=ERC20_ABI)
balance = await token_contract.functions.balanceOf(web3.to_checksum_address(wallet)).call()

return balance

except Exception as error:
logger.error(f'{error}')
await asyncio.sleep(1)
return await check_balance(web3, wallet, address_contract, abi)
return await check_balance(web3, wallet, address_contract)

async def worker(wallet, chain, address_contract, abi):
async def worker(wallet, chain, address_contract):

web3 = Web3(
AsyncHTTPProvider(DATA[chain]['rpc']),
modules={"eth": (AsyncEth,)},
middlewares=[],
)

balance = await check_balance(web3, wallet, address_contract, abi)
balance = await check_balance(web3, wallet, address_contract)
RESULT[wallet] = balance

async def main(contract, chain, abi, wallets):
async def main(contract, chain, wallets):

tasks = [worker(wallet, chain, contract, abi) for wallet in wallets]
tasks = [worker(wallet, chain, contract) for wallet in wallets]
await asyncio.gather(*tasks)

def send_result(min_balance, file_name):
Expand Down Expand Up @@ -98,7 +98,7 @@ def send_result(min_balance, file_name):

def nft_check():

chain, contract, abi, min_balance, file_name = value_nft_checker()
chain, contract, min_balance, file_name = value_nft_checker()

wallets = []
for key in WALLETS:
Expand All @@ -107,5 +107,5 @@ def nft_check():

RESULT.update({wallet : 0})

asyncio.run(main(contract, chain, abi, wallets))
asyncio.run(main(contract, chain, wallets))
send_result(min_balance, file_name)
3 changes: 1 addition & 2 deletions setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,9 +462,8 @@ def value_nft_checker():

chain = 'bsc'
contract = '' # nft contract
abi = '' # abi of nft contract

min_balance = 1 # если баланс nft меньше этого числа, кошелек выделяется
file_name = 'nft_balances' # имя файла в который будем сохранять данные. создается сам

return chain, contract, abi, min_balance, file_name
return chain, contract, min_balance, file_name

0 comments on commit b47bf62

Please sign in to comment.