We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
contract Caller{ address public proxy; // 代理合约地址
constructor(address proxy_){ proxy = proxy_; } // 通过代理合约调用 increase()函数 function increase() external returns(uint) { ( , bytes memory data) = proxy.call(abi.encodeWithSignature("increment()")); return abi.decode(data,(uint)); }
}
// 大佬们, 这个地方为什么返回值是1, 不是100呢???
The text was updated successfully, but these errors were encountered:
可以这么理解,调用代理合约时,代理合约将会维护自己的状态变量,此处的状态变量是implementation和变量X,proxy合约通过构造函数初始化了implementation变量,变量X没有赋值,那么就是默认值0,调用increment函数,返回x+1,那么就是返回的0+1 也就是1。 理解代理合约一定要理解代理合约自己的状态变量和逻辑合约的状态变量是独立的
Sorry, something went wrong.
No branches or pull requests
contract Caller{
address public proxy; // 代理合约地址
}
// 大佬们, 这个地方为什么返回值是1, 不是100呢???
The text was updated successfully, but these errors were encountered: