2022-01-28 05:52:54 -08:00
# Contract verification
The various EVM explorer sites (etherscan, bscscan, etc.) support contract
verification. This essentially entails uploading the source code to the site,
and they verify that the uploaded source code compiles to the same bytecode
that's actually deployed. This enables the explorer to properly parse the
transaction payloads according to the contract ABI.
This document outlines the process of verification. In general, you will need an
API key for the relevant explorer (this can be obtained by creating an account),
and also know which address the contract code lives. The API key is expected to
be set in the `ETHERSCAN_KEY` environment variable for all APIs (not just
etherscan, bit of a misnomer).
Our contracts are structured as a separate proxy and an implementation. Both of
2022-11-24 05:14:29 -08:00
these components need to be verified, and truffle handles it.
2022-01-28 05:52:54 -08:00
2022-09-09 23:35:07 -07:00
## Verifying the contract
2022-01-28 05:52:54 -08:00
2022-09-09 23:35:07 -07:00
Our contract is called `PythUpgradable` . To verify it on e.g. avalanche, at contract address `0x0e082F06FF657D94310cB8cE8B0D9a04541d8052` , run
2022-01-28 05:52:54 -08:00
```
2022-09-09 23:35:07 -07:00
ETHERSCAN_KEY=... npm run verify --module=PythUpgradable --contract_address=0x0e082F06FF657D94310cB8cE8B0D9a04541d8052 --network=avalanche
2022-01-28 05:52:54 -08:00
```
(Note: the network name comes from the `truffle-config.json` ).
(Note: In this case, the `ETHERSCAN_KEY` is your snowtrace API key).
2022-09-09 23:35:07 -07:00
**You might need to add the the explorer api keys in [the truffle config ](./truffle-config.js ) `api_keys` .** Please look at
`truffle-plugin-verify/utils.js` to find the key names.
2022-01-28 05:52:54 -08:00
# Note
2022-11-24 05:14:29 -08:00
2022-01-28 05:52:54 -08:00
The `npm run verify` script uses the `truffle-plugin-verify` plugin under the
2022-11-24 05:14:29 -08:00
hood. The version of `truffle-plugin-verify` pinned in the repo (`^0.5.11` at
2022-01-28 05:52:54 -08:00
the time of writing) doesn't support the avalanche RPC. In later versions of the
plugin, support was added, but other stuff has changed as well in the transitive
dependencies, so it fails to parse the `HDWallet` arguments in our
`truffle-config.json` . As a quick workaround, we backport the patch to `0.5.11`
2022-11-24 05:14:29 -08:00
by applying the `truffle-verify-constants.patch` file, which the `npm run verify` script does transparently. Once the toolchain has been upgraded and the
2022-01-28 05:52:54 -08:00
errors fixed, this patch can be removed.