Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bscscan for Etherscan Providers #1473

Closed
mcastiglione777 opened this issue Apr 15, 2021 · 1 comment
Closed

Add bscscan for Etherscan Providers #1473

mcastiglione777 opened this issue Apr 15, 2021 · 1 comment
Labels
duplicate Duplicate of another issue.

Comments

@mcastiglione777
Copy link

mcastiglione777 commented Apr 15, 2021

Hello, please add bscscan (Binance Chain Etherscan) for Etherscan providers
the base URL is https://api.bscscan.com/

I use ethers.js and I need to use this endpoint so I can add historical data support for Binance Smart Chain.

the file is this one:
packages/providers/src.ts/etherscan-provider.ts

Right now the options are these:
switch(name) {
case "homestead":
baseUrl = "https://api.etherscan.io";
break;
case "ropsten":
baseUrl = "https://api-ropsten.etherscan.io";
break;
case "rinkeby":
baseUrl = "https://api-rinkeby.etherscan.io";
break;
case "kovan":
baseUrl = "https://api-kovan.etherscan.io";
break;
case "goerli":
baseUrl = "https://api-goerli.etherscan.io";
break;
default:
throw new Error("unsupported network");
}

It should be like this:

    switch(name) {
        case "homestead":
            baseUrl = "https://api.etherscan.io";
            break;
        case "ropsten":
            baseUrl = "https://api-ropsten.etherscan.io";
            break;
        case "rinkeby":
            baseUrl = "https://api-rinkeby.etherscan.io";
            break;
        case "kovan":
            baseUrl = "https://api-kovan.etherscan.io";
            break;
        case "goerli":
            baseUrl = "https://api-goerli.etherscan.io";
            break;
        case "smartchain":
            baseUrl = "https://api.bscscan.com";
            break;
        default:
            throw new Error("unsupported network");
    }

Also, there should be a handler for getEtherPrice, like this:
delete these two lines:
if (this.network.name !== "homestead") { return 0.0; }
url += "?module=stats&action=ethprice";
add:
if (this.network.name !== "homestead" && this.network.name !== "smartchain") { return 0.0; }
if (this.network.name == "smartchain") {
url += "?module=stats&action=bnbprice";
} else {
url += "?module=stats&action=ethprice";
}

Thank you very much
Marco

@ricmoo
Copy link
Member

ricmoo commented Apr 16, 2021

Closing this in favour of #1204.

Please comment there, and include any additional information.

Thanks! :)

@ricmoo ricmoo closed this as completed Apr 16, 2021
@ricmoo ricmoo added the duplicate Duplicate of another issue. label Apr 16, 2021
ricmoo added a commit that referenced this issue May 14, 2021
pull bot pushed a commit to shapeshift/ethers.js that referenced this issue Jun 4, 2021
pull bot pushed a commit to shapeshift/ethers.js that referenced this issue Jun 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate Duplicate of another issue.
Projects
None yet
Development

No branches or pull requests

2 participants