Skip to content

Instantly share code, notes, and snippets.

View caffeinum's full-sized avatar
🐶
Coffee Driven Development

Aleksey Bykhun caffeinum

🐶
Coffee Driven Development
View GitHub Profile
@caffeinum
caffeinum / deploy.js
Last active September 20, 2022 17:38
How to use Truffle to replace pending transaction when you deploy new contract
const Greeter = artifacts.require("Greeter");
module.exports = async function (deployer, network, accounts) {
// await deployer.deploy(Greeter);
// replace with:
const [ owner ] = accounts;
const lastNonce = await web3.eth.getTransactionCount(owner);
// this DOESN'T include pending transactions, so lastNonce + 1 always replaces pending
@caffeinum
caffeinum / [email protected]
Last active October 23, 2021 10:42
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=089cf9d1a5fcb80a0a766ebe8584656e
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
@caffeinum
caffeinum / script.js
Created October 7, 2021 12:29
Pancake Swap NFT Marketplace get floor
// put breakpoint at etherscan VM:280
// use "res" variable
res.askInfo.map((i, index) => ({ ...i, tokenId: res.tokenIds[index], priceBNB: Number(i.price) / 1e18, link: `https://pancakeswap.finance/nfts/collections/0x0a8901b0E25DEb55A87524f0cC164E9644020EBA/${res.tokenIds[index]}` })).sort((a,b) => Number(a.price) - Number(b.price)).filter(i => i.priceBNB == 5)
@caffeinum
caffeinum / AvatarNFT.sol
Last active December 3, 2021 16:33
Simplest ERC721 Avatar Collection Template (use TemplateNFT.sol, change values to yours)
// SPDX-License-Identifier: MIT
// Adapted from World of Women: https://etherscan.io/token/0xe785e82358879f061bc3dcac6f0444462d4b5330#readContract
pragma solidity ^0.8.2;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract AvatarNFT is ERC721, ERC721Enumerable, Ownable {
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.
/**
* @dev Wrappers over Solidity's arithmetic operations.
@caffeinum
caffeinum / [email protected]@4.2.0...access...Ownable.sol
Last active August 20, 2021 13:36
TigersFightClub.sol Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.4+commit.c7e474f2.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
@caffeinum
caffeinum / APIConsumer.sol
Created January 29, 2021 08:43
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.6.12+commit.27d51765.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: MIT
/** This example code is designed to quickly deploy an example contract using Remix.
* If you have never used Remix, try our example walkthrough: https://docs.chain.link/docs/example-walkthrough
* You will need testnet ETH and LINK.
* - Kovan ETH faucet: https://faucet.kovan.network/
* - Kovan LINK faucet: https://kovan.chain.link/
*/
pragma solidity ^0.6.0;
@caffeinum
caffeinum / imagine.tsx
Last active December 10, 2020 03:05
GPT-3 Imagine
// A. So we have a React component
// B. that is a modal popup
// C. it has two buttons: Apply and Cancel
// D. when you press cancel, it hides itself
// E. when you press Apply, the function callback
// F. that was passed through props, is called
// G. Also, popup can draw inherited HTML fetched from props.children
// H. Bonus question! It looks wrong.
// Please add the dark overlay over background, and make the buttons more in style with the rest of the project
@caffeinum
caffeinum / RESTREAM.md
Last active November 24, 2020 13:56
RTMP Server Basic setup

Setup restream with NGINX

  1. Install FFMPEG
  2. Setup rtmp application for restream
  3. Test