ethers.js
ethers.js copied to clipboard
unknown fragment
Ethers Version
6.12.0
Search Terms
No response
Describe the Problem
Hi, I'm trying to listen for events, I'm using ethers v6.12.1, node js 18.16.1. I've tried suggested fixes from issues raised earlier and even downgraded the package, I got another error. Please what could be the issue?
Code Snippet
const provider = new ethers.WebSocketProvider("wss://mainnet.infura.io/ws/v3/....");
const tokenContract = new ethers.Contract("0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe", [//abi],provider)
tokenContract.on('Transfer', (from, to, value) => {
console.log("transfer from===", from, "===to====", to, "===value===", value)
});
Contract ABI
[
{
"constant": false,
"inputs": [
{
"name": "_owner",
"type": "address"
}
],
"name": "removeOwner",
"outputs": [],
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_addr",
"type": "address"
}
],
"name": "isOwner",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "m_numOwners",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"type": "function"
},
{
"constant": false,
"inputs": [],
"name": "resetSpentToday",
"outputs": [],
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_owner",
"type": "address"
}
],
"name": "addOwner",
"outputs": [],
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "m_required",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_h",
"type": "bytes32"
}
],
"name": "confirm",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_newLimit",
"type": "uint256"
}
],
"name": "setDailyLimit",
"outputs": [],
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_to",
"type": "address"
},
{
"name": "_value",
"type": "uint256"
},
{
"name": "_data",
"type": "bytes"
}
],
"name": "execute",
"outputs": [
{
"name": "_r",
"type": "bytes32"
}
],
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_operation",
"type": "bytes32"
}
],
"name": "revoke",
"outputs": [],
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_newRequired",
"type": "uint256"
}
],
"name": "changeRequirement",
"outputs": [],
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "_operation",
"type": "bytes32"
},
{
"name": "_owner",
"type": "address"
}
],
"name": "hasConfirmed",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_to",
"type": "address"
}
],
"name": "kill",
"outputs": [],
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_from",
"type": "address"
},
{
"name": "_to",
"type": "address"
}
],
"name": "changeOwner",
"outputs": [],
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "m_dailyLimit",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "_owners",
"type": "address[]"
},
{
"name": "_required",
"type": "uint256"
},
{
"name": "_daylimit",
"type": "uint256"
}
],
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"name": "owner",
"type": "address"
},
{
"indexed": false,
"name": "operation",
"type": "bytes32"
}
],
"name": "Confirmation",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"name": "owner",
"type": "address"
},
{
"indexed": false,
"name": "operation",
"type": "bytes32"
}
],
"name": "Revoke",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"name": "oldOwner",
"type": "address"
},
{
"indexed": false,
"name": "newOwner",
"type": "address"
}
],
"name": "OwnerChanged",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"name": "newOwner",
"type": "address"
}
],
"name": "OwnerAdded",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"name": "oldOwner",
"type": "address"
}
],
"name": "OwnerRemoved",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"name": "newRequirement",
"type": "uint256"
}
],
"name": "RequirementChanged",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"name": "_from",
"type": "address"
},
{
"indexed": false,
"name": "value",
"type": "uint256"
}
],
"name": "Deposit",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"name": "owner",
"type": "address"
},
{
"indexed": false,
"name": "value",
"type": "uint256"
},
{
"indexed": false,
"name": "to",
"type": "address"
},
{
"indexed": false,
"name": "data",
"type": "bytes"
}
],
"name": "SingleTransact",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"name": "owner",
"type": "address"
},
{
"indexed": false,
"name": "operation",
"type": "bytes32"
},
{
"indexed": false,
"name": "value",
"type": "uint256"
},
{
"indexed": false,
"name": "to",
"type": "address"
},
{
"indexed": false,
"name": "data",
"type": "bytes"
}
],
"name": "MultiTransact",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"name": "operation",
"type": "bytes32"
},
{
"indexed": false,
"name": "initiator",
"type": "address"
},
{
"indexed": false,
"name": "value",
"type": "uint256"
},
{
"indexed": false,
"name": "to",
"type": "address"
},
{
"indexed": false,
"name": "data",
"type": "bytes"
}
],
"name": "ConfirmationNeeded",
"type": "event"
}
]
Errors
/node_modules/ethers/src.ts/utils/errors.ts:687
error = new TypeError(message);
^
TypeError: unknown fragment (argument="event", value="Transfer", code=INVALID_ARGUMENT, version=6.12.1)
at makeError (/home/budescode/Documents/CODING/PROJECTS/Bitfornaira/web/Bitfornaira/node_modules/ethers/src.ts/utils/errors.ts:687:21)
at assert (/home/budescode/Documents/CODING/PROJECTS/Bitfornaira/web/Bitfornaira/node_modules/ethers/src.ts/utils/errors.ts:715:25)
at assertArgument (/home/budescode/Documents/CODING/PROJECTS/Bitfornaira/web/Bitfornaira/node_modules/ethers/src.ts/utils/errors.ts:727:5)
at getSubInfo (/home/budescode/Documents/CODING/PROJECTS/Bitfornaira/web/Bitfornaira/node_modules/ethers/src.ts/contract/contract.ts:496:27)
at getSub (/home/budescode/Documents/CODING/PROJECTS/Bitfornaira/web/Bitfornaira/node_modules/ethers/src.ts/contract/contract.ts:545:45)
at Proxy.on (/home/budescode/Documents/CODING/PROJECTS/Bitfornaira/web/Bitfornaira/node_modules/ethers/src.ts/contract/contract.ts:969:27)
at Object.createCryptoWallet (/home/budescode/Documents/CODING/PROJECTS/Bitfornaira/web/Bitfornaira/src/controllers/api/crypto/crypto.controller.ts:512:23)
at preHandlerCallback (/home/budescode/Documents/CODING/PROJECTS/Bitfornaira/web/Bitfornaira/node_modules/fastify/lib/handleRequest.js:137:37)
at next (/home/budescode/Documents/CODING/PROJECTS/Bitfornaira/web/Bitfornaira/node_modules/fastify/lib/hooks.js:233:9)
at handleResolve (/home/budescode/Documents/CODING/PROJECTS/Bitfornaira/web/Bitfornaira/node_modules/fastify/lib/hooks.js:250:7) {
code: 'INVALID_ARGUMENT',
argument: 'event',
value: 'Transfer',
shortMessage: 'unknown fragment'
}
Environment
Ethereum (mainnet/ropsten/rinkeby/goerli), node.js (v12 or newer)
Environment (Other)
No response