2023-04-05 04:55:50 +00:00
|
|
|
import { task } from 'hardhat/config'
|
|
|
|
import '@nomiclabs/hardhat-ethers'
|
|
|
|
|
|
|
|
task(
|
|
|
|
'verify-contract-deployment',
|
|
|
|
'Verifies the given contract deployment transaction'
|
|
|
|
)
|
|
|
|
.addParam('contract', 'Address of the contract deployed')
|
|
|
|
.addParam('transactionHash', 'Hash of the deployment transaction')
|
|
|
|
.setAction(async ({ contract, transactionHash }, { ethers }) => {
|
|
|
|
const provider = new ethers.providers.JsonRpcProvider(
|
2023-04-11 10:51:03 +00:00
|
|
|
`${process.env.CERC_L1_RPC}`
|
2023-04-05 04:55:50 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Get the deployment tx receipt
|
|
|
|
const receipt = await provider.getTransactionReceipt(transactionHash)
|
|
|
|
if (
|
|
|
|
receipt &&
|
|
|
|
receipt.contractAddress &&
|
|
|
|
receipt.contractAddress === contract
|
|
|
|
) {
|
|
|
|
console.log(
|
|
|
|
`Deployment for contract ${contract} in transaction ${transactionHash} verified`
|
|
|
|
)
|
|
|
|
process.exit(0)
|
|
|
|
} else {
|
|
|
|
console.log(`Contract ${contract} deployment verification failed`)
|
|
|
|
process.exit(1)
|
|
|
|
}
|
|
|
|
})
|