Skip to content

Instantly share code, notes, and snippets.

@stonegao
stonegao / songs.md
Created September 26, 2021 07:28 — forked from Suhail/songs.md

FAQ of Songs for Tunes

Songs for Tunes lets artists upload songs to sell on an open decentralized marketplace with other artists. The goal is to fund music artists to keep producing great music.

To mint, you need music.

1. How do I mint an Original Song?

You must be the owner of an original Tune NFT. You can buy one here: https://opensea.io/collection/tunesproject

After that, you can mint directly from our web app: https://songs.tunesproject.org

Overview

To understand how constructors through Solidity works (that is, how do we go from the compiled contract's bin to a live deployed contract with a different deployedBytecode), I took a deep dive into how one simple contract worked.

The contract Simple.sol:

pragma solidity ^0.5.12;

contract Simple {
@stonegao
stonegao / NewlyCreatedTokenQuery.ql
Created September 22, 2021 11:47 — forked from buddies2705/NewlyCreatedTokenQuery.ql
GraphQL API to get the newly created Ethereum Tokens
{
ethereum {
smartContractCalls(options: {desc: "block.height", limit: 10}, smartContractMethod: {is: "Contract Creation"}, smartContractType: {is: Token}) {
block {
height
timestamp {
time
}
}
smartContract {
@stonegao
stonegao / amulet.ts
Created September 9, 2021 16:54 — forked from mrbrucespringsteen/amulet.ts
amulet verification code
import { utils } from 'ethers'
export interface Amulet {
value: string;
hash: string;
count: number;
}
const getAmuletCount = (hash: string): number => {
const matches = hash.match(/(8)\1*/g);
/**
* 1. Initialize new node project (npm init -y)
* 2. Run: npm install ethers
* 3. Add private key where PRIVATE_KEY
* 4. Optionally, update gas price (line 29) or chosen gas limit
* 4. Run: node score-claim.js
*/
// Imports
const ethers = require("ethers");
const { parseUnits } = require("@ethersproject/units");
require("dotenv").config();
const ethers = require("ethers");
const axios = require('axios').default;
const provider = new ethers.providers.JsonRpcProvider(`https://eth-mainnet.alchemyapi.io/v2/${process.env.NEXT_PUBLIC_ALCHEMY_API_KEY}`);
const alg = new ethers.Contract(
"0x32353A6C91143bfd6C7d363B546e62a9A2489A20",
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"inde
@stonegao
stonegao / check-settlement.js
Created September 4, 2021 23:52 — forked from mehranhydary/check-settlement.js
check-settlement.js
/*
1. Run `npm init` in a new folder
2. Install ethers.js with `npm i ethers`
3. Create a file called `check-settlement.js`
4. Copy the script below and save it in the file you create
5. In your terminal, run `node check-settlement.js`
*/
require("dotenv").config();
const ethers = require("ethers");
const axios = require('axios').default;
/**
* 1. Initialize new node project (npm init -y)
* 2. Run: npm install ethers
* 3. Add private key where PRIVATE_KEY
* 4. Optionally, update gas price (line 29) or chosen gas limit
* 5. Run: node mint-temporal-loot.js
* 6. NOTE: Don't forget to get an API key fgrom Alchemy and replace the variable in line 15
*/
// Imports
require("dotenv").config();
@stonegao
stonegao / Fee1155NFTLockable.sol
Created August 16, 2021 08:39 — forked from TimTinkers/Fee1155NFTLockable.sol
A gas-efficient mintable, lockable NFT creation contract for OpenSea listing.
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;
import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
import "./FeeOwner.sol";
@stonegao
stonegao / eventFilter.js
Created July 15, 2021 08:35 — forked from wschwab/eventFilter.js
a handmade Ethereum event filter that you should never really use
const eventFilter = (contractAddress, contractAbi, eventName, _provider) => {
const provider = _provider
// this will return an array with an object for each event
const events = contractAbi.abi.filter(obj => obj.type ? obj.type === "event" : false);
// getting the Transfer event and pulling it out of its array
const event = events.filter(event => event.name === eventName)[0];
// getting the types for the event signature
const types = event.inputs.map(input => input.type)
// knowing which types are indexed will be useful later
let indexedInputs = [];