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

EtherscanProvider has no base URL for Optimism #2968

Closed
eliotstock opened this issue May 5, 2022 · 2 comments
Closed

EtherscanProvider has no base URL for Optimism #2968

eliotstock opened this issue May 5, 2022 · 2 comments
Assignees
Labels
enhancement New feature or improvement. fixed/complete This Bug is fixed or Enhancement is complete and published.

Comments

@eliotstock
Copy link

Ethers Version

5.6.5

Search Terms

optimism etherscan

Describe the Problem

Versions of the Etherscan API that enable historical queries (using EtherscanProvider.getHistory(address)) now exist for some L2 chains, including Optimistic Ethereum: https://optimistic.etherscan.io/apis. However, it's not yet possible to use this in Ethers.js AFAICT.

This code...

  const network: Network = {name: 'optimism', chainId: 10}
  const provider = new EtherscanProvider(network, etherscanApiKey)

... will throw:

ReferenceError: name is not defined
    at EtherscanProvider.getBaseUrl (/home/e/r/dro/interface/node_modules/@ethersproject/providers/src.ts/etherscan-provider.ts:189:76)
    at new EtherscanProvider (/home/e/r/dro/interface/node_modules/@ethersproject/providers/src.ts/etherscan-provider.ts:170:46)
    at main (/home/e/r/dro/interface/src/index.ts:48:30)

... because getBaseUrl() here doesn't know about Optimism.

I've also tried using the JsonRpcProvider and providing a URL:

const network: Network = {name: 'optimism', chainId: 10}
provider = new JsonRpcProvider('https://api-optimistic.etherscan.io/api', network)

But of course there's no getHistory() method on JsonRpcProvider.

Code Snippet

const network: Network = {name: 'optimism', chainId: 10}
  const provider = new EtherscanProvider(network, etherscanApiKey)

Contract ABI

No response

Errors

ReferenceError: name is not defined
    at EtherscanProvider.getBaseUrl (/home/e/r/dro/interface/node_modules/@ethersproject/providers/src.ts/etherscan-provider.ts:189:76)
    at new EtherscanProvider (/home/e/r/dro/interface/node_modules/@ethersproject/providers/src.ts/etherscan-provider.ts:170:46)
    at main (/home/e/r/dro/interface/src/index.ts:48:30)

Environment

Altcoin - Please specify (e.g. Polygon), node.js (v12 or newer)

Environment (Other)

Optimism

@eliotstock eliotstock added the investigate Under investigation and may be a bug. label May 5, 2022
@ricmoo ricmoo added on-deck This Enhancement or Bug is currently being worked on. enhancement New feature or improvement. and removed investigate Under investigation and may be a bug. labels May 11, 2022
@ricmoo
Copy link
Member

ricmoo commented May 14, 2022

This has been added in 5.6.6.

Let me know if you have any problems.

Thanks! :)

@ricmoo ricmoo closed this as completed May 14, 2022
@ricmoo ricmoo added fixed/complete This Bug is fixed or Enhancement is complete and published. and removed on-deck This Enhancement or Bug is currently being worked on. labels May 14, 2022
@eliotstock
Copy link
Author

Amazing, thank you so much!

Woodpile37 pushed a commit to Woodpile37/ethers.js that referenced this issue Jan 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement. fixed/complete This Bug is fixed or Enhancement is complete and published.
Projects
None yet
Development

No branches or pull requests

2 participants