编码一个字节[]用于encodeWithSignature
作为Ethernaut的Puzzzle Wallet挑战的一部分,我希望将这种外部合同的方法称为我的合同:
function multicall(bytes[] calldata data) external payable onlyWhitelisted
更具体地说,我试图打电话给递归电话。
multidata
________|________
| |
multidata multidata
| |
deposit deposit
我正在使用abi.codewithsignature
方法,但看起来坚固性不允许在此处未实现嵌套的动态数组。
:
bytes memory data = abi.encode([bytes4(keccak256('deposit()'))]);
bytes memory singleMulticallData = abi.encodePacked(bytes4(keccak256('multicall(bytes[])')), data);
(bool successDeposit, ) = address(proxy).call(abi.encodeWithSignature("multicall(bytes[])", [singleMulticallData, singleMulticallData]));
require(successDeposit, "deposit not successful");
关于如何创建一个字节数组的任何想法会包含字节吗?
As part of the PuzzleWallet challenge from Ethernaut, I am looking to call this method of an external contract from my contract:
function multicall(bytes[] calldata data) external payable onlyWhitelisted
More specifically, I am trying to call with a recursive call.
multidata
________|________
| |
multidata multidata
| |
deposit deposit
I am using abi.encodeWithSignature
method but it looks like Solidity doesn't allow Nested dynamic arrays not implemented here.
:
bytes memory data = abi.encode([bytes4(keccak256('deposit()'))]);
bytes memory singleMulticallData = abi.encodePacked(bytes4(keccak256('multicall(bytes[])')), data);
(bool successDeposit, ) = address(proxy).call(abi.encodeWithSignature("multicall(bytes[])", [singleMulticallData, singleMulticallData]));
require(successDeposit, "deposit not successful");
Any idea on how you could create an array of bytes which would contain bytes?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
2.以下是我的参考解决方案。
2.the follow is my solution For your reference.