You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi @yinchonging, I followed the above steps using this code with the Lock sample contract and was able to get the log output. It looks like the function selector is not being recognized, and, as such, the transaction is reverting. Are you sure you're calling the right method? Can you provide a minimal reproducible example?
import { ethers, artifacts } from "hardhat";
import { time } from "@nomicfoundation/hardhat-toolbox/network-helpers";
const JAN_1ST_2030 = 1893456000;
async function main() {
const abi = (await artifacts.readArtifact("Lock")).abi;
const wsprovider = new ethers.WebSocketProvider("ws://127.0.0.1:8545/");
const signer = await wsprovider.getSigner();
const wscontract = new ethers.Contract(
"0x5FbDB2315678afecb367f032d93F642f64180aa3",
abi,
signer
);
await time.increaseTo(JAN_1ST_2030 + 1);
await wscontract.on("Withdrawal", (amount, when) => {
console.log(`Withdrawal of ${amount} at ${when}`);
});
const txResponse = await wscontract.withdraw();
await txResponse.wait();
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
Hi @yinchonging, I'm closing this issue for now since the example you provided seems to be working on my end and we haven't received any additional information from you. I'm happy to reopen it if you can provide more details. Thanks!
Version of Hardhat
2.22.2
What happened?
The hardhat node subscription event is not working
Minimal reproduction steps
Step1 (Start hardhat node):
Step2 (Deploy contract):
Step3 (Add listener):
Step4 (Hardhat logs show that the subscription was successful):
Step5(The event was not emitted after being called):
How to solve this problem? Thanks!!!
Search terms
No response
The text was updated successfully, but these errors were encountered: