[英]How to properly use the call (or delegatecall) in solidity
I'm trying to use this method:我正在尝试使用这种方法:
function test(uint amount) public {
address(0xf5eA38B6b9644224dA1aECbC1219e8543c0689b2).call(abi.encodeWithSignature("deposit(uint)",amount));
}
but the transaction gets reverted, this is because the amount is not hashed in some way, and I don't really know to do it, what should I do on the amount?但是交易被还原,这是因为金额没有以某种方式进行哈希处理,我真的不知道该怎么做,我应该怎么做? these are transactions:
这些是交易:
-the failed one using the method: https://bscscan.com/tx/0x7fdd50cee23295ea866baa8961a2105c58162e77125df852a4fc5bf0fad2f507 -使用方法失败的一个: https://bscscan.com/tx/0x7fdd50cee23295ea866baa8961a2105c58162e77125df852a4fc5bf0fad2f507
and this was the input data:这是输入数据:
Function: test(uint256 tAmount) *** Function:测试(uint256 tAmount)***
MethodID: 0x29e99f07 [0]: 0000000000000000000000000000000000000000000000000000000000000001 MethodID: 0x29e99f07 [0]: 0000000000000000000000000000000000000000000000000000000000000001
-the successfull one directly calling the contract from the site instead of using call inside another smart contract: https://bscscan.com/tx/0xfd4158766f25761fa5dddb0683c677085a04ea6db05e03794be375a8243d7128 - 直接从站点调用合约而不是在另一个智能合约中使用调用的成功者:https://bscscan.com/tx/0xfd4158766f25761fa5dddb0683c677085a04ea6db05e03794be375a8243d7128
and this was the input data:这是输入数据:
Function: deposit(uint256 _amount) *** Function:存款(uint256 _amount)***
MethodID: 0xb6b55f25 [0]: 000000000000000000000000000000000000000000000000005427aedb41a400 MethodID: 0xb6b55f25 [0]: 000000000000000000000000000000000000000000000000005427aedb41a400
do I need to hash amount in someway?我是否需要以某种方式获得 hash 数量?
The target contract defines uint
as the argument type, but it's just an alias uint256
.目标合约将
uint
定义为参数类型,但它只是一个别名uint256
。 ABI encode methods don't automatically convert the aliases, so you need to change it in your code. ABI 编码方法不会自动转换别名,因此您需要在代码中更改它。
// `uint256` instead of `uint`
abi.encodeWithSignature("deposit(uint256)",amount)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.