Skip to content

Instantly share code, notes, and snippets.

@TehilaFavourite
Last active June 27, 2023 13:39
Show Gist options
  • Save TehilaFavourite/b231edfd2b51dda3ee6dce45e9aee5c2 to your computer and use it in GitHub Desktop.
Save TehilaFavourite/b231edfd2b51dda3ee6dce45e9aee5c2 to your computer and use it in GitHub Desktop.
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.0;
library MathUtils {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
function multiply(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
}
contract MyContract {
function performCalculation(
uint256 x,
uint256 y
) public pure returns (uint256) {
uint256 result = MathUtils.add(x, y); // Using the add() function from the MathUtils library
result = MathUtils.multiply(result, 2); // Using the multiply() function from the MathUtils library
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment