I am a beginner to solidity and I came across this concept called "Low-Level Calls". What exactly is a Low-level function? and How is it different from others?


So in solidity the address object has this method call through which you can call every function you want and if the address implements it will be triggered.
For example:

contract SomeContract {
    function any() public {
        (bool success, bytes memory result) = addr.call(abi.encodeWithSignature("myFunction(uint,address)", 10, msg.sender);
        // if success is `true` the function exists and it had returned some result
        (uint a, uint b) = abi.decode(result, (uint, uint)); // This is an example of how the result might have been decoded

You can also use this syntax:

address.call.gas(50000).value(1 ether)(data);

Here you forward some ethe and gas. the variable data is something like this:


The first 4bites after the 0x symbol represent the function signature - the first for bytes of the function signature after encoding it with the keccak256 hash function, in this case it is abi.keccak256("swapExactTokensForTokens(uint256,uint256,address[],address,uint256)") and from the result you are using the first 4 bytes. Everything after this 4bits is representation of the calldata which will be parsed to the functions arguments.


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.