ethereumsolidityweb3jsbep20

How to get ETH or BSC unverified contract ABI


I want to find a deployed but not verified contract ABI~ There is api to find verified contract ABI but not support the unverified.Is there any ways to find a deployed but not verified contract ABI~ Like this contract 0x9447e3eD2A23572F7Be359216321f7e67B364BaC on BSC


Solution

  • You can loop through mined blocks and their transactions, and search for transaction receipts without to value and with contractAddress value.

    for (let blockNumber = 13188112; blockNumber < 13188113; blockNumber++) {
        const block = await web3.eth.getBlock(blockNumber);
        for (let txHash of block.transactions) {
            const receipt = await web3.eth.getTransactionReceipt(txHash);
            if (receipt.to === null && receipt.contractAddress !== undefined) {
                // found a contract-creating transaction
                console.log(receipt.contractAddress);
            }
        }
    }
    

    You can expand on this code to query the BSCScan API to find out if the contract address is verified on their site or not.