繁体   English   中英

我需要像薄荷一样的所有交易,在 web3 中烧录

[英]I need get a all transactions like mint , burn in web3

我需要从 bsc 上的 aa 地址获取所有交易。 我尝试了 bscscan api 但它并没有提供像燃烧铸币操作这样的一切,它们只是提供转移,我怎样才能使用 web3 js 或 web3 py 获得所有交易。 如果有人可以帮助我,我将不胜感激

您需要扫描所有块并发现您需要。 这是非常糟糕的方式。 其他方式——你可以使用 API

检查 etherscan.io api 您可以轻松获取所有交易的列表作为替代

https://etherscan.io/apis

http://api.etherscan.io/api?module=account&action=txlist&address=0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae&startblock=0&endblock=99999999&sort=asc&apikey=YourApiKeyToken

并使用这个答案。 这是一种简单的方法,但不是通过 web3js 或 web3py 获取所有事务的简单方法。

但是如果你只需要指定的事件——那就很容易了。

你需要 function getPastEvents

const START_BLOCK = 7700000;
const END_BLOCK = 7701000;
contract.getPastEvents("allEvents",
    {                               
        fromBlock: START_BLOCK,     
        toBlock: END_BLOCK // You can also specify 'latest'          
    })                              
.then(events => console.log(events))
.catch((err) => console.error(err));

您只能设置 mint 或 burn 事件。

https://web3js.readthedocs.io/en/v1.2.11/web3-eth-contract.html#getpastevents

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM