DeveloperBreeze

Blockchain Development Programming Tutorials, Guides & Best Practices

Explore 30+ expertly crafted blockchain development tutorials, components, and code examples. Stay productive and build faster with proven implementation strategies and design patterns from DeveloperBreeze.

Solidity Cheatsheet

Cheatsheet August 22, 2024
solidity

Libraries are similar to contracts but are meant to hold reusable code. They cannot hold state.

library Math {
    function add(uint a, uint b) internal pure returns (uint) {
        return a + b;
    }
}

contract MyContract {
    using Math for uint;

    function calculate(uint a, uint b) public pure returns (uint) {
        return a.add(b);
    }
}