0

I'm encountering difficulties deploying a smart contract using Hardhat. In my deployment script, I'm using ethers.getContractFactory().deploy() to deploy the BinaryvilleRobotsNFT contract. However, the deployment process seems to be failing, as I'm not receiving any output for the contract address. Additionally, I've attempted to retrieve deployment-related information using getDeployedCode() from other stack exchange answers, but without success.

I need guidance on troubleshooting this issue. Are there any common pitfalls or configurations that might be causing the deployment to fail? I'd appreciate any insights or suggestions on how to diagnose and resolve this problem effectively.

mint-script-js

const { ethers } = require("hardhat");

async function main() {
  const BinaryvilleRobotsNFT = await ethers.getContractFactory("BinaryvilleRobotsNFT");
  const robotNFT = await BinaryvilleRobotsNFT.deploy();

  // const receipt = await robotNFT.getDeployedCode()
  
  // Extract contract address from the receipt
  const contractAddress = robotNFT.getAddress();
  
  console.log("BinaryvilleRobotsNFT deployed to:", contractAddress);
}

main()
  .then(() => process.exit(0))
  .catch((error) => {
    console.error(error);
    process.exit(1);
  });

Error:

BinaryvilleRobotsNFT deployed to: undefined // when I did some research on stack exchange
BinaryvilleRobotsNFT deployed to: Promise { <pending> } // when I use getdeployedCode()

1 Answer 1

0

As, getAddress() is returning Promise { <pending> }. You need to add await before that too, in order to wait for it to return the actual address value.

const contractAddress = await robotNFT.getAddress();
2
  • Hey thanks! It worked
    – varun_63
    Commented Apr 1 at 11:00
  • @varun_63, you're welcome. Kindly please accept the answer then. Thanks. Commented Apr 1 at 11:03

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.