Skip to content

Instantly share code, notes, and snippets.

View lex-world's full-sized avatar
🐨
🔺

Domsan Lex lex-world

🐨
🔺
View GitHub Profile
@lex-world
lex-world / Node-FileSystemServer.js
Created March 25, 2022 23:35
File Server in Node.js without DB installation.
const cluster = require("cluster");
// deepcode ignore HttpToHttps: https provided on production with NGINX
const http = require("http");
const numCPUs = require("os").cpus().length;
const process = require("process");
const statik = require("node-static");
/**
* @dev folder listener
#include <stdio.h>
#include <stdlib.h>
struct SLL{
int data;
struct SLL *next;
};
struct SLL *head = NULL;
const provider = new ethers.providers.Web3Provider(window.ethereum, "any");
await provider.send("eth_requestAccounts", []);
const signer = provider.getSigner()
const usdc = {
address: "0x68ec573C119826db2eaEA1Efbfc2970cDaC869c4",
abi: [
"function name() view returns (string)",
"function symbol() view returns (string)",
"function gimmeSome() external",
/*
* @dev Module Explanation - Creating a Transaction
* tronWeb.transactionBuilder.sendTrx(to, amount, from, options);
* * The Addresses uses below are randomly generated addresses
*/
const tradeobj = await tronWeb.transactionBuilder.sendTrx("TNo9e8MWQpGVqdyySxLSTw3gjgFQWE3vfg", 100,"TM2TmqauSEiRf16CyFgzHV2BVxBejY9iyR");
/*
* @dev Module Explanation - Signing a Transaction
* PRIVATE_KEY are not meant to shared public so it's better keep in environment.
import detectEthereumProvider from '@metamask/detect-provider'
const provider = await detectEthereumProvider()
if (provider) {
console.log('Ethereum successfully detected!')
// From now on, this should always be true:
// provider === window.ethereum
@lex-world
lex-world / ImmunXFactory.sol
Created February 15, 2022 23:19
Way Formatted Factory Contract for ImmunX.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./SafeMath.sol";
import "./ERC20.sol";
contract ImmunXFactory {
using SafeMath for uint;
ERC20 private usdtAddress;
@lex-world
lex-world / BSCNS.sol
Created January 26, 2022 06:30
Name Server for Binance Smart Chain.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract BSCNS {
struct Record {
address owner;
string domainName;
uint expirationDate;
}
@lex-world
lex-world / BEP20.sol
Created January 16, 2022 17:23
BEP20 Token format for Binance Chain from ERC20 Standard.
// contracts/BEP20.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract BEP20 is ERC20 {
constructor(uint256 initialSupply, string memory _name, string memory _symbol) ERC20(_name, _symbol) {
_mint(msg.sender, initialSupply);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "https://github.com/nibbstack/erc721/src/contracts/tokens/nf-token-metadata.sol";
import "https://github.com/nibbstack/erc721/src/contracts/ownership/ownable.sol";
/**
* @dev This is an example contract implementation of NFToken with metadata extension.
*/
contract MyArtSale is
@lex-world
lex-world / AWSEC2_NodeSetup.sh
Last active January 16, 2022 17:57
Bash File for Setting base for Node.js setup on AWS EC2. The below bash file installs all required packages you just need to clone repo and install node_modules, configure .env and run on pm2. 😎 🚀
cd ~ && curl -sL https://deb.nodesource.com/setup_16.x -o nodesource_setup.sh && sudo bash nodesource_setup.sh && sudo apt install nodejs -y && sudo npm i -g npm && sudo npm i -g pm2 && sudo npm i -g yarn && rm -rf nodesource_setup.sh && sudo apt update && sudo apt install nginx -y && sudo ufw allow ‘Nginx Full’ && sudo ufw status && systemctl status nginx && sudo systemctl start nginx && sudo systemctl enable nginx