Aanchal Bhatti
Aanchal Bhatti

Reputation: 1

Using web3.js' getPastEvents() in TypeScript gives "No overload matches this call" error

I want to fetch past events for compound v2 protocol using the following function:

// Retrieve past events using getPastLogs method
const pastEvents = await contract.getPastEvents(
    'Mint',
    {
        fromBlock: Number(blockNumber) - 4000,
        toBlock: "latest",
    },
);

where my abi has this:

{
    "anonymous": false,
    "inputs": [
        {
            "indexed": false,
            "name": "minter",
            "type": "address"
        },
        {
            "indexed": false,
            "name": "mintAmount",
            "type": "uint256"
        },
        {
            "indexed": false,
            "name": "mintTokens",    //cUSDC token he got in return of supplying usdc
            "type": "uint256"
        }
    ],
    "name": "Mint",
    "type": "event"
},

but this gives me the following error:

No overload matches this call.
  Overload 1 of 4, '(eventName: "allEvents" | "ALLEVENTS", returnFormat?: DataFormat | undefined): Promise<(string | EventLog)[]>', gave the following error.
    Argument of type '"Mint"' is not assignable to parameter of type '"allEvents" | "ALLEVENTS"'.
  Overload 2 of 4, '(filter: Omit<Filter, "address">, returnFormat?: DataFormat | undefined): Promise<(string | EventLog)[]>', gave the following error.
    Type '"Mint"' has no properties in common with type 'Omit<Filter, "address">'.
  Overload 3 of 4, '(eventName: "allEvents" | "ALLEVENTS", filter: Omit<Filter, "address">, returnFormat?: { readonly number: FMT_NUMBER.BIGINT; readonly bytes: FMT_BYTES.HEX; } | undefined): Promise<...>', gave the following error.
    Argument of type '"Mint"' is not assignable to parameter of type '"allEvents" | "ALLEVENTS"'.ts(2769)

How can I fix this error?

Upvotes: 0

Views: 94

Answers (0)

Related Questions