I want to create a form from the Human-Readable ABI using the json file truffle creates. so the idea is to get the string Human-Readable ABI and then use regex to cut out and use the different parts to create my form. But using ethers.utils.FormatTypes.full
does not return a string like the documentation suggest.
Here is my code:
const iface = await new ethers.utils.Interface(Bank.abi);
iface.format(ethers.utils.FormatTypes.full);
expected output:
[
'function deposit() public payable',
'function withdraw(uint256 _amount)',
'function checkAssets() public view returns(uint256)'
];
actual output: According to the documentation: Converting Between Formats
ethers.utils.FormatTypes.full ⇒ string. This is a full human-readable string, including all parameter names, any optional modifiers (e.g. indexed, public, etc) and white-space to aid in human readability.
But instead, it returns an object. Can anyone please assist?
CodePudding user response:
Looking at the code, format
will definitely return a string in all cases.
From your code excerpt, it's not clear what you're logging in the console.
It should be something like:
const iface = await new ethers.utils.Interface(Bank.abi);
console.log('Formatted ABI', iface.format(ethers.utils.FormatTypes.full));
From what you posted in the screenshot, it seems that you're logging the iface
object itself.
I'd be happy for edit this answer if you provide the full code that you're using.