【问题标题】:Can I extract BSC transaction details programmatically without going through BscScan?我可以在不通过 BscScan 的情况下以编程方式提取 BSC 交易详细信息吗?
【发布时间】:2021-12-30 16:09:42
【问题描述】:

我想以编程方式获取 BscScan 上显示的数据,但他们的 API 似乎非常有限,我想避免解析 HTML 内容来提取它。

我想知道是否可以找到公开这些数据的 REST API。例如,如果 https://bsc-dataseed.binance.org 公开 REST 端点。

如果我理解正确,该 URL 应该实现此规范:https://github.com/ethereum/execution-apis,在这里:https://github.com/ethereum/execution-apis/blob/main/src/eth/transaction.json 我可以看到 eth_getTransactionByHash,这听起来与我正在寻找的完全一样,但我不确定如何/是否可以访问这个。

谢谢。

【问题讨论】:

  • BSC 是基于 EVM 的区块链,你绝对可以使用 web3/ethers 库来获取交易收据或其他状态。

标签: ethereum binance binance-smart-chain binance-chain


【解决方案1】:

您可以使用 web3/ethers 直接从节点获取交易回执。

 // mainnet 
     const web3 = new Web3('https://bsc-dataseed1.binance.org:443');
// testnet
    const web3 = new Web3('https://data-seed-prebsc-1-s1.binance.org:8545');

BSC 的 RPC 端点:https://docs.binance.org/smart-chain/developer/rpc.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-27
    • 1970-01-01
    • 1970-01-01
    • 2022-06-22
    • 2018-12-29
    • 1970-01-01
    相关资源
    最近更新 更多