0

Lets say I have a 00-mocks.ts file inside a deploy folder(hardhat project) and the code looks ok:


const { ethers, newtwork } = require('hardhat')


module.exports =  async function () {
    try {
        const accounts = await ethers.getSigners()
        console.log(accounts);
        const token = await ethers.getContractFactory("Token")
        const instance = await token.deploy("testTokenName","testSymbol")
        await instance.deployed()
    } catch (error) {
        console.log(error);
    }
 
}
module.exports.tags = ["all", "Token"]

But the problem is when i run my node using yarn hardhat node my token doesn't deploy, and i can't see my logs, but node runs and it gives me signers with first balance of ETH. I've used exact same code in JS and it works, but i don't know whats the problem with typeScript.

Even i tried to use it as a script using this command: yarn hardhat run scripts/"filename".ts --network localhost But still doesn't work.

1
  • try npx hardhat run scripts/"filename".ts --network localhost instead
    – Adam Boudj
    Mar 23, 2023 at 12:51

1 Answer 1

0

You should check your hardhat configuration files once, make sure all the chainId and url are correct. Then it should have work.

9
  • Actually I'm using yarn package manager, But still i installed this package that you mentioned but result is same, still i cant see my deployments and my logs
    – Alireza
    Mar 25, 2023 at 12:25
  • Don't use yarn use npx or npm because there recently there are few new changes in hardhat which yarn doesn't support.
    – Yana Gupta
    Mar 26, 2023 at 4:38
  • Then should I run node with : npx hardhat node ?
    – Alireza
    Mar 26, 2023 at 5:44
  • No delete your yarn.lock file and install all the dependencies with npm, then use command npx hardhat to see if you can actually use node.
    – Yana Gupta
    Mar 26, 2023 at 14:09
  • Still doesn't work, it compile my contracts but do not run script
    – Alireza
    Mar 27, 2023 at 17:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.