Skip to content

Instantly share code, notes, and snippets.

View idimetrix's full-sized avatar
Big believer in quality over quantity. Maximization through minimization.

Dmitry Selikhov idimetrix

Big believer in quality over quantity. Maximization through minimization.
View GitHub Profile
@idimetrix
idimetrix / BEP-20-wallet.ts
Created May 27, 2023 00:15
BEP-20 wallet
import Web3 from 'web3'; // Import the Web3 library
import HDWalletProvider from '@truffle/hdwallet-provider'; // Import the HDWalletProvider
const mnemonic = 'your-mnemonic-here'; // Replace with your actual mnemonic
const providerUrl = 'https://bsc-dataseed.binance.org'; // Replace with your desired network
const contractAddress = '0xcontract-address'; // Replace with the address of the BEP-20 token contract
const web3 = new Web3(new HDWalletProvider(mnemonic, providerUrl)); // Create a new instance of Web3 with the specified provider
interface Transaction {
@idimetrix
idimetrix / BEP-20-pendingTransactions.ts
Created May 27, 2023 00:12
BEP-20 pendingTransactions
import Web3 from 'web3';
// Create a new Web3 instance
const web3 = new Web3('https://bsc-dataseed.binance.org'); // Replace with your desired network
// Subscribe to the mempool events
const subscribeToMempool = async () => {
try {
const subscription = await web3.eth.subscribe('pendingTransactions');
<script lang="ts">
import { onMount, onDestroy } from 'svelte';
import { writable } from 'svelte/store';
export let isMetamaskInstalled: boolean;
export let isMetamaskConnected: boolean;
export let metamaskAccount: string;
let metamaskStore;
<template>
<div>
<h1>Metamask Connection Example</h1>
<div v-if="isMetamaskInstalled">
<div v-if="isMetamaskConnected">
<p>Connected to Metamask</p>
<p>Account: {{ metamaskAccount }}</p>
<button @click="disconnectMetamask">Disconnect</button>
</div>
import React, { useEffect, useState } from 'react';
// Component
const App: React.FC = () => {
const [isMetamaskInstalled, setIsMetamaskInstalled] = useState(false);
const [isMetamaskConnected, setIsMetamaskConnected] = useState(false);
const [metamaskAccount, setMetamaskAccount] = useState('');
// Check if Metamask is installed
useEffect(() => {
@idimetrix
idimetrix / MemeCoin.sol
Created May 26, 2023 06:02
ERC-20 meme coin contract with comments explaining each line
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// ERC20 standard interface
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
@idimetrix
idimetrix / useCountdown.ts
Created May 26, 2023 05:52
React useCountdown hook
import React, { useState, useEffect } from 'react';
const useCountdown = (initialCountdownSeconds) => {
const [countdown, setCountdown] = useState(initialCountdownSeconds);
useEffect(() => {
let timer;
if (countdown > 0) {
timer = setTimeout(() => {
setCountdown(countdown - 1);
@idimetrix
idimetrix / useClickOutside.ts
Created May 26, 2023 05:51
React useClickOutside hook
import React, { useRef, useEffect } from 'react';
const useClickOutside = (callback) => {
const ref = useRef(null);
const handleClickOutside = (event) => {
if (ref.current && !ref.current.contains(event.target)) {
callback();
}
};
@idimetrix
idimetrix / MemeCoin.sol
Created May 26, 2023 05:49
BEP-20 meme coin contract with comments explaining each line
pragma solidity ^0.8.0;
contract BEP20MemeCoin {
// Token name
string public name = "MemeCoin";
// Token symbol
string public symbol = "MEME";
// Total supply of tokens
@idimetrix
idimetrix / How to fork repository on GitHub, GitLab, Bitbucket.md
Last active May 26, 2023 14:01
How to fork repository on GitHub, GitLab, Bitbucket

Steps to fork a repository on GitHub, GitLab, or Bitbucket:

  1. Create a new repository for your fork:

    • On the platform (GitHub, GitLab, Bitbucket), navigate to the repository you want to fork.
    • Click on the "Fork" button to create a copy of the repository under your account.
  2. Clone your fork:

    • Open your terminal or command prompt.
    • Use the following command to clone your forked repository to your local machine: