Skip to content

Instantly share code, notes, and snippets.

View karmacoma-eth's full-sized avatar

karmacoma karmacoma-eth

View GitHub Profile
@karmacoma-eth
karmacoma-eth / FizzBuzz.sol
Created December 2, 2022 22:06
FizzBuzz in Solidity but ridiculous
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
import {console2} from "forge-std/console2.sol";
contract FizzBuzz {
modifier fizz(uint256 n) {
_;
if (n % 3 == 0 && n % 5 != 0) {
console2.log("Fizz");
@karmacoma-eth
karmacoma-eth / AdversarialRoyalties.sol
Created February 15, 2022 02:26
What if a contract returns different data when viewed off-chain vs during a transaction?
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
contract AdversarialRoyalties {
bytes4 private constant _INTERFACE_ID_ERC2981 = 0x2a55205a;
function supportsInterface(bytes4 interfaceID) external pure returns (bool) {
return interfaceID == _INTERFACE_ID_ERC2981;
}
@karmacoma-eth
karmacoma-eth / CheckBeforeStore.sol
Created February 8, 2022 19:08
Is it cheaper to check if a new value is different before storing it?
// SPDX-License-Identifier: Unlicense
pragma solidity >=0.8.0;
contract CheckBeforeStore {
event Log(address);
bytes32 stored;
function setUp() public {
stored = keccak256(abi.encode(address(this)));
@karmacoma-eth
karmacoma-eth / IERC1155MetadataURI.json
Created September 20, 2021 22:33
IERC1155MetadataURI JSON ABI
[
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "account",
"type": "address"
},