There are a abi.encodeWithSignature("foo((bytes))", info), but in addition to calling the function in another contract I want to send more data as an address to retrieve with msg.data, for example. It is possible?


I'm not really sure of what your are looking for but if you want to send more parameters than required in the signature you can do something like that

function send(bytes memory info, address moreInfo) public {
    (bool success,) = address(this).call(abi.encodePacked(abi.encodeWithSignature("foo((bytes))", info), moreInfo));
function foo(bytes memory info) public {
    address moreInfo = address(0);
    if (msg.data.length >= 24) { // you should check msg.sender too
        assembly {
            moreInfo := shr(96,calldataload(sub(calldatasize(),20)))
    // ...

You can specify multiple types in the function signature. For example:

abi.encodeWithSignature("foo(uint256,address)", 12345, address(0x0));

This will result in:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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