I have created some tasks using the hardhat template. However, I got some tasks that do not require the fhevm to be instantiate to execute them. For instance if I need to pause a contract, I simply want to execute the following code:
task("task:pause", "Pauses the contract")
.addParam("contractaddress", "Address of the contract to pause")
.setAction(async (taskArgs, hre) => {
const { ethers } = hre;
const contract = await ethers.getContractAt("MyContract", taskArgs.auctionaddress);
const tx = contract.pause()
tx.wait();
});
This works pretty well only when the transaction is not reverted. If it is, then we will not fallback on the revert error, but instead on an error from the fhevm plugin that is not initialized.
Revert reason: The Hardhat Fhevm plugin is not initialized.
Error in plugin @fhevm/hardhat-plugin: The Hardhat Fhevm plugin is not initialized.
HardhatFhevmError: The Hardhat Fhevm plugin is not initialized.
at Proxy.getContractsRepository (/.../node_modules/@fhevm/hardhat-plugin/src/internal/FhevmEnvironment.ts:451:13)
at __formatFhevmErrorMessages (/.../node_modules/@fhevm/hardhat-plugin/src/internal/errors/FhevmContractError.ts:420:24)
at __mutateFhevmErrorAndPrintBox (/.../node_modules/@fhevm/hardhat-plugin/src/internal/errors/FhevmContractError.ts:399:22)
at mutateProviderErrorInPlace (/.../node_modules/@fhevm/hardhat-plugin/src/internal/errors/FhevmContractError.ts:389:9)
at FhevmProviderExtender._handleEthEstimateGas (/.../node_modules/@fhevm/hardhat-plugin/src/internal/provider/FhevmProviderExtender.ts:148:39)
at processTicksAndRejections (node:internal/process/task_queues:105:5)
at async HardhatEthersProvider.estimateGas (/.../node_modules/@nomicfoundation/hardhat-ethers/src/internal/hardhat-ethers-provider.ts:246:27)
at async /.../node_modules/@nomicfoundation/hardhat-ethers/src/signers.ts:335:35
at async Promise.all (index 0)
at async HardhatEthersSigner._sendUncheckedTransaction (/.../node_modules/@nomicfoundation/hardhat-ethers/src/signers.ts:356:7)
Where the errors seems link here, as it is not defined.
public getContractsRepository(): contracts.FhevmContractsRepository {
if (!this._contractsRepository) {
throw new HardhatFhevmError(`The Hardhat Fhevm plugin is not initialized.`);
}
return this._contractsRepository;
}
Do not know if we could eventually have a work around for this, or if in all the cases we need to instantiate the fhevm module, which make no sense in some situation where you do not need it but could be block to execute your transaction because you need to load it first. Especially sometimes when the relayer is not available.
I have created some tasks using the hardhat template. However, I got some tasks that do not require the fhevm to be instantiate to execute them. For instance if I need to pause a contract, I simply want to execute the following code:
This works pretty well only when the transaction is not reverted. If it is, then we will not fallback on the revert error, but instead on an error from the fhevm plugin that is not initialized.
Where the errors seems link here, as it is not defined.
Do not know if we could eventually have a work around for this, or if in all the cases we need to instantiate the fhevm module, which make no sense in some situation where you do not need it but could be block to execute your transaction because you need to load it first. Especially sometimes when the relayer is not available.