2

I want to deploy smart contracts on front-end with metamask address as deployer. To do that, I first compile the smart contract with Remix and put the json output on my React project (I use Ganache to deploy locally).

After that, I follow the erthers.js doc as follow:

const provider = new ethers.providers.Web3Provider(window.ethereum);
await provider.send("eth_requestAccounts", []);
const signer = provider.getSigner()

factory = new ContractFactory(ContractJson.abi, ContractJson.data.bytecode, signer)
contract = await factory.deploy("Test", "TT");
console.log(contract.address)
console.log(contract.deployTransaction)
console.log(await contract.deployTransaction.wait())

At execution nothing is logged and the contract is not deployed.

Do you have any idea what I am doing wrong/missing? Thanks.

1 Answer 1

0

I had the same problem. I used the Hardhat local node and I was trying to send a transaction via MetaMask. MetaMask didn't notify me that it couldn't connect to the local node and just silently waited forever.

To fix this, ensure that there is a connection to your node from MetaMask:

  1. Add a network into MetaMask with the correct RPC URL (e.g. http://localhost:8545/) and Chain ID (e.g. 31337).
  2. Switch to that network in MetaMask.
  3. Ensure that the local node is running (e.g. run npx hardhat node)
  4. Ensure that it is reachable (e.g. check via curl localhost:8545)

Also check the web console, maybe there are some error messages.

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.