Skip to content

Instantly share code, notes, and snippets.

View Chmarusso's full-sized avatar

Artur Chmarusso

View GitHub Profile
const fs = require('fs');
const path = require('path');
// here i have 10k json files delivered by collection owner
const dirPath = '/Users/user/Documents/collection_V1/json';
const updateContent = (filePath, content) => {
const match = filePath.match(/(\d+)\.json$/);
if (match) {
console.log(match[1]); // get tokenId from path
@Chmarusso
Chmarusso / PaymentSplitter.sol
Created June 19, 2022 12:43
This smart contract will automatically divide the payment amount and push it to specified recipients.
pragma solidity ^0.8.15;
// SPDX-License-Identifier: MIT
contract PaymentSplitter {
address payable [] public recipients;
event TransferReceived(address _from, uint _amount);
constructor(address payable [] memory _addrs) {
for(uint i=0; i<_addrs.length; i++){
recipients.push(_addrs[i]);
@Chmarusso
Chmarusso / DamnSimpleNftStake.sol
Created February 13, 2022 15:54
Super Simple NFT staking
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Receiver.sol";
contract NftStaker {
IERC1155 public parentNFT;
struct Stake {
@Chmarusso
Chmarusso / SwordNFT.sol
Created December 19, 2021 09:40
Learn how to create truly immutable smart contracts (Ethereum / EVM) that can hold all metadata and SVG images on-chain
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
library Base64 {
string internal constant TABLE_ENCODE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
bytes internal constant TABLE_DECODE = hex"0000000000000000000000000000000000000000000000000000000000000000"
// contracts/GameItems.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
contract GameItems is ERC1155, Ownable {
@Chmarusso
Chmarusso / FeeCollector.sol
Created October 4, 2021 16:05
Transfer ERC20 from contract
pragma solidity ^0.8.7;
// SPDX-License-Identifier: MIT
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
contract FeeCollector {
address public owner;
uint256 public balance;
event TransferReceived(address _from, uint _amount);
@Chmarusso
Chmarusso / FeeCollector.sol
Last active April 11, 2023 08:39
Simple smart contract
pragma solidity ^0.8.7;
// SPDX-License-Identifier: MIT
contract FeeCollector { //
address public owner;
uint256 public balance;
constructor() {
owner = msg.sender; // store information who deployed contract
}

VS Code - wtyczki, porady, tricki

  • Terminal ( toggle CTRL + ` )
  • Go to file
  • Ctrl + click = jump to file from console
  • Theme "Material Theme Palenight High Contrast"
  • Icons "material-icon-theme"
  • Plugin: ESLint
  • Switch between projects (CTRL + R)
  • Plugin: ES7 React/Redux/GraphQL/React-Native snippets
@Chmarusso
Chmarusso / settings.json
Created January 8, 2019 08:50
My VS Code settings
{
"window.zoomLevel": 3,
"editor.renderWhitespace": "boundary",
"editor.tabSize": 2,
"workbench.iconTheme": "eq-material-theme-icons-palenight",
"editor.rulers": [80],
"editor.scrollBeyondLastLine": false,
"editor.wrappingIndent": "none",
"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true,
@Chmarusso
Chmarusso / ipb4.rb
Last active March 18, 2022 04:56
Put this file in: discourse_dir/scripts/import_scripts/ipb4.rb
# migration script from IPB4 to Discourse
require "mysql2"
require File.expand_path(File.dirname(__FILE__) + "/base.rb")
require 'htmlentities'
class ImportScripts::Ipb4 < ImportScripts::Base
IPB_DB_USER = "user"
IPB_DB_PASSWORD = "password"
IPB_4_DB = "mmo_forum"