0

The below code fails when calling foo() on TestContract. The adaptedLib as been set to the right address. How do you make a delegatecall to a lib correctly?

contract TestContract {
    address public adapterLib;
    uint public a;

    function setLib(address lib)public{
        adapterLib = lib;
    }

    function foo()public {
        (bool success, bytes memory returnData) = adapterLib.delegatecall(
                abi.encodeWithSignature('foo(uint)', 1)
            );
    }
    
}

library Test{

    function foo(State storage state)external returns(uint){
        return 1;
    }
}

2 Answers 2

1

try changing the function signature to 'foo(uint256)'. That's certainly one issue as uint is shorthand for uint256, but you can't use that shorthand for function signatures

0

your library is implemented in your smart contract and you use the library there, in this situation "delegateCall" does not suitable and you can use "yourLibrary.yourFunc()", but if you implement your library in another contract, I recommend to check your input arguments type(uint to uint256)

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.