etherjs (5.0) is used to deployed a smart contract Hello.sol
. Here is the js code (truffle 5.1.52/ganache CLI 6.12.1):
import { ContractFactory, ethers } from "ethers";
let privateKey = "0xf43608a210da70d40115ad23526e50f2a502c018aeffd56477fcbe44119b53cc"; //<<==private key from ganache-cli
let wallet = new ethers.Wallet(privateKey); //address of the wallet
console.log("wallet : ", wallet);
//deploy
const factory = new ContractFactory(abi, bytecode, signer); //<<==abi, bytecode, signer defined before
const contract = await factory.deploy(wallet.address);
console.log("contract deployed : ", contract);
console.log("contract address : ", contract.address);
// The transaction that the signer sent to deploy
contract.deployTransaction;
// Wait until the transaction is mined
contract.deployTransaction.wait();
The execution of code above generates the output on ganache-cli -b 3
:
Transaction: 0xbbd7dfd7272cee291a2d1e62ac51e32dd99c98dacb44d04f1ae4bd50487f35b7
Contract created: 0x03734542501c30e1ea22d6ddcb876e84eaa99381
Gas usage: 92522
Block Number: 2594
Block Time: Thu Nov 12 2020 14:37:36 GMT-0800 (Pacific Standard Time)
The contract is deployed at the address of 0x03734542501c30e1ea22d6ddcb876e84eaa99381
.
truffle
is started with truffle development
. command networks
generates the following output:
truffle(development)> networks
Network: develop (id: 5777)
No contracts deployed.
Why truffle doesn't find the contract deployed above?