Skip to content

Instantly share code, notes, and snippets.

Avatar

TannrA WilfredTA

View GitHub Profile
@WilfredTA
WilfredTA / udt_proposal.md
Last active Feb 14, 2020
Proposal for User Defined Fungible Token standard on CKB
View udt_proposal.md

UDT Proposal Draft

Introduction

This document puts forth a proposed standard for user defined tokens (UDT) on Nervos Network’s Common Knowledge Base (CKB).

Transactions are the interface in CKB by which users perform operations (produce state changes). Transactions are composed of cells and cells can define type scripts that enforce constraints on any transaction in which the cell is included. Therefore descriptions of CKB operations are descriptions of transaction patterns. These patterns in turn describe specific input, output, and dependency cells, as well as the constraints the input & output cells introduce into a transaction (via their type & lock scripts). The operations and their corresponding transaction patterns are the first two aspects of the standard that this document defines. The third aspect that this draft defines is the UDT extension mechanism. The base standard is simple, defining only the bare minimum constraints for a fungible token. This will allow greater flexibility and oppor

@WilfredTA
WilfredTA / udt_proposal_alt.md
Last active Feb 14, 2020
An alternative design of user defined fungible token on Nervos Network's Common Knowledge Base
View udt_proposal_alt.md

Base Fungible UDT Proposal Draft

Introduction

This document puts forth a proposed standard for Base Fungible user defined tokens (UDT) on Nervos Network’s Common Knowledge Base (CKB).

Relationship Between Properties, Transactions, and Operations

Transactions are the interface in CKB by which users perform operations (produce state changes). Transactions are composed of cells and cells can define type scripts that enforce constraints on any transaction in which the cell is included. Therefore descriptions of CKB operations are descriptions of transaction patterns, which in turn describe specific input, output, and dependency cells, as well as the constraints the input & output cells introduce into a transaction (via their type & lock scripts). The operations and their corresponding transaction patterns are the first two aspects of the standard that this document defines. The third aspect that this draft defines is the UDT extension mechanism through Lock.

@WilfredTA
WilfredTA / ckbinterface.js
Last active Aug 20, 2019
Some generator code extending js sdk - experiences errors
View ckbinterface.js
const fs = require('fs')
const Core = require('@nervosnetwork/ckb-sdk-core').default
class CKBInterface {
constructor(core, nodeUrl, privKey) {
this.core = new Core(nodeUrl)
this.privKey = privKey
@WilfredTA
WilfredTA / wordSearchWithSeenCache.js
Created Feb 26, 2019
Word search with branching logic and the addition of a seen cache and early return
View wordSearchWithSeenCache.js
var exist = function(board, word) {
var seen = [];
var targetCharIdx = 0;
var result = {
found: false
};
var seenCache = {};
for (var i = 0; i < board.length; i++) {
for (var j = 0; j < board[0].length; j++) {
if (result.found) return result.found;
@WilfredTA
WilfredTA / wordSearchImprovement3.js
Created Feb 26, 2019
Move word matching from end-of-path to branching logic
View wordSearchImprovement3.js
var exist = function(board, word) {
var seen = [];
var targetCharIdx = 0;
var result = {
found: false
};
for (var i = 0; i < board.length; i++) {
for (var j = 0; j < board[0].length; j++) {
if (board[i][j] === word[targetCharIdx]) {
@WilfredTA
WilfredTA / wordSearchImprovement2.js
Created Feb 26, 2019
Word search solution with unique cell and adjacent cell branching logic
View wordSearchImprovement2.js
var exist = function(board, word) {
var seen = [];
var targetCharIdx = 0;
var result = {
found: false
};
for (var i = 0; i < board.length; i++) {
for (var j = 0; j < board[0].length; j++) {
if (board[i][j] === word[targetCharIdx]) {
seen.push([i,j]);
@WilfredTA
WilfredTA / naive-with-adjacent-branching.js
Created Feb 26, 2019
Slightly improved approach to word search using adjacent cell branching rather than checking for adjacent property at the end of path
View naive-with-adjacent-branching.js
var exist = function(board, word) {
var seen = [];
var targetCharIdx = 0;
var result = {
found: false
};
for (var i = 0; i < board.length; i++) {
for (var j = 0; j < board[0].length; j++) {
if (board[i][j] === word[targetCharIdx]) {
seen.push([i,j]);
@WilfredTA
WilfredTA / naive-backtrack-word-search.js
Last active Feb 17, 2019
The "dumb" version the backtracking algorithm for the word search problem on LeetCode
View naive-backtrack-word-search.js
var exist = function(board, word) {
var seen = [];
var targetCharIdx = 0;
var result = {
found: false
};
existHelper(board, word, seen, result);
return result.found;
};