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

Snowtrace verification #27

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,23 @@ In our repository we use a pre-configured file [hardhat.config.ts](https://githu

You can define custom hardhat tasks in [hardhat.config.ts](https://github.com/ava-labs/avalanche-smart-contract-quickstart/blob/main/hardhat.config.ts).

## Snowtrace Verification

To try out Snowtrace verification, you first need to deploy a contract to an Avalanche network that's supported by Snowtrace, such as Fuji, C-Chain.

In this project, copy the `env.example` file to a file named `.env`, and then edit it to fill in the details. Enter your Snowtrace API key, and the private key of the account which will send the deployment transaction. With a valid `.env` file in place, first deploy your contract:

```shell
hardhat run --network fuji scripts/deploy.ts
```

Then, copy the deployment address and paste it in to replace `DEPLOYED_CONTRACT_ADDRESS` and `CONSTRUCTOR_ARGUMENTS` if needed in this command:

```shell
npx hardhat verify --network fuji DEPLOYED_CONTRACT_ADDRESS CONSTRUCTOR_ARGUMENTS
```

## Documentation

There is a documentation under the Avalanche's official documentation repository:
[Using Hardhat with the Avalanche C-Chain](https://docs.avax.network/build/tutorials/smart-contracts/using-hardhat-with-the-avalanche-c-chain)
[Using Hardhat with the Avalanche C-Chain](https://docs.avax.network/build/tutorials/smart-contracts/using-hardhat-with-the-avalanche-c-chain)
2 changes: 2 additions & 0 deletions env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SNOWTRACE_API_KEY=
PRIVATE_KEY=
13 changes: 10 additions & 3 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import * as dotenv from "dotenv";
import { task } from "hardhat/config"
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers"
import { BigNumber } from "ethers"
import "@nomiclabs/hardhat-waffle"
import "@nomiclabs/hardhat-etherscan";

dotenv.config();

// When using the hardhat network, you may choose to fork Fuji or Avalanche Mainnet
// This will allow you to debug contracts using the hardhat network while keeping the current network state
Expand Down Expand Up @@ -81,13 +85,16 @@ export default {
url: 'https://api.avax-test.network/ext/bc/C/rpc',
gasPrice: 225000000000,
chainId: 43113,
accounts: []
accounts: process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
},
mainnet: {
url: 'https://api.avax.network/ext/bc/C/rpc',
gasPrice: 225000000000,
chainId: 43114,
accounts: []
accounts: process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
}
},
etherscan: {
apiKey: process.env.SNOWTRACE_API_KEY !== undefined ? process.env.SNOWTRACE_API_KEY : "",
}
}
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
"name": "avalanche-smart-contract-quickstart",
"devDependencies": {
"@nomiclabs/hardhat-ethers": "^2.0.2",
"@nomiclabs/hardhat-etherscan": "^2.1.8",
"@nomiclabs/hardhat-waffle": "^2.0.1",
"@openzeppelin/contracts": "^4.3.0",
"@types/chai": "^4.2.21",
"@types/mocha": "^9.0.0",
"@types/node": "^16.7.1",
"avalanche": "3.8.5",
"chai": "^4.3.4",
"dotenv": "^10.0.0",
"ethereum-waffle": "^3.4.0",
"ethereumjs-tx": "^2.1.2",
"ethers": "^5.4.5",
Expand Down
Loading