forked from NomicFoundation/hardhat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support multiple api keys in hardhat-etherscan
The config has been extended to allow both a string as api key or an object that can contain multiple api keys, keyed by chain. Relates to NomicFoundation#1448.
- Loading branch information
Showing
14 changed files
with
540 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@nomiclabs/hardhat-etherscan": major | ||
--- | ||
|
||
Support multiple api keys in `hardhat-etherscan` to allow for verification against multiple networks (issue #1448) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Contributing to Hardhat Etherscan | ||
|
||
The `hardhat-etherscan` plugin works with any explorer that is powered by Etherscan or that has a compatible verification API. This guide explains how to send a Pull Request that adds support for a new chain. | ||
|
||
1. Update [types.ts](./src/types.ts) to include the new chain: | ||
- Add the chain as an entry in the `Chains` enum, ensuring the name and string value match. | ||
2. Update [ChainConfig](./src/ChainConfig.ts) with the parameters for the chain you want to add: | ||
|
||
- Add an entry to the `chainConfig` object under the name you added to the `Chains` enum | ||
- Under that `chainConfig` entry add the chain id. For example, if your network is called "foo_chain" and its chain id is 1234, you need to add: | ||
|
||
```jsx | ||
foo_chain: { | ||
chainId: 1234, | ||
... | ||
}, | ||
``` | ||
|
||
- Add the proper URLs under the `chainConfig` chain entry. For example: | ||
|
||
```jsx | ||
foo_chain: { | ||
chainId: 1234, | ||
urls: { | ||
apiURL: "https://api.foochainscan.io/api", | ||
browserURL: "https://foochainscan.io", | ||
}, | ||
}, | ||
``` | ||
|
||
Here `apiURL` is the endpoint that corresponds to the API of the explorer, which will be used to send the verification request. `browserURL` is the URL of the explorer, that will be used to show a link after a successful verification. For this example, you would see a message with something like: `https://foochainscan.io/address/0xabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcde#code` | ||
|
||
3. Send a pull request with these changes. | ||
4. As part of the PR, and for each chain you are adding: | ||
- Indicate a public JSON-RPC endpoint that can be used for that chain. | ||
- Send some funds to this address: `0x4444c3F7D7d3153Dc0773C31ae10cf9B5495d4Bb`. These will be used by us to check that a contract can be deployed and verified with these changes. Don't send too much value, just enough to deploy a simple contract. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
import { ChainConfig } from "./types"; | ||
|
||
// See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md#list-of-chain-ids | ||
export const chainConfig: ChainConfig = { | ||
mainnet: { | ||
chainId: 1, | ||
urls: { | ||
apiURL: "https://api.etherscan.io/api", | ||
browserURL: "https://etherscan.io", | ||
}, | ||
}, | ||
ropsten: { | ||
chainId: 3, | ||
urls: { | ||
apiURL: "https://api-ropsten.etherscan.io/api", | ||
browserURL: "https://ropsten.etherscan.io", | ||
}, | ||
}, | ||
rinkeby: { | ||
chainId: 4, | ||
urls: { | ||
apiURL: "https://api-rinkeby.etherscan.io/api", | ||
browserURL: "https://rinkeby.etherscan.io", | ||
}, | ||
}, | ||
goerli: { | ||
chainId: 5, | ||
urls: { | ||
apiURL: "https://api-goerli.etherscan.io/api", | ||
browserURL: "https://goerli.etherscan.io", | ||
}, | ||
}, | ||
kovan: { | ||
chainId: 42, | ||
urls: { | ||
apiURL: "https://api-kovan.etherscan.io/api", | ||
browserURL: "https://kovan.etherscan.io", | ||
}, | ||
}, | ||
bsc: { | ||
chainId: 56, | ||
urls: { | ||
apiURL: "https://api.bscscan.com/api", | ||
browserURL: "https://bscscan.com", | ||
}, | ||
}, | ||
bsc_testnet: { | ||
chainId: 97, | ||
urls: { | ||
apiURL: "https://api-testnet.bscscan.com/api", | ||
browserURL: "https://testnet.bscscan.com", | ||
}, | ||
}, | ||
heco: { | ||
chainId: 128, | ||
urls: { | ||
apiURL: "https://api.hecoinfo.com/api", | ||
browserURL: "https://hecoinfo.com", | ||
}, | ||
}, | ||
heco_testnet: { | ||
chainId: 256, | ||
urls: { | ||
apiURL: "https://api-testnet.hecoinfo.com/api", | ||
browserURL: "https://testnet.hecoinfo.com", | ||
}, | ||
}, | ||
opera: { | ||
chainId: 250, | ||
urls: { | ||
apiURL: "https://api.ftmscan.com/api", | ||
browserURL: "https://ftmscan.com", | ||
}, | ||
}, | ||
ftm_testnet: { | ||
chainId: 4002, | ||
urls: { | ||
apiURL: "https://api-testnet.ftmscan.com/api", | ||
browserURL: "https://testnet.ftmscan.com", | ||
}, | ||
}, | ||
optimistic_ethereum: { | ||
chainId: 10, | ||
urls: { | ||
apiURL: "https://api-optimistic.etherscan.io/api", | ||
browserURL: "https://optimistic.etherscan.io/", | ||
}, | ||
}, | ||
optimistic_kovan: { | ||
chainId: 69, | ||
urls: { | ||
apiURL: "https://api-kovan-optimistic.etherscan.io/api", | ||
browserURL: "https://kovan-optimistic.etherscan.io/", | ||
}, | ||
}, | ||
polygon: { | ||
chainId: 137, | ||
urls: { | ||
apiURL: "https://api.polygonscan.com/api", | ||
browserURL: "https://polygonscan.com", | ||
}, | ||
}, | ||
polygon_mumbai: { | ||
chainId: 80001, | ||
urls: { | ||
apiURL: "https://api-testnet.polygonscan.com/api", | ||
browserURL: "https://mumbai.polygonscan.com/", | ||
}, | ||
}, | ||
arbitrum_one: { | ||
chainId: 42161, | ||
urls: { | ||
apiURL: "https://api.arbiscan.io/api", | ||
browserURL: "https://arbiscan.io/", | ||
}, | ||
}, | ||
arbitrum_testnet: { | ||
chainId: 421611, | ||
urls: { | ||
apiURL: "https://api-testnet.arbiscan.io/api", | ||
browserURL: "https://testnet.arbiscan.io/", | ||
}, | ||
}, | ||
avalanche: { | ||
chainId: 43114, | ||
urls: { | ||
apiURL: "https://api.snowtrace.io/api", | ||
browserURL: "https://snowtrace.io/", | ||
}, | ||
}, | ||
avalanche_fuji_testnet: { | ||
chainId: 43113, | ||
urls: { | ||
apiURL: "https://api-testnet.snowtrace.io/api", | ||
browserURL: "https://testnet.snowtrace.io/", | ||
}, | ||
}, | ||
moonriver: { | ||
chainId: 1285, | ||
urls: { | ||
apiURL: "https://api-moonriver.moonscan.io/api", | ||
browserURL: "https://moonscan.io", | ||
}, | ||
}, | ||
moonbase_alpha: { | ||
chainId: 1287, | ||
urls: { | ||
apiURL: "https://api-moonbase.moonscan.io/api", | ||
browserURL: "https://moonbase.moonscan.io/", | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.