Skip to content

Instantly share code, notes, and snippets.

@rib3ye
Last active April 4, 2018 22:05
Show Gist options
  • Save rib3ye/7050598b18a852421d194007cff0250e to your computer and use it in GitHub Desktop.
Save rib3ye/7050598b18a852421d194007cff0250e to your computer and use it in GitHub Desktop.
Just random things I learned about solidity

Using .call() or .delegatecall() we can call functions, similar to the data field in a sendTransaction

However, the function name being called must be encoded in hex so the first four bytes can be read as the function name. To do this, we use <address>.delegatecall(bytes4(keccak256("functionName()"))).

Simple logging is possible, using event and emit:

contract LogTest {
    event LogIt(string _text);
    
    //constructor
    function LogTest() public { 
        emit LogIt("Log Me!!!!");
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment