Hi, I have this problem with hardhat in Typescript with the library to make updates.

scripts/deploy.ts:1:18 - error TS2305: Module '"hardhat"' has no exported member 'upgrades'.

1 import { ethers, upgrades } from "hardhat"


any suggestions?

thanks

Dec 13, 2021, 11:45 AM
require('@openzeppelin/hardhat-upgrades');
Dec 13, 2021, 12:05 PM
👍, now I have this error
TypeError: Cannot read property 'deployProxy' of undefined

My code:
import {ethers, upgrades} from "hardhat"
import '@openzeppelin/hardhat-upgrades';

import readline from "readline"

async function deployNFT(privateKey:string) {
const wallet = new ethers.Wallet(privateKey, ethers.provider)
// Deploying
const WSN = await ethers.getContractFactory("WonklySocial", wallet);
const instance = await upgrades.deployProxy(WSN, [wallet]);
await instance.deployed();

console.log("Wonkly deployed to:", instance.address)
console.log("Owner:", instance.deployTransaction.from)

}
Dec 13, 2021, 12:07 PM
i think you have to use require itself, not import
And put that above hardhat upgrades import
Dec 13, 2021, 12:09 PM
with require I have the same error, in rare
Dec 13, 2021, 12:12 PM
Maybe you don't have hardhat-upgrades installed?
Dec 13, 2021, 12:13 PM
Dec 13, 2021, 12:18 PM
const { deployProxy } = require('@openzeppelin/hardhat-upgrades');
Try this then
That contract only exists on ethereum, not bsc
Huh how did that even go through... I thought you can't call methods on a non contract
Dec 13, 2021, 12:40 PM
I have tried as you say, but I get this error:

(node:28105) UnhandledPromiseRejectionWarning: TypeError: deployProxy is not a function
Dec 13, 2021, 12:53 PM
Ooh mb mb. You put this one on deploy script right?
It should be on hardhat config
Dec 13, 2021, 12:57 PM
i am surprised it went through on bsc.
Dec 13, 2021, 12:57 PM
I use it on truffle, and truffle have it inside migrator script
I prefer truffle because I used it from the beginning and too lazy to migrate to hardhat xD
But hardhat is better
Dec 13, 2021, 1:29 PM
const { ethers, upgrades } = require("hardhat");
import '@openzeppelin/hardhat-upgrades';

// import readline from "readline"

async function deployNFT(privateKey:string) {
const wallet = new ethers.Wallet(privateKey, ethers.provider)
// Deploying
const WSN = await ethers.getContractFactory("Box", wallet);
const instance = await upgrades.deployProxy(WSN);
await instance.deployed();
console.log("Wonkly deployed to:", instance.address)
console.log("Owner:", instance.deployTransaction.from)
}
always the same error:

(node:32037) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'deployProxy' of undefined
Dec 13, 2021, 2:05 PM
@damianlluch
Dec 13, 2021, 2:05 PM
In Truffle it uses the extension for upgradeable, and I haven't had any problems, but in Hardhat and Typescript, I've been losing time for hours c
Dec 13, 2021, 2:06 PM
Put

require('@openzeppelin/hardhat-upgrades');

Inside hardhat.config.js
Yeah because on truffle you put it in migration script. But for hardhat, it should be inside harhat config
Dec 13, 2021, 2:07 PM

© 2024 Draquery.com All rights reserved.