Search code examples
ethereumbinancebinance-smart-chainbinance-chain

Can I extract BSC transaction details programmatically without going through BscScan?


I would like to get the data that's displayed on BscScan programmatically, but their API seems quite limited, and I would like to avoid parsing HTML content to extract it.

I am wondering if I can find a REST API that exposes this data. Like if, for example, https://bsc-dataseed.binance.org exposes REST endpoints.

If I understand correctly, that URL should implement this spec: https://github.com/ethereum/execution-apis, and here: https://github.com/ethereum/execution-apis/blob/main/src/eth/transaction.json I can see eth_getTransactionByHash which sounds exactly like what I am looking for, but I am not sure how/if I can access this.

Thanks.


Solution

  • You can use web3/ethers to get transaction receipt from node directly.

     // 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');
    

    And RPC endpoints for BSC: https://docs.binance.org/smart-chain/developer/rpc.html