Skip to content

Instantly share code, notes, and snippets.

View tunnckoCore's full-sized avatar
🔒
Fighting for freedom, security and privacy 🔐

Charlike Mike Reagent tunnckoCore

🔒
Fighting for freedom, security and privacy 🔐
View GitHub Profile
@tunnckoCore
tunnckoCore / ethscriptions-user-markets.md
Last active September 15, 2024 18:11
Ethscriptions user-owned and user-controlled markets

Motivation and how the process currently works

The current approach is that a user escrows their Ethscriptions to a Marketplace contract that uses the ESIP-2 (contract-based transfers) for transferring when a sale happens. That escrowing process is required, and thankfully tho can be just a one-time cheap thing through the ESIP-5 Bulk transfers. While i was working on indexer, there was few people that transferred over 3000 ethscriptions at one go, for just a few dollars, and that was pre-Blobs with medium to high gas fees. Now would probably be just few cents.

The listing process is not "on-chain", the user just makes a listing through a marketplace site, that listing goes in a database and shows it to other marketplace users. When a user wants to buy, it actually calls the market's' contract with specific "listing id", the "ethscription id" which wants to buy, and the price asked by the seller. All that happens under the hood and is not complex to the end user. Nothing bad in all that.

The other side

@tunnckoCore
tunnckoCore / web-native-totp.js
Last active August 23, 2024 20:54
Web Crypto API native TOTP (Time-based One-Time Passwords), in 60 lines
// SPDX-License-Identifier: Apache-2.0
// RFC 4648 base32 alphabet without pad
export const BASE32_ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';
/**
* Generate secret
* @param length optional, length (defaults to `24`)
* @returns secret
*/
@tunnckoCore
tunnckoCore / example_with_create_facet_client.ts
Last active September 14, 2024 15:35
Facet actions / clients for Viem, or standalone
import { english, generateMnemonic, mnemonicToAccount } from "viem/accounts";
import { sepolia } from "viem/chains";
import { createFacetClient } from "./index.ts";
const mnemonic = generateMnemonic(english, 256);
const account = mnemonicToAccount(mnemonic);
const facet = createFacetClient({
account,
chain: sepolia,
@tunnckoCore
tunnckoCore / README.md
Last active March 17, 2024 08:45
Track Ethereum Blob Transactions with Viem

Just import and call trackBlobs(handler).

import { trackBlobs, onlyDataURIBlobs } from './pkg';

await trackBlobs(({ parentBlockSlotHash, block, blobTransactions, blobs }) => {
  const { dataBytes } = onlyDataURIBlobs({ blobs });
 
@tunnckoCore
tunnckoCore / blobs-utils.mjs
Created March 14, 2024 19:57
Ethereum Blobs Utils
import { bytesToString, hexToBytes } from 'viem';
export async function getBlobMeta(hash) {
let result = {};
try {
const res = await fetch(getBlobUrl(hash)).then((x) => x.json());
if (res.error) {
result.error = res.error;
@tunnckoCore
tunnckoCore / mongo-like-filters.ts
Created February 26, 2024 22:20
mongo like filters for javascript objects
function getAttribute(obj: any, key: any) {
const parts = key.split(".");
for (let _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {
const k = parts_1[_i];
if (obj !== null && typeof obj === "object" && k in obj) {
obj = obj[k];
} else {
obj = undefined;
@tunnckoCore
tunnckoCore / EthsBidding.sol
Last active September 1, 2023 22:02
Ethscriptions Bidding solution
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.21;
// Author: wgw.eth / wgw.lol / tunnckoCore
// Date: August 2023
contract EthsBidding {
struct Offer {
bytes32 bidTxHash;
bytes32 ethscriptionId;
@tunnckoCore
tunnckoCore / name-service-resolver.js
Created August 14, 2023 06:32
Ethscriptions hosting & resolving domains (handles/words/ens), not just "user profiles" with `application/vnd.esc.user.profile+json`
import { verifyMessage } from "viem";
/**
* Ethscriptions Hosting & Resolving of ens domains & ethscriptions handles eg. `data,hirsch`
*
* `data:application/vnd.esc.wgw.deploy.`
* -> hex = 646174613a6170706c69636174696f6e2f766e642e6573632e7767772e6465706c6f792e
*
* `+json`
* -> hex = 2b6a736f6e
[
{
"hex": "#f0f8ff",
"name": "aliceblue"
},
{
"hex": "#faebd7",
"name": "antiquewhite"
},
{

New (old) Way of Trading.

I think I solved the problem of safe #Ethscriptions trading.

A multi step process, but safe and sane. Basically, offers-based.


1/ Here's how it could work: