# Solidity - call other contract function by calldata

By [N00b21337](https://paragraph.com/@n00b21337) · 2023-01-12

---

Calling some other contract function can be achieved with .call notation on contract address and passing in calldata info which is in bytes format.

    contract CallFunction {
        address public s_other_contract_address;
    
        constructor(address addy) {
            s_other_contract_address = addy;
        }
    
        // you could use this to change state
        function callFunctionDirectly(bytes calldata callData) public returns (bytes4, bool) {
            (bool success, bytes memory returnData) = s_other_contract_address.call(callData);
            return (bytes4(returnData), success);
        }
    

to get this calldata which will be passed to this contract you need to encode it somehow, one way would be to make it in solidity with this code

        function getCallData() public view returns (bytes memory) {
            return abi.encodeWithSignature("transfer(address,uint256)", address(this), 123);
        }
    

where we would get data like this and that is what we would pass to calldata in first function. That data is encoded function signature with function parametars.

---

*Originally published on [N00b21337](https://paragraph.com/@n00b21337/solidity-call-other-contract-function-by-calldata)*
