6

I'm passing the contract address from a bash script export CONTRACT_ADDRESS I verified contractAddress has the correct value in my javascript, but I'm getting NotImplementedError: Method 'HardhatEthersProvider.resolveName' is not implemented Previously if I had it in a .env file, everything was working as expected

Below is my script

require("dotenv").config();
const hre = require("hardhat");

async function main() { const value = process.env.VALUE; const contractAddress = process.env.CONTRACT_ADDRESS;

const MyContract = await hre.ethers.getContractFactory("GetterSetter");
const myContract = MyContract.attach(contractAddress);

await myContract.setBytes32(value);

console.log("Set the value to:", value);

}

main().catch((error) => { console.error(error); process.exitCode = 1; });

user125051
  • 73
  • 3
  • I had the same issue and it was because it couldnt resolved the address, I suggest you check for whitespaces or anything that can make it different – Julissa DC Aug 24 '23 at 22:27

2 Answers2

0

You are calling constructor on wrong way.

 constructor(
        address _lzEndpoint,
        string memory _name,
        string memory _symbol,
        uint8 decimal
    ) OFTWithFee(_name, _symbol, decimal, _lzEndpoint) {}

for example if you call above constructor with wrong arguments like

const lock = await hre.ethers.deployContract("RushOFT", [
    "Optimism",
    "Optimism",
    "18",
"0xae92d5aD7583AD66E49A0c67BAd18F6ba52dDDc1",
  ]);

it will throw this error

-1

This Error generally indicates that you are not using address or addresses in constructor properly. you are using the wrong keyword in constructor at the time of deploy. you should use the keyword that include address or you can also use direct address. I think..

in my case this was the issue. i resolved this issue using addresses in constructor().