blockchainethers.jscontract

How to get contract deployer address using ethers.js?


I wanna know the way to get contract deployer address after contract deployed.

let contract = await factory.deploy
 (name, name + "NFT");
 await contract.deployed();
 let deployer = contract.deployTransaction.from;

I can get deployer using deploy contract. But I need to get in backend. Looking forward to hearing from you.

Thank you :)


Solution

  • Here you have a working example:

    import { ethers } from "hardhat";
    
      async function main() {
        const Contract = await ethers.getContractFactory("Contract");
        const contract = await Contract.deploy();
        await contract.deployed();
        
        console.log("Contract deployed to: ", contract.address);    
        
        }
        
      main().catch((error) => {
        console.error(error);
        process.exitCode = 1;
      });