Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Contract deployed at undefined #6711

Copy link
Copy link
Open
@MustafaMansoor

Description

@MustafaMansoor
Issue body actions

Discussed in #6710

Originally posted by MustafaMansoor August 10, 2024
Hi,
In the tutorial, the deployment was done on Rinkeby, but since it was deprecated, I decided to deploy on the Sepolia testnet. I added my API key from MetaMask and selected the Sepolia network in Alchemy. However, I'm encountering an issue where the contract address shows as undefined after deployment. The transaction amount is being deducted from my MetaMask, so I believe the contract is being deployed, but I can't figure out what's causing the issue. Any help would be appreciated.

here is the code

const ethers = require("ethers");
const fs = require("fs-extra");
require("dotenv").config();

const main = async () => {
  const provider = new ethers.JsonRpcProvider(process.env.URL);

  const wallet = new ethers.Wallet(process.env.PRIVATE_KEY, provider);

  const abi = fs.readFileSync("./simpleStorage_sol_SimpleStorage.abi", "utf8");
  const binary = fs.readFileSync(
    "./simpleStorage_sol_SimpleStorage.bin",
    "utf8"
  );

  const contractFac = new ethers.ContractFactory(abi, binary, wallet);
  console.log("Deploying contract, please wait...");

  const contract = await contractFac.deploy();

  // Wait for the contract deployment to be mined
  await contract.waitForDeployment("1");

  // Now the address should be available
  console.log(`Contract deployed at ${contract.address}`);

  // Retrieve the initial value stored in the contract
  // const res = await contract.retrieve();
  // console.log("Initial retrieved value:", res.toString());

  // // Store a new value
  // const TransRes = await contract.store("1217");
  // await TransRes.wait(); // Wait for 1 confirmation
  // console.log("New value stored.");

  // // Retrieve the updated value
  // const update = await contract.retrieve();
  // console.log("Updated retrieved value:", update.toString());
};

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

and here is the error

Deploying contract, please wait...
Contract deployed at undefined

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.