CRYPTO NEWS

address.call{}(abi.encodeWithSignature()) in solidity returns boolean and what other parameters?

I learned from this documentation https://docs.soliditylang.org/en/v0.8.15/contracts.html and this discussion How to use address.call{}() in solidity about abi.encodeWithSignature() .

I have question about this snippet below.

contract TestPayable { uint x; uint y; // This function is called for all messages sent to // this contract, except plain Ether transfers // (there is no other function except the receive function). // Any call with non-empty calldata to this contract will execute // the fallback function (even if Ether is sent along with the call). fallback() external payable { x = 1; y = msg.value; }  // This function is called for plain Ether transfers, i.e. // for every call with empty calldata. receive() external payable { x = 2; y = msg.value; } } 

Then we have the caller

contract Caller {  function callTestPayable(TestPayable test) public returns (bool) {     (bool success,) = address(test).call(abi.encodeWithSignature("nonExistingFunction()"));     require(success);     // results in test.x becoming == 1 and test.y becoming 0.     (success,) = address(test).call{value: 1}(abi.encodeWithSignature("nonExistingFunction()"));     require(success);     // results in test.x becoming == 1 and test.y becoming 1.     return true; } } 
  1. I am wondering this line (bool success,) = address(test).call(abi.encodeWithSignature("nonExistingFunction()"));

    What could come after the comma (bool success, **What other parameters could fit here?**)?

  2. If that line only returns bool success , then why we need to put it in a bracket with comma (bool success,)? Why can’t we just put bool success = address(test).call(abi.encodeWithSignature("nonExistingFunction()"));

  3. Is nonExistingFunction() a default reserved function name to call no-name fallback function from other smart contract?

I can’t find this information in the official documentation.

Linter Error: `assert(this.f.address == address(this));`

While learning solidity, I copy-pasted this code from: https://docs.soliditylang.org/en/v0.8.4/types.html // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.4 <0.9.0; contract Example { function f() public payable returns (bytes4) { assert(this.f.address == address(this)); return this.f.selector; } function g() public { this.f{gas: 10, value: 800}(); } } Linter: Parse error: extraneous input ‘)’ expecting ‘;’ [undefined] I’m using VSCode, with::Listen

While learning solidity, I copy-pasted this code from: https://docs.soliditylang.org/en/v0.8.4/types.html

// SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.4 <0.9.0;  contract Example {     function f() public payable returns (bytes4) {         assert(this.f.address == address(this));         return this.f.selector;     }      function g() public {         this.f{gas: 10, value: 800}();     } } 

Linter: Parse error: extraneous input ‘)’ expecting ‘;’ [undefined]

enter image description here


I’m using VSCode, with solidity version: 0.0.113, and solc version: 0.8.4+commit.c7e474f2.Darwin.appleclang

In Remix, I don’t see this error (with same solc version):

enter image description here

What is this error and how can I fix it?

address.call{}(abi.encodeWithSignature()) in solidity returns boolean and what other parameters?

Shopping cart
There are no products in the cart!
Continue shopping
0