Skip to content

Instantly share code, notes, and snippets.

View sandy13869's full-sized avatar
💻
Processing...

Sandeep sandy13869

💻
Processing...
View GitHub Profile
@sandy13869
sandy13869 / EtherWallet.sol
Last active May 30, 2022 02:58
Simple Ether Wallet Smart Contract
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
contract EtherWallet{
address payable public owner;
// Only owner can access the function and withdraw
constructor() {
owner = payable(msg.sender);
}
@sandy13869
sandy13869 / LotteryRandom.sol
Last active May 30, 2022 02:58
Chain link Random Lottery (Rinkeby)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;
import "@chainlink/contracts/src/v0.8/VRFConsumerBase.sol";
contract Lottery is VRFConsumerBase{
// Declare the owner
address public owner;
// Declare the Player
@sandy13869
sandy13869 / lottery.sol
Created May 29, 2022 09:01
A solidity Smart Contract to Conduct a Lottery
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract Lottery {
// Declare the owner
address public owner;
// Declare the Player
address payable[] public players;
uint256 public lotteryId;
@sandy13869
sandy13869 / PurchaseAgreement.sol
Created May 28, 2022 12:26
Seller and Buyer Purchase Agreement
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.14;
contract PurchaseAgreement {
uint256 public value;
address payable public seller;
address payable public buyer;
enum State {Created, Locked, Release, Inactive}
@sandy13869
sandy13869 / SampleTokens.sol
Created May 23, 2022 06:40
Generate ERC20 tokens (Optimum code to mint 'n' Tokens in Testnet)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract MyNFT is ERC20 {
constructor() ERC20 ("Sandy Coins", "SAN") {
_mint(msg.sender, 1000 * 10 ** 18);
@sandy13869
sandy13869 / schain.js
Last active May 23, 2022 06:37
Create Blockchain Genesis Block in JavaScript
const crypto = require("crypto"), SHA256 = message => crypto.createHash("sha256").update(message).digest("hex");
class Block {
constructor(timestamp = "", data = []) {
this.timestamp = timestamp;
this.data = data;
this.hash = this.getHash();
this.prevHash = "";
}
@sandy13869
sandy13869 / postgresOps.py
Created May 23, 2022 06:30
Postgres basic mutation operations with Python
import psycopg2
import psycopg2.extras
hostname ='localhost'
database = 'demo'
username = 'postgres'
pwd = 'pwd'
port_id = 5432
conn = None
cur = None
@sandy13869
sandy13869 / script.js
Created May 23, 2022 06:24
Create Custom GRAPHQL query from the SubGraph and capture into JSON
const axios = require('axios');
const fs = require('fs');
function getGraph() {
}
const main = async () => {
try {

MongoDB Cheat Sheet

Show All Databases

show dbs

Show Current Database