2 Star 3 Fork 4

GKing/Solidity8_perfect

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
S_38_TestCall.sol 1.00 KB
一键复制 编辑 原始数据 按行查看 历史
GKing 提交于 2022-11-14 11:35 +08:00 . FunctionSign 函数签名
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.7;
contract TestCall {
string public message;
uint public x;
event Log(string message);
fallback() external payable {
emit Log("fallback was called");
}
function foo(string memory _message, uint _x) external payable returns (bool, uint){
message = _message;
x = _x;
return (true, 999);
}
receive() external payable{}
}
contract Call {
bytes public data;
function callFoo(address _test) external payable {
(bool success, bytes memory _data) = _test.call{value: 111, gas: 5000}(
abi.encodeWithSignature("foo(string, uint256)",
"call foo",
123));
require(success, "called failed");
data = _data;
}
// 调用合约不存在的函数
function callDoesNotExitFunc(address _test) external {
(bool success, ) = _test.call(abi.encodeWithSignature("DoesNotExit()"));
require(success, "call failed");
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/jacky2code/solidity8_perfect.git
[email protected]:jacky2code/solidity8_perfect.git
jacky2code
solidity8_perfect
Solidity8_perfect
master

搜索帮助