I have smartcontract from HardHat tutorial https://hardhat.org/tutorial/writing-and-compiling-contracts.html
and I successfully deployed it.
async function main() {
const [deployer] = await ethers.getSigners();
console.log("Deploying contracts with the account:", deployer.address);
console.log("Account balance:", (await deployer.getBalance()).toString());
const Token = await ethers.getContractFactory("Token");
const token = await Token.deploy();
console.log("Token address:", token.address);
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
But only the address of the contact is returned to me and its private key is not.
console.log("Deploying contracts with the account:", deployer.address);
How can I get the private key in this way? I need it for the method
web3.eth.accounts.wallet.add('0x<private_key>');
Because otherwise I can't call the transfer method on the smart contract.