这是一个非常小的存储库来显示该问题:https ://github.com/adamdry/ethers-event-issue
但我也会在这里解释一下。这是我的合同:
//SPDX-License-Identifier: UNLICENSED;
pragma solidity 0.8.4;
contract ContractA {
event TokensMinted(uint amount);
function mint(uint amount) public {
emit TokensMinted(amount);
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的测试代码:
import * as chai from 'chai'
import { BigNumber, ContractTransaction } from 'ethers'
import { ethers } from 'hardhat'
import { ContractA, ContractAFactory } from '../typechain'
const expect = chai.expect
describe("Example test", function () {
it("should fire the event", async function () {
const [owner] = await ethers.getSigners();
const contractAFactory = (await ethers.getContractFactory(
'ContractA',
owner, …Run Code Online (Sandbox Code Playgroud)