I am trying to import a third party library in my autotask code. I am currently using ethers.js and I would like to import the hardhat library. Is this possible under the current infrastructure? While importing the libraries, I get an error that my module could not be found.
Hey @vsvs! Autotasks run with a set of pre-installed dependencies (listed here), but hardhat-ethers is not among those. You can work around this by bundling the dependency with your code, using something like rollup (sample project here).
However, I’d like to better understand your use case, to see if it makes sense to include hardhat-ethers right out of the box. What are you trying to do from your Autotask that depends on hardhat-ethers?
Hello!
Im trying to create a script to run the job YearKeep3rProxyJob.
I am using a snippet which uses the helper method getContractAt() and a second one called getWorkData(), which I assume is also a helper method. I am new to this and I am not really sure with what to substitute each of these methods in order to write the script without the hardhat dependency. Any guidance on this would be quite appreciated. Documentation would also help a lot.
You can replace getContractAt by creating a new ethers contract object, like:
const myContract = new ethers.Contract(address, abi, signer);
The address is the address of the contract, and the abi object you can get from the build output (usually in the artifacts folder) or directly from Etherscan (if the contract source code has been verified).
As for the signer, you can link your Autotask to a Defender Relayer, and use:
I think that getWorkData is a function from the YearKeep3rProxyJob contract, not an addition from the hardhat plugin. If the function is defined in the contract’s abi, then you’ll be able to call it normally on the myContract instance.