BSC令牌浏览器

2024-10-16 20:52:26 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在寻找一种解决方案,在Binance智能链上获得所有可用和新的BEP-20代币。我尝试用web3py分析所有事务并从输入字段中提取令牌,但看起来不正确。我尝试了BSCscan API、Pancakeswap API和Web3py,但没有人提供该端点

以下是我当前获取所有事务的解决方案:

from web3 import Web3
import time

web3 = Web3(Web3.HTTPProvider('https://bsc-dataseed.binance.org/'))

def handle_event(event):
    try:
        transaction = web3.eth.getTransactionReceipt(event)
        print ('\n****************TRANSACTION****************')
        print (transaction)
        print ('*******************************************\n')
    except:
        pass

def log_loop(event_filter, poll_interval):
    while True:
        for event in event_filter.get_new_entries():
            handle_event(event)
        time.sleep(poll_interval)

def main():
    transactions = web3.eth.filter('pending')
    log_loop(transactions, 1)

if __name__ == '__main__':
    main()

通过transaction.input和内部日志,我将看到传输的令牌

顺便说一句:这里有谁有一个有效的解决方案,可以从输入中提取令牌,而不用手动切片字符串

有人知道一个更好的方法来获得所有的BEP-20代币吗?我的目标类似于:https://poocoin.app/ape


Tags: importeventapitimemaindef解决方案filter