Skip to content

Instantly share code, notes, and snippets.

View z0r0z's full-sized avatar
💭
codin qualia 🪄

ross z0r0z

💭
codin qualia 🪄
View GitHub Profile
@z0r0z
z0r0z / EIP4521.sol
Created February 28, 2022 08:25
make your NFTs compatible with more smart contracts that expect erc20s with this 1 weird trick
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.4;
import 'https://github.com/Rari-Capital/solmate/blob/main/src/tokens/ERC721.sol';
error NotOwner();
error InvalidRecipient();
contract EIP4521 is ERC721("WEIRD", "WEIRD") {
@z0r0z
z0r0z / NFT.sol
Created February 28, 2022 08:29
what ERC-721 could have been
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;
/// @notice Modern and gas efficient NFT implementation adhering as closely to ERC20 interface.
/// @author Ross, modified from (https://github.com/Rari-Capital/solmate/blob/main/src/tokens/ERC20.sol)
abstract contract NFT {
/*///////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
@z0r0z
z0r0z / MultiToken.sol
Last active February 28, 2022 09:10
what ERC-1155 could have been
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;
/// @notice Modern and gas efficient MultiToken implementation adhering as closely to ERC20 interface.
/// @author Ross, modified from (https://github.com/Rari-Capital/solmate/blob/main/src/tokens/ERC20.sol)
abstract contract MultiToken {
/*///////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
@z0r0z
z0r0z / AfterExpensesPaymentSplitter.sol
Created March 11, 2022 17:56
after expenses splitter
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (finance/PaymentSplitter.sol)
pragma solidity ^0.8.0;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/utils/SafeERC20.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Address.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Context.sol";
/**
@z0r0z
z0r0z / LilSuperfluidNFT.sol
Created March 12, 2022 00:26
A simple token streaming manager represented by NFTs
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.10;
import 'https://github.com/Rari-Capital/solmate/blob/main/src/tokens/ERC20.sol';
import 'https://github.com/Rari-Capital/solmate/blob/main/src/tokens/ERC721.sol';
/// @title lil superfluid nft
/// @author Miguel Piedrafita, Ross Campbell
/// modified from (https://github.com/m1guelpf/lil-web3/blob/main/src/LilSuperfluid.sol)
/// @notice A simple token streaming manager represented by NFTs
@z0r0z
z0r0z / RentNFT.sol
Created April 4, 2022 08:23
pay rent to keep right to hold an NFT
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;
import "https://github.com/Rari-Capital/solmate/blob/main/src/tokens/ERC721.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol";
import "https://github.com/Rari-Capital/solmate/blob/main/src/utils/SafeTransferLib.sol";
contract RentNFT is ERC721("RentNFT", "RENT"), Ownable {
using SafeTransferLib for address;
@z0r0z
z0r0z / AnyToken.sol
Created April 22, 2022 16:13
this is a general purpose way to tokenize things, anything, really
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;
/// @notice Minimalist and gas efficient standard ERC1155 implementation.
/// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/tokens/ERC1155.sol)
abstract contract ERC1155 {
/*//////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
@z0r0z
z0r0z / CuriaPanel.sol
Created April 22, 2022 16:46
curia panel reputation / membership protocol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;
/// @notice Minimalist and gas efficient standard ERC1155 implementation.
/// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/tokens/ERC1155.sol)
abstract contract ERC1155 {
/*//////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
pragma solidity ^0.8.0;
contract Check {
function check0(address[] calldata stuff) external view returns (uint256) {
uint256 startGas = gasleft();
uint256 counter;
for (uint256 i; i< stuff.length; i++) {
counter++;
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;
import "https://github.com/kalidao/multi-sig/blob/main/src/interfaces/IClubLoot.sol";
import "https://github.com/Rari-Capital/solmate/blob/v7/src/tokens/ERC1155.sol";
import "https://github.com/kalidao/multi-sig/blob/main/src/libraries/FixedPointMathLib.sol";
import "https://github.com/kalidao/multi-sig/blob/main/src/libraries/SafeTransferLib.sol";
/// @notice Ch.11 bankruptcy token
contract Bankruptcy is ERC1155 {