solidity基础-call
例子
receive
contract ReceiveTest { event Received(address caller, uint256 amount, string msg); function getBalance() public view returns(uint256){ return address(this).balance; } function foo(string memory _msg, uint256 _x) public payable returns(uint256){ emit Received(msg.sender, msg.value, _msg); return _x + 1; } }
call
contract Caller { event Re(bool succcess, bytes data); function callFoo(address payable _addr) public payable{ (bool success, bytes memory data) = _addr.call{value: msg.value, gas: 10000}( abi.encodeWithSignature("foo(string, uint256)", "call foo", 40000) ); emit Re(success, data); } }