1
   
 function setXTransferETH(address otherContract, uint256 x) payable external{
        OtherContract(otherContract).setX{value: msg.value}(x);
    }

As above method, the calling with {} before the ()... what's the name of this calling, what is this {}'s terminology?

(Sorry I come from C / Jave world, I do understand what this method does. But what's the syntax for this thing? )

Thanks.

1 Answer 1

2

It is called call-argument-list syntax.

It is useful to pass 'configuration' data to a function call, like the gas, value, etc.

In older versions of Solidity, the syntax to set the gas, value, etc., in a function like .call, was something like this:

recipient.call.gas(3000).value(1 eth);

But that syntax is not supported any more in newer versions of Solidity.

The new syntax is like this:

recipient.call{gas: 3000, value: 1 eth}();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.