Uniswap V3 Tick

tags: Uniswap V3 source: Shao, 田少谷. “Uniswap v3 Features Explained in Depth.” Taipei Ethereum Meetup (blog), July 20, 2021. https://medium.com/taipei-ethereum-meetup/uniswap-v3-features-explained-in-depth-178cfe45f223. Tick is a price range Each tick is a price range with upper bound and lower bound. Tick price from index: \(p(i) = 1.0001 ^ i\) 1.0001 ** 138162 # 999_998 Tick index from price: \(log_{1.0001}p\) import math math.log(1000_000, base=1.0001) # 138162.01321981344

August 25, 2022 · 1 min · Gray King

Uniswap V3

tags: Uniswap The Graph: Uniswap V3 Subgraph

August 25, 2022 · 1 min · Gray King

DeFi

tags: Blockchain

August 25, 2022 · 1 min · Gray King

Uniswap

tags: Blockchain,Ethereum,DeFi

August 25, 2022 · 1 min · Gray King

Non-Fungible Tokens vs. Fungible Tokens

tags: Blockchain,Ethereum source: “Graphical Guide to Understanding Uniswap - EthHub.” Accessed August 23, 2022. https://docs.ethhub.io/guides/graphical-guide-for-understanding-uniswap/. ERC20 tokens are the most common type of token built on top of Ethereum. They are fungible in nature, meaning that there isn’t a distinction between individual tokens. For example, if I have 100 metal marbles in my hand that are all the same size and color, it doesn’t matter which one I give you. In the same way, if I have 100 of the same ERC20 token, it doesn’t matter which one I give you. This contrasts with ERC721 tokens which are non-fungible tokens (NFTs) such as cryptokitties. ...

August 23, 2022 · 1 min · Gray King

Your Makefiles are wrong

tags: Makefile source: Davis-Hansson, Jacob. “Your Makefiles Are Wrong.” Jacob Davis-Hansson on Tech, December 15, 2019. https://tech.davis-hansson.com/p/make/. Best Makefile Defaults # Always use bash as the shell. SHELL := bash # Enable bash strict mode. .SHELLFLAGS := -eu -o pipefail -c ## Change some Defaults of Make. # Ensures each Make recipe is ran as one single shell session, # rather than one new shell per line. .ONESHELL: # Delete it's target file if a Make rule fails. .DELETE_ON_ERROR: MAKEFLAGS += --warn-undefined-variables MAKEFLAGS += --no-builtin-rules # Always use GNU Make. ifeq ($(origin .RECIPEPREFIX), undefined) $(error This Make does not support .RECIPEPREFIX. Please use GNU Make 4.0 or later) endif # Use '>' to instead of tab. .RECIPEPREFIX = >

August 22, 2022 · 1 min · Gray King

Podcasts RSS Feed Validator

tags: Online Tools website: https://www.castfeedvalidator.com/

August 17, 2022 · 1 min · Gray King

Solana Account

tags: Solana, Solana 101: 1. Develop Model Account: a Memory region The solana term for a memory region is “account”. Some programs own thousands of independent accounts. Programs own accounts, aka the owner of accounts. Transactions and Accounts You can make a program read and write data by sending transactions. Programs provide endpoints that can be called via transactions (In reality it’s a bit more complex than that but frameworks like Anchor abstract away this complexity). A function signature usually takes the following arguments: ...

August 2, 2022 · 2 min · Gray King

Solana Program

tags: Solana, Solana 101: 1. Develop Model Program Owns Accounts And each memory region has a program that manages it (sometimes called the “owner”). How to Communicate with Solana Programs? Off-chain This means your programs aren’t on-chain program, you can submit transactions with instructions to the network, it could be done via the JSON RPC API or any SDK built on top this API. On-chain TODO

August 2, 2022 · 1 min · Gray King

Rust Opaque Types: Static Dispatch vs. Dynamic Dispatch

tags: Rust source: Johnston, Dylan R. “Formally Verifying Rust’s Opaque Types,” August 1, 2022. https://dylanj.xyz/posts/rust-coq-opaque-types/. Prelude trait ToString { fn to_string(&self) -> String; } Static Dispatch fn yell<S: ToString>(stringable: S) { println!(stringable.to_string().to_uppercase()) } Dynamic Dispatch fn yell(stringable: &dyn ToString) { println!(stringable.to_string().to_uppercase()) } impl Trait fn yell(stringable: impl ToString) { println!(stringable.to_string().to_uppercase()) }

August 2, 2022 · 1 min · Gray King

error: is only available in macOS 10.15 or newer

tags: Flutter,GUI,macOS souce: https://github.com/flutter/flutter/issues/73122 To solve this problem we should specify MACOSX_DEPLOYMENT_TARGET: I would imagine that there is Apple documentation on managing build settings in Xcode, but I don’t have a link offhand. There’s no Flutter-specific documentation of the process, if that’s what you mean; it isn’t any different in a Flutter macOS application as it would be any other macOS application. If you don’t want to use Xcode, you can change MACOSX_DEPLOYMENT_TARGET directly in Runner.xcodeproj/project.pbxproj. ...

July 28, 2022 · 1 min · Gray King

Wecom Debug Mode

macOS Press Command + Shift + Control + D to enter debug mod. Then you can open url in brower: Help -> Debug -> 「浏览器 webview 相关-系统浏览器打开网页」

July 25, 2022 · 1 min · Gray King

Flutter

tags: GUI

July 25, 2022 · 1 min · Gray King

iOS

July 25, 2022 · 0 min · Gray King

Flutter FFI didn't be Invoked in Release Mode

tags: Rust,Flutter,iOS source: “Using Dummy Headers - Flutter_rust_bridge.” Accessed July 25, 2022. http://cjycode.com/flutter_rust_bridge/integrate/ios_headers.html. Recently, I met a problem that the iOS app didn’t work properly in release mode. After a little searching, I found it’s a Flutter app and invoked a Rust function by FFI. The inital call were not invoked during app startup, and it should be. I finally resolved the problem by following: https://github.com/fzyzcjy/flutter_rust_bridge/issues/496 http://cjycode.com/flutter_rust_bridge/integrate/ios_headers.html In short: Xcode will strip the unused symbols in release mode, and won’t realize the FFI invocation; So we need add some dummy invocations to the AppDelegate.swift to make sure it have been used. Next, add this line to ios/Runner/Runner-Bridging-Header.h: ...

July 25, 2022 · 1 min · Gray King

openssl

tags: Tools

July 15, 2022 · 1 min · Gray King

openssl unknown ca

tags: openssl This problem is caused about the ca certs are different between client and server.

July 15, 2022 · 1 min · Gray King

Move Resources Permissions

tags: Move,Starcoin Web3 StarTrek Bedrock – Object-capability model In my words, Move is kind of a Resource-Oriented Programming language. The resource is represented by struct in Move, aka object in other programming language. By the way, the resource in Move is the struct which cannot be copied and cannot be dropped1. Distinct from other programming language, objects are stored in memory, resource in Move can store to the chain’s global storage. ...

July 5, 2022 · 2 min · Gray King

Brevity 500: 500 mini-games to help you learn powerful writing skills

tags: How to Write,Online Tools source: https://brevity500.com/

June 30, 2022 · 1 min · Gray King

GitHub: hackclub/some-assembly-required

tags: Assembly source: https://github.com/hackclub/some-assembly-required What do we mean by an abstraction? Well, an abstraction is a layer above something else that makes that thing easier to do.

June 29, 2022 · 1 min · Gray King

How is a Block Executed

tags: Starcoin Web3 StarTrek,Move When I start learning Move and looking at the stdlib starcoin-framework and starcoin-framework-commons. Then I realized there are must some magic during the block execution in runtime. To roll the world, the runtime should provide some built in types and call some function in the stdlib. How does StarcoinVM Validate Transactions? As a miner, it’s responsible for executing block, it follows: Received some transactions from P2P network: EventHandler of PeerTransactionsMessage. ...

June 24, 2022 · 5 min · Gray King

Starcoin Node Debug

tags: Starcoin Web3 StarTrek Start node with console: $ ./target/debug/starcoin -d ~/.starcoin -n dev console In console type: starcoin% dev log level debug Note: starcoin% is the prompt. Then we can see debug log in ~/.starcoin/dev/starcoin.log.

June 21, 2022 · 1 min · Gray King

Move: A Language With Programmable Resources

tags: Move,Starcoin Web3 StarTrek source: Blackshear, Sam, Evan Cheng, David L Dill, Victor Gao, Ben Maurer, Todd Nowacki, Alistair Pott, et al. “Move: A Language With Programmable Resources,” n.d., 26.

June 18, 2022 · 1 min · Gray King

Move

tags: Starcoin Web3 StarTrek,Blockchain,Smart contracts

June 18, 2022 · 1 min · Gray King

How is an Account Created

tags: Starcoin Web3 StarTrek,Account-Model Blockchain Systems We can create an account by wallet like MetaMask or StarMask, but I’m curious about how an account is created on the blockchain system. As a wallet has been embedded in the starcoin node, we can use it to create an account as follow: $ ./target/debug/starcoin -d ~/.starcoin -n dev account create -p my-pass { "ok": { "address": "0x2f1aeb63bd30d8eb841d6a941c5d6df3", "is_default": false, "is_readonly": false, "public_key": "0x91f79bdd9ced49332bf85b751d02339e05aff047c386d0c14b380d8519d2fb4b", "receipt_identifier": "stc1p9udwkcaaxrvwhpqad22pchtd7vy2276p" } } As above we can see our account has been created, and the address is: 0x2f1aeb63bd30d8eb841d6a941c5d6df3. We’ll find some files are created, if we check our local directory at ~/.starcoin/dev: ...

June 16, 2022 · 4 min · Gray King

Luck Surface Area: How to Get Lucky In Life(a Note of "How to Get Rich")

tags: Career,How To Get Rich (without getting lucky) source: Frontera. “Luck Surface Area: How to Get Lucky In Life,” May 31, 2022. https://fronterablog.com/luck-surface-area/. 5 ways to expand your luck surface area: Do & Tell, don’t miss the “telling” part. Follow your curiosity Talk to new peopli Build a personal brand Take luck as a skill

June 15, 2022 · 1 min · Gray King

Rust libp2p

tags: libp2p,Starcoin Web3 StarTrek source: https://docs.rs/libp2p/0.45.1/libp2p/tutorials/index.html Ping: Four necessary traits Identity: PeerId and corresponding Keypair Transport: send and receive bytes on the network. NetworkBehaviour: decode or encode the bytes from the Transport. Swarm: drives both a Transport and a NetworkBehaviour forward. use futures::StreamExt; use libp2p::ping::{Ping, PingConfig}; use libp2p::{identity, Multiaddr, PeerId, Swarm}; use std::error::Error; #[async_std::main] async fn main() -> Result<(), Box<dyn Error>> { // First we need to create a network identity. let local_key = identity::Keypair::generate_ed25519(); let local_peer_id = PeerId::from(local_key.public()); println!("Local peer id: {:?}", local_peer_id); // Then construct a transport: defines how to send bytes on the network. let transport = libp2p::development_transport(local_key).await?; // NetworkBehaviour defines what bytes to send on the network. let behaviour = Ping::new(PingConfig::new().with_keep_alive(true)); // Swarm connects transport and behaviour together: // // 1. Passing commands from NetworkBehaviour to the Transport. // 2. As well ass events from the Transport to the NetworkBehaviour. let mut swarm = Swarm::new(transport, behaviour, local_peer_id); swarm.listen_on("/ip4/0.0.0.0/tcp/0".parse()?)?; if let Some(addr) = std::env::args().nth(1) { let remote: Multiaddr = addr.parse()?; swarm.dial(remote)?; println!("Dialed {}", addr); } loop { match swarm.select_next_some().await { libp2p::swarm::SwarmEvent::NewListenAddr { listener_id: _, address, } => println!("Listening on {:?}", address), libp2p::swarm::SwarmEvent::Behaviour(event) => println!("{:?}", event), _ => {} } } Ok(()) }

June 15, 2022 · 1 min · Gray King

Distributed Hash Table

tags: P2P,libp2p,Starcoin Web3 StarTrek

June 15, 2022 · 1 min · Gray King

libp2p

tags: P2P,Starcoin Web3 StarTrek,Network source: https://docs.libp2p.io/ A set of protocols for peer identity, discover, routing, transport and more. Peer-to-peer network Peers or nodes communicate with oen another directly, it’s different from the client-server architecture. libp2p Solved Transport abstract data transmission and receipt to adapte many protocols, include the future protocols. Identity use public key cryptography as the basis of peer identity, with this: It gives each peer a globally unique “name”, in the form of a PeerId. PeerId allows anyone to retreve the public key for the identified peer, which enables secure communication between peers. Security libp2p supports “upgrading” a connection provided by a transport into a securely encrypted channel. Currently support; ...

June 15, 2022 · 1 min · Gray King

P2P

tags: Starcoin Web3 StarTrek,Blockchain

June 15, 2022 · 1 min · Gray King

starcoin#3450

tags: Starcoin Web3 StarTrek,starcoin issue solving Today I saw this issue: starcoin#3450 at GitHub, I decide to give it a try. The corresponding type VMStatus is defined out of starcoin’s reposiotry, here. The work need to be done seems are: convert function from u16 to a readable string. convert status_code from StatusCode to a readable string. Let’s take a look at StatusCode first, StatusCode is a enum that contains lot of variants, WOW! My intuition is that can we just get the name of the variant by it’s value. Or I’ll write an ugly match that contains tons of arms. Maybe there already existed some similar code, Let me do a search. ...

June 11, 2022 · 2 min · Gray King

starcoin issue solving

tags: Starcoin Web3 StarTrek

June 11, 2022 · 1 min · Gray King

Addressable Merkle Tree(AMT)

tags: Merkle tree,Blockchain,Starcoin Web3 StarTrek source: Gao, Zhenhuan, Yuxuan Hu, and Qinfan Wu. “Jellyfish Merkle Tree,” n.d., 12. What is Addressable mean? It means the leaf node in the tree can be found by an address. The address encoded the path to the leaf node, for example, a leaf node in a binary tree, which has 3 level. Its address may be encoded to 010, the corresponding path is: left->right->left: 0 1 0 + + + v v v left right left root / \ H1 H2 /\ /\ D1 D2 D3 D4 As we can see, the address 010 leads us to the leaf node D2. ...

June 7, 2022 · 2 min · Gray King

UTXO VS. ACCOUNT MODEL

tags: Starcoin Web3 StarTrek,Account-Model Blockchain Systems source: https://academy.horizen.io/technology/expert/utxo-vs-account-model/

June 7, 2022 · 1 min · Gray King

Account-Model Blockchain Systems

tags: Starcoin Web3 StarTrek,Ethereum,Merkle tree

June 7, 2022 · 1 min · Gray King

Patricia Merkle Tree

tags: Starcoin Web3 StarTrek,Merkle tree,Ethereum Powers the widely known Ethereum network.

June 7, 2022 · 1 min · Gray King

Seal is a verifiable timestamp mechanism for cryptographically proving that a note is created before a specific time.

tags: Let’s Encrypt,Merkle tree source: https://docs.planet.ink/data/seal/ This idea is genius, it use a merkle tree to combine serval notes. And use the root hash of merkel tree to obtain a certificate from Let’s Encrypt.

June 6, 2022 · 1 min · Gray King

Binary Search : Median of two sorted arrays of different sizes.

tags: Binary Search,LeetCodeNJ YouTube: https://www.youtube.com/watch?v=LPFhl65R7ww The most difficult thing is doing binary search among two sorted arrays, in this video Tushar Roy given us a straightforward method of how to do binary search among tow sorted arrays. Assume we have two sorted arrays, X and Y, and cut them between at x2,x3 and y3,y4: If we meet the conditions: x2 <= y3 y2 <= x3 then we find the median postion, as the merged arrays of the four elements may be order by: ...

June 6, 2022 · 1 min · Gray King

LeetCodeNJ

tags: Algorithm,Data Structures Make my best effort to move to Nanjing for my son. This is a successor of LeetCode101.

June 6, 2022 · 1 min · Gray King

Starcoin Blockchain from Scartch

tags: Starcoin Web3 StarTrek,Blockchain Overview Block is the basic element in a blockchain system, as we known blockchain system is just a ledger, which means a bookkeeping1 that recording of financial transactions. In the blockchain system, those transactions are stored in the blocks. In each block, the data stored in may look like: TXN FROM TO VALUE #0 God Cale 100 #1 Cale Alice 10 #2 Alice Bob 1 #3 Bob Mike 0.5 Then what’s a blockchain? Just simply chain the blocks together, usually add a field to point to its parent: ...

June 2, 2022 · 1 min · Gray King

Sparse Merkle Tree

tags: Merkle tree,Starcoin Web3 StarTrek

June 2, 2022 · 1 min · Gray King

Jellyfish Merkle Tree

tags: Starcoin Web3 StarTrek,Sparse Merkle Tree,Merkle tree,LSM-Tree,Account-Model Blockchain Systems source: Gao, Zhenhuan, Yuxuan Hu, and Qinfan Wu. “Jellyfish Merkle Tree,” n.d., 12. JMT(Jellyfish Merkle Tree) a LSM-tree based Implementation of Sparse Merkle Tree Inspired by Patricia Merkle Tree and has been implemented in Rust, but it is language-independent. Merkel tree fits pretty well as an authenticated key-value store holding a huge amount of data in a tamper-proof way. Two major concerns where people have been trying to achieve some enhnacements: ...

June 2, 2022 · 1 min · Gray King

Starcoin PoW

tags: Starcoin Web3 StarTrek, Proof-of-work Generate nonce (random data) as salt to join to the data of block to be hash. The goal is to find a hash value that less than target. The target is influenced by difficulty. As the difficulty gets bigger and the target will be smaller, which means more difficult to find. pub fn difficult_to_target(difficulty: U256) -> U256 { U256::max_value() / difficulty }

June 1, 2022 · 1 min · Gray King

Merkle tree

tags: Starcoin Web3 StarTrek,Blockchain source: Wikipedia: Merkle tree Starcoin Cookbook What is a Merkle tree. Merkle tree is a hash tree, named after Ralph Merkle, who patented in 1979. Most implementations of them are binary, which means two child nodes under each node. Why the merkle tree is important to the peer-to-peer network? The main purpose of a merkle tree is to ensure the data we received from a peer-to-peer network are undamaged and unaltered, it’s important as the data were splitted into many blocks and stored in multiple nodes in the network. ...

June 1, 2022 · 2 min · Gray King

Starcoin Learn Resource

tags: Starcoin Web3 StarTrek The documentation of Starcoin are written in multiple places: The Developers Documentation on the main site English Version Chinese Version The Starcoin Cookbook English Version Chinese Version

June 1, 2022 · 1 min · Gray King

Compile Starcoin from Source And Setup a Dev Node

tags: Starcoin Web3 StarTrek Why compile starcoin from source? Why not download a released binary? Because I want to contribute code to it, maybe in the future. But the toolchain is awesome, the progress is very simple. Just two steps: Clone the code from GitHub git clone git@github.com:starcoinorg/starcoin.git Run scripts/dev_setup.sh: cd starcoin ./scripts/dev_setup.sh Then we are ready to compile: cargo build Wait? You haven’t install Rust yet? Please refer to Getting started. ...

May 31, 2022 · 1 min · Gray King

Starcoin Web3 StarTrek

tags: Web3 Learn journal of Starcoin Web3 StarTrek Program, check the follow “Links to this note”.

May 31, 2022 · 1 min · Gray King

Blogchain

tags: ipfs source: https://blogchain.app/home

May 31, 2022 · 1 min · Gray King

ipfs

source: https://github.com/ipfs/ipfs site: https://ipfs.io/

May 31, 2022 · 1 min · Gray King

IPFS

May 31, 2022 · 0 min · Gray King