Skip to content

Instantly share code, notes, and snippets.

@shobhitic
shobhitic / PreRevealedTokens.sol
Last active June 8, 2023 03:05
Contract to help with Pre reveal metadata for NFT smart contract
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
import "@openzeppelin/contracts@4.8.0/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts@4.8.0/access/Ownable.sol";
import "@openzeppelin/contracts@4.8.0/utils/Counters.sol";
contract PreRevealedTokens is ERC721, Ownable {
using Counters for Counters.Counter;
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract MyToken is ERC20 {
constructor() ERC20("MyToken", "MTK") {
_mint(msg.sender, 10000000 * 10 ** decimals());
}
}
@shobhitic
shobhitic / index.html
Last active May 31, 2023 16:38
Showcase NFTs from a specific collection with Enumerable module - https://youtu.be/7P2nnpU-HoQ
<html>
<head>
<title>Show NFTs</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://cdn.jsdelivr.net/npm/web3@latest/dist/web3.min.js"></script>
</head>
<body>
<div id="root">
</div>
<script>
@shobhitic
shobhitic / DefaultOperatorFilterer.sol
Last active June 29, 2023 21:28
Working version of OpenSea operator filter registry - https://www.youtube.com/watch?v=4spapOTVpNA
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
import {OperatorFilterer} from "./OperatorFilterer.sol";
contract DefaultOperatorFilterer is OperatorFilterer {
address constant DEFAULT_SUBSCRIPTION = address(0x3cc6CddA760b79bAfa08dF41ECFA224f810dCeB6);
constructor() OperatorFilterer(DEFAULT_SUBSCRIPTION, true) {}
}
@shobhitic
shobhitic / Checker.sol
Last active January 15, 2023 04:21
Testing on real blockchain data without tokens - https://www.youtube.com/watch?v=VGZb2orvYJE
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
contract Checker {
function check(address _token, address user) view public returns (uint256) {
return IERC20(_token).balanceOf(user);
@shobhitic
shobhitic / TodoList.sol
Last active October 31, 2022 10:32
TodoList Backend in Solidity - https://www.youtube.com/watch?v=20ktZBancco
// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0 <0.9.0;
contract TodoList {
struct TodoItem {
string task;
bool isCompleted;
}
mapping (uint256 => TodoItem) public list;
@shobhitic
shobhitic / Lock-test.js
Last active March 17, 2023 00:31
Testing smart contract with hardhat - https://www.youtube.com/watch?v=6g5jclcYX88
const {
time,
loadFixture,
} = require("@nomicfoundation/hardhat-network-helpers");
const { anyValue } = require("@nomicfoundation/hardhat-chai-matchers/withArgs");
const { expect } = require("chai");
describe("Lock", function () {
// We define a fixture to reuse the same setup in every test.
// We use loadFixture to run this setup once, snapshot that state,
@shobhitic
shobhitic / MyToken.sol
Last active March 17, 2023 19:14
Simple Timelock and Vesting Smart Contract - https://www.youtube.com/watch?v=Z8dLFoREfWE
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts@4.7.3/token/ERC20/ERC20.sol";
contract MyToken is ERC20 {
constructor() ERC20("MyToken", "MTK") {
_mint(msg.sender, 10000 * 10 ** decimals());
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@aave/core-v3/contracts/flashloan/base/FlashLoanSimpleReceiverBase.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
contract SimpleFlashLoan is FlashLoanSimpleReceiverBase {
using SafeMath for uint;
@shobhitic
shobhitic / ERC4907.sol
Last active April 20, 2023 09:16
Rentable NFT with ERC 4907 on Ethereal, Polygon, and other EVM chains - https://youtu.be/t1ZB0-UwWB0
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "./IERC4907.sol";
contract ERC4907 is ERC721, IERC4907 {
struct UserInfo
{
address user; // address of user role