Replies: 3 comments 5 replies
-
Are you using v1.1.0? Support for factories has been added in that release. Just make sure that the Example for how to use the factories in a Hardhat task, assuming that import { YourContract__factory} from "your-package/typechain/factories/YourContract__factory";
import { task } from "hardhat/config";
task("deploy:YourContract").setAction(async function (_, { ethers }) {
const signers: SignerWithAddress[] = await ethers.getSigners();
const chainlinkOperatorFactory: YourContract__factory = new YourContract__factory(signers[0]);
const yourContract: YourContract = await yourContractFactory.deploy();
await yourContract.deployed();
console.log("YourContract deployed to: ", yourContract.address);
}); |
Beta Was this translation helpful? Give feedback.
-
Ok so I found a solution:
4 - |
Beta Was this translation helpful? Give feedback.
-
I was scouring the web for a way to publish TypeScript code to the npm registry, and make it possible to import it directly from there. But it looks like only JavaScript is supported for now. I will prevent the TypeChain factories from being included by default, and I will update the README to explain how to handle them. This is not such a straightforward a matter as I had initially thought. Once again, thanks @sshmaxime for your updates. |
Beta Was this translation helpful? Give feedback.
-
At first, I thought that the idea of the packager was to expose classes from the typechain to a npm package way in order to import the typechain anywhere (another hh project maybe) and just call new on a factory right away. But this plugin doesn't (yet ?). Any plans on that in the future ? Cause I see that you are exporting abi, bytecode and then recreating the factory in your exemples. I've tried myself to publish a hardhat project to npm and exposing as well the typechain directly but it doesn't seems to work when importing from another hardhat project. All i'm getting is either
SyntaxError: Unexpected token 'export'
orSyntaxError: Cannot use import statement outside a module
. It's a common error, I know, but I cannot make it workBeta Was this translation helpful? Give feedback.
All reactions