0

If I understand well, payload and calldata are the same thing ? Basically are the bytes representation of the function that is called. I heard this was useful for calling many functions in a single call.

Suppose I have a simple function I want to call multiple times

function getReserves(address factory, address tokenA, address tokenB) internal view returns (uint reserveA, uint reserveB);

My understanding is I can magically encode this function into a payload (or calldata?) and then sending this to my contract which is going to call

function callPayloads(address target, bytes[] memory _payloads) external view returns (uint256[2][] memory) {

for (uint256 i = 0; i < _payloads.length; i++) {
      (bool _success, bytes memory _response) = targets.call(_payloads[i]); 
            require(_success); _response;                                              
      }

}

Can I use this instead of using multi-call aggregate calls or is there a difference? Also how can I encode the target contract address and function into payloads? using ethers or any other method a

also does this payload needs to be signed by a private key?

Sorry If these come as a duplicate but most of the threads I have seen are too technical for me and would like a more basic explanation for dummy people :')

1 Answer 1

3

Technically they are different things:

  • calldata is a memory region where the contract's input is stored.
  • payload is data that will be sent to another contract.

In simple terms, calldata is the container and payload is the content inside the container.

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.