solidity - 尝试调用智能合约的另一个功能时出现问题
问题描述
我有两个智能合约,一个当前已部署,另一个应该调用第一个的特定功能。第一个包含一个以 uint256 和地址作为参数的函数。第二个应该调用这个函数,作为参数传递一个特定的数字和调用函数的用户的地址。
致电合同:
contract ToCall is Owner {
function doSomething(uint256 number, address aRandomAddress) external onlyOwner {
///Do something...
}
}
合约调用:
contract Caller is Owner {
function callOtherContract(uint256 number) external onlyOwner {
(bool sucess,)=contractAddress.call(abi.encodeWithSignature("doSomething(uint256,address)", number, msg.sender);
require(success);
}
}
每次我测试时,“require(success)”都没有通过,即使第二个合同是第一个合同的所有者。我认为这可能与我传递参数的方式有关,因为我已经使用此方法来调用不同智能合约的其他功能,但在使用参数时从未使用过。我在文档中找不到任何关于 .call 的信息,所以我有点迷茫。