ethers.js
ethers.js copied to clipboard
EthersV6: Maximum call stack size exceeded
Ethers Beta Version
6.0.0-beta.9
Describe the Problem
When trying to create a Contract object, an error occurs if ABI generated by solidity compiler is passed.
I've noted that this issue is not observed if human readable ABI is used ["function getValue() view returns (string)"]
.
Code Snippet
import { Contract } from "ethers";
const abi = [
{
inputs: [],
name: "getValue",
outputs: [{ internalType: "string", name: "", type: "string" }],
stateMutability: "view",
type: "function",
},
];
const contract = new Contract(
"0x0000000000000000000000000000000000000000",
abi
); // this line causes the issue
Errors
% node contract.js
file:///Users/sohamzemse/Workspace/ethers-v6/node_modules/@ethersproject/abi/lib/fragments.js:650
switch (obj.type) {
^
RangeError: Maximum call stack size exceeded
at Function.fromObject (file:///Users/sohamzemse/Workspace/ethers-v6/node_modules/@ethersproject/abi/lib/fragments.js:650:21)
at Function.fromObject (file:///Users/sohamzemse/Workspace/ethers-v6/node_modules/@ethersproject/abi/lib/fragments.js:654:54)
at Function.fromObject (file:///Users/sohamzemse/Workspace/ethers-v6/node_modules/@ethersproject/abi/lib/fragments.js:654:54)
at Function.fromObject (file:///Users/sohamzemse/Workspace/ethers-v6/node_modules/@ethersproject/abi/lib/fragments.js:654:54)
at Function.fromObject (file:///Users/sohamzemse/Workspace/ethers-v6/node_modules/@ethersproject/abi/lib/fragments.js:654:54)
at Function.fromObject (file:///Users/sohamzemse/Workspace/ethers-v6/node_modules/@ethersproject/abi/lib/fragments.js:654:54)
at Function.fromObject (file:///Users/sohamzemse/Workspace/ethers-v6/node_modules/@ethersproject/abi/lib/fragments.js:654:54)
at Function.fromObject (file:///Users/sohamzemse/Workspace/ethers-v6/node_modules/@ethersproject/abi/lib/fragments.js:654:54)
at Function.fromObject (file:///Users/sohamzemse/Workspace/ethers-v6/node_modules/@ethersproject/abi/lib/fragments.js:654:54)
at Function.fromObject (file:///Users/sohamzemse/Workspace/ethers-v6/node_modules/@ethersproject/abi/lib/fragments.js:654:54)
Environment
node.js
Environment (Other)
No response
Thanks! I’ll look into this right away. :)
The problem is in interface initialization.
ConstructorFragment.fromObject()
ErrorFragment.fromObject()
EventFragment.fromObject()
FunctionFragment.fromObject()
StructFragment.fromObject()
is not implemented. And it causes endless recursion because of extending basic Fragment
class. @ricmoo without this it is impossible to test further
@farwayer oh yes. I think this may be fixed in the latest GitHub version? I’ll double check shortly. I’m working on some v6 provider stuff right now, but will check that next.
This should be fixed now. Let me know if you still have any issues.
Thanks! :)