2

Newbie question! I am trying to understand some Solidity code, and I see what is apparently the calling of an unimplemented function. My question is about the syntax: unimplFunc{value: x}(data). What are the angle brackets for?

interface ICaller {
    struct CallDescription {
        uint256 value;
        bytes data;
    }

    function makeCall(CallDescription memory desc) external;
    function makeCalls(CallDescription[] memory desc) external payable;
}

Elsewhere, this unimplemented function is called like so:

function swap(
        ICaller caller,
        ICaller.CallDescription[] calldata calls
    )
        external
        payable
        whenNotPaused
        returns (uint256 returnAmount)
    {
       //
       // This is the syntax I am puzzled over
       //
       caller.makeCalls{value: 1}(calls);
        
        . . . etc . . . 
    

Maybe that syntax is for over-riding a field in the struct argument? What's especially puzzling is that this function makeCalls is never implemented.

If it helps, the input value I observed for calls is:

calls.value = 0
calls.data = 0xb3af37c000000000000000000000000000000000000000000000000000000000000000808000000000000000000000000000000000000000000000000000000000000024000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000000000001400000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000002445636885000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000083314c5f8bab1f01a5f64e01cda3c4a0ea75b6ba00000000000000000000000083314c5f8bab1f01a5f64e01cda3c4a0ea75b6ba0000000000000000000000000000000000000000000000002789438280458ffd000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000002a1530c4c41db0b0b2bb646cb5eb1a67b715866700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011c37937e0800000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000064ad65d76d0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000005fd0169e00000000000000000000000083314c5f8bab1f01a5f64e01cda3c4a0ea75b6ba0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

1 Answer 1

1

It is a new syntaxis introduced with solc 0.7.

When making a call to a funciton you specify the ether amount to send and gas available to calle.

myContract.myFunction{gas: 3000000, value: 0.01 ether}(param1,...);

For solc version 0.6 the same line has to be written as

myContract.myFunction.gas(3000000).value(0.01 ether)(param1,...);
2
  • Thank you - can you explain what the significance of the value key? I see that it's a member of the struct argument -- but is "value" have some special meaning (for instance, the value of the ether)? Dec 9, 2020 at 3:31
  • @ThomasRuble You are correct value is the amount of ether you want to send with the function call. It is unrelated to CallDescription structure.
    – Ismael
    Dec 9, 2020 at 4:30

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.