--基本上,node.js或javascript函数将使用web3或其他方法从ETH或BSC扫描中提取数据,并按以下步骤进行分析和显示:
我怎样才能取得所需的成果?
发布于 2021-07-25 08:51:25
答:在ETH和BSC扫描上创建帐户,获取API键,然后在响应以下2个请求时,如果得到状态代码= 1,这意味着契约部署在特定的链上。
使用Etherscan https://api.etherscan.io/api?module=contract&action=getabi&address=0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413&apikey=xxx
类似地,对于BSC,使用BSC扫描开发API https://api.bscscan.com/api?module=contract&action=getabi&address=0x0000000000000000000000000000000000001004&apikey=xxx。
嗯,为此,我试图找到以太扫描自由API。然而,我认为他们在PRO计划中提供了API。因此,我发现使用node.js和web 抓取 npm库的快速解决方案是:
const options1 = {
method: 'GET',
url: `https://etherscan.io/token/${req.query.tokenAddress}`,
headers: { 'content-type': 'application/json' },
json: true
};
request(options1, (error, response, html) => {
if (!error && response.statusCode == 200) {
const $ = cheerio.load(html);
const holders = $('div[id = "ContentPlaceHolder1_tr_tokenHolders"] > div > div').text().trim();
console.log(holders);
res.send({ chain, holders });
} else if (error) throw new Error(error);
});任何合同的第一次交易都是为了部署smart合同。因此,我们可以通过获取该特定智能契约的第一个事务的执行时间戳来获得合同创建日期和时间。
对于EthScan,我们可以通过它们的API调用https://api.etherscan.io/api?module=account&action=txlist&address=0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae&startblock=0&endblock=99999999&page=1&offset=10&sort=asc&apikey=xxx获取任何合同的事务。
对于平衡计分卡来说,这是https://api.bscscan.com/api?module=account&action=txlist&address=0x0000000000000000000000000000000000001004&startblock=1&endblock=99999999&page=1&offset=10&sort=asc&apikey=xxx
https://stackoverflow.com/questions/68507742
复制相似问题