老师请帮忙看看
错误信息:
transact to caller.setCalleeX errored: VM error: revert.
revert
The transaction has been reverted to the initial state.
Reason provided by the contract: “call failed”.
Debug the transaction to get more information.
callee.sol 代码:
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.8.2 <0.9.0;
// 被调用的契约
contract Callee{
uint public x;
function setX(uint _x)public returns(uint){
x = _x;
return x;
}
}
caller.sol 代码:
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.8.2 <0.9.0;
// 执行调用的契约
contract caller{
address calleeAddress;
uint public xx;
constructor(address _calleeAddress){
calleeAddress = _calleeAddress;
}
function setCalleeX(uint _x)public{
bytes memory cd = abi.encodeWithSignature("setX(uint)", _x);
(bool suc, bytes memory rst) = calleeAddress.call(cd);
if(!suc){
revert("call failed");
}
(uint x) = abi.decode(rst, (uint));
xx = x;
}
}
登录后可查看更多问答,登录/注册