Skip to content

Instantly share code, notes, and snippets.

View walteh's full-sized avatar

Walter Scott walteh

  • 14:09 (UTC -05:00)
View GitHub Profile
@walteh
walteh / CheckSameSign.sol
Last active July 12, 2022 11:10
gas analysis of different methods of checking sign equality of integers in solidity v8
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.15;
import "forge-std/Script.sol";
import "forge-std/Test.sol";
function checkSameSign1(int256 a, int256 b) pure returns (bool sameSign) {
uint256 sa;
uint256 sb;
@walteh
walteh / assemblyStorageRef.sol
Last active February 23, 2022 00:28
simple example of how solidity calculates storage refs for structs
pragma solidity 0.8.12;
// contains refs to hardhat console.sol and DSTest.sol contract
import '../utils/forge.sol';
contract test is t {
struct Test {
uint256 a;
uint256 b;