【发布时间】:2022-01-09 16:57:54
【问题描述】:
我想使用 truffle 创建的 json 文件从人类可读的 ABI 创建一个表单。所以想法是获取字符串 Human-Readable ABI,然后使用正则表达式剪切并使用不同的部分来创建我的表单。但是使用ethers.utils.FormatTypes.full 不会像文档建议的那样返回字符串。
这是我的代码:
const iface = await new ethers.utils.Interface(Bank.abi);
iface.format(ethers.utils.FormatTypes.full);
预期输出:
[
'function deposit() public payable',
'function withdraw(uint256 _amount)',
'function checkAssets() public view returns(uint256)'
];
实际输出: 根据文档:Converting Between Formats
ethers.utils.FormatTypes.full ⇒ 字符串。 这是一个完整的人类可读字符串,包括所有参数名称、任何可选修饰符(例如 indexed、public 等)和有助于人类可读性的空格。
但相反,它返回一个对象。 有人可以帮忙吗?
【问题讨论】:
标签: javascript reactjs ethereum human-readable ethers.js