Skip to content

Instantly share code, notes, and snippets.

View 0xAnon101's full-sized avatar
๐ŸŽ“
Rain , coffee , code

0xAnon 0xAnon101

๐ŸŽ“
Rain , coffee , code
  • EVM
View GitHub Profile
@0xAnon101
0xAnon101 / Deposit.sol
Last active August 5, 2022 15:08
DVD Unstoppable #1 - a()
// why use deposit tokens to get the balance?
function depositTokens(uint256 amount) external nonReentrant {
require(amount > 0, "Must deposit at least one token");
// Transfer token from sender. Sender must have first approved them.
damnValuableToken.transferFrom(msg.sender, address(this), amount);
poolBalance = poolBalance + amount;
}
@0xAnon101
0xAnon101 / subscribefn.js
Last active July 13, 2022 04:04
subscribe function
subscribe(topic) {
this.web3.on(topic, async (txnHash) => {
setTimeout(async () => {
try {
const txn = await this.web3.getTransaction(txnHash);
if (txn !== null && txn.to !== null) {
if (this.accounts === txn.from.toLowerCase()) {
// dumps the data onto the CLI
console.log({
address: txn.from,
@0xAnon101
0xAnon101 / txnChecker.js
Last active July 13, 2022 04:03
event based subscription to track an address activity
const { ethers } = require("ethers");
require("dotenv").config();
class TxnChecker {
web3 = null;
accounts = null;
subscription = null;
constructor(projectId, account) {
console.log(account);
@0xAnon101
0xAnon101 / merkleTrie.sol
Last active July 10, 2022 15:59
Merkle verification for random txn
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
/// @title A simple contract named MerkleTrie
/// @author 0xAnon101
/// @notice Shows you the functioning of Merkle Trie. Not meant to be used in Production environment
/// due to high gas cost in this demo methodology. It is here just to understand the underlining
/// structure of Merkle Trie.
/// @dev Implementaion using custom string based array which includes sample transactions.
contract MerkleTrie {
@0xAnon101
0xAnon101 / bored-ape-yacht-club.ts
Created June 27, 2022 05:16
mapping of handleTransfer
import { log, ipfs, json, JSONValue } from "@graphprotocol/graph-ts";
import {
Transfer as TransferEvent,
baycToken as BaycTokenContract,
} from "../generated/baycToken/baycToken";
import { BoredApeToken, BoredApeUser } from "../generated/schema";
export function handleTransfer(event: TransferEvent): void {
/**
* load ipfs of bayc
@0xAnon101
0xAnon101 / schema.graphql
Created June 27, 2022 03:30
Schema graph
# fulltext query: searchable keywords
type _Schema_
@fulltext(
name: "apeFilter"
language: en
algorithm: rank
include: [
{
entity: "BoredApeToken"
fields: [{ name: "eyes" }, { name: "background" }]
@0xAnon101
0xAnon101 / subgraph.yaml
Last active June 27, 2022 04:31
subgraph yaml file for BAYC
specVersion: 0.0.5
schema:
file: ./schema.graphql
features:
- fullTextSearch
- ipfsOnEthereumContracts
dataSources:
- kind: ethereum
name: baycToken
network: mainnet
@0xAnon101
0xAnon101 / Migrations.js
Last active May 17, 2021 07:05
Deployer modifications
const Registration = artifacts.require("Registration");
const fs = require('fs');
const path = '/../src/metaData.js'; // need to create src folder first
module.exports = async function (deployer) {
await deployer.deploy(Registration);
const instance = await Registration.deployed();
fs.writeFile(
__dirname + path,
@0xAnon101
0xAnon101 / currency.sol
Created February 1, 2021 11:09
send/mint/transfer currency
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.5.0 <0.9.0;
import "github/OpenZeppelin/openzeppelin-contracts/contracts/math/SafeMath.sol";
contract Scoin {
using SafeMath for uint256;
address public minter;
mapping (address => uint256) public balances;
@0xAnon101
0xAnon101 / Address.sol
Last active January 26, 2021 11:03
Address coercion
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.22 <0.7.0;
contract Address {
// address addressA = 0x111122223333444455556666777788889999AAAABBBBCCCCDDDDEEEEFFFFCCCC; notimplicity convertible
address addressA;
function compressAddressSize() external pure returns(address ) {