[{"data":1,"prerenderedAt":635},["ShallowReactive",2],{"home-blog":3},[4,345,423],{"id":5,"title":6,"body":7,"category":334,"date":335,"description":336,"extension":337,"meta":338,"navigation":339,"path":340,"seo":341,"stem":342,"thumbnail":343,"__hash__":344},"blogs\u002Fblog\u002F2025-02-12-automate-formatting-of-code-with-prettier-and-husky.md","Automate Formatting of Code with Prettier and Husky",{"type":8,"value":9,"toc":328},"minimark",[10,15,19,23,62,66,150,153,172,195,263,266,270,273,276,288,295,298,314,324],[11,12,14],"h2",{"id":13},"standardizing-the-code-format-before-committing-to-github","Standardizing the code format before committing to GitHub",[16,17,18],"p",{},"When working as a team, having a consistent coding structure and format is very important. Imagine a scenario where someone in the team installs a formatter while others don't. This results in commits that appear to have significant changes, but in reality, they only involve minor formatting differences, such as spaces and quote styles. Here comes the automation that I personally use for most of my projects and decided to write it down as a blog so that I could share it with future developers or even my future self.",[11,20,22],{"id":21},"step-1-install-the-dependencies","Step 1: Install the dependencies",[24,25,30],"pre",{"className":26,"code":27,"language":28,"meta":29,"style":29},"language-bash shiki shiki-themes github-dark","npm install -D husky lint-staged eslint prettier\n","bash","",[31,32,33],"code",{"__ignoreMap":29},[34,35,38,42,46,50,53,56,59],"span",{"class":36,"line":37},"line",1,[34,39,41],{"class":40},"svObZ","npm",[34,43,45],{"class":44},"sU2Wk"," install",[34,47,49],{"class":48},"sDLfK"," -D",[34,51,52],{"class":44}," husky",[34,54,55],{"class":44}," lint-staged",[34,57,58],{"class":44}," eslint",[34,60,61],{"class":44}," prettier\n",[11,63,65],{"id":64},"step-2-create-config-for-prettier","Step 2: Create config for Prettier",[24,67,72],{"className":68,"code":69,"filename":70,"language":71,"meta":29,"style":29},"language-json shiki shiki-themes github-dark","{\n  \"singleQuote\": true,\n  \"semi\": true,\n  \"printWidth\": 100,\n  \"trailingComma\": \"all\",\n  \"endOfLine\": \"auto\"\n}\n",".prettierrc.json","json",[31,73,74,80,95,107,120,133,144],{"__ignoreMap":29},[34,75,76],{"class":36,"line":37},[34,77,79],{"class":78},"s95oV","{\n",[34,81,83,86,89,92],{"class":36,"line":82},2,[34,84,85],{"class":48},"  \"singleQuote\"",[34,87,88],{"class":78},": ",[34,90,91],{"class":48},"true",[34,93,94],{"class":78},",\n",[34,96,98,101,103,105],{"class":36,"line":97},3,[34,99,100],{"class":48},"  \"semi\"",[34,102,88],{"class":78},[34,104,91],{"class":48},[34,106,94],{"class":78},[34,108,110,113,115,118],{"class":36,"line":109},4,[34,111,112],{"class":48},"  \"printWidth\"",[34,114,88],{"class":78},[34,116,117],{"class":48},"100",[34,119,94],{"class":78},[34,121,123,126,128,131],{"class":36,"line":122},5,[34,124,125],{"class":48},"  \"trailingComma\"",[34,127,88],{"class":78},[34,129,130],{"class":44},"\"all\"",[34,132,94],{"class":78},[34,134,136,139,141],{"class":36,"line":135},6,[34,137,138],{"class":48},"  \"endOfLine\"",[34,140,88],{"class":78},[34,142,143],{"class":44},"\"auto\"\n",[34,145,147],{"class":36,"line":146},7,[34,148,149],{"class":78},"}\n",[16,151,152],{},"Use the following to format the code:",[24,154,156],{"className":26,"code":155,"language":28,"meta":29,"style":29},"npx prettier --write .\n",[31,157,158],{"__ignoreMap":29},[34,159,160,163,166,169],{"class":36,"line":37},[34,161,162],{"class":40},"npx",[34,164,165],{"class":44}," prettier",[34,167,168],{"class":48}," --write",[34,170,171],{"class":44}," .\n",[16,173,174,175,178,179,182,183,186,187,190,191,194],{},"You may add the following to the ",[31,176,177],{},"scripts"," section of ",[31,180,181],{},"package.json"," so that you can run ",[31,184,185],{},"npm run format"," to format manually all files while ",[31,188,189],{},"npm run lint-staged"," to check prettier on the staged files which is what we want to do in the end of the tutorial. In the example below, I am using ",[31,192,193],{},"*.{js,ts,vue}"," to format all JavaScript, TypeScript, and Vue files. For different project that use different languages, you may want to change the file extension.",[24,196,198],{"className":68,"code":197,"filename":181,"language":71,"meta":29,"style":29},"\"scripts\": {\n  \u002F\u002F Other default scripts\n  \"format\": \"prettier --write .\",\n  \"lint-staged\": \"lint-staged\"\n},\n\"lint-staged\": {\n  \"*.{js,ts,vue}\": \"prettier --write\"\n},\n",[31,199,200,208,214,226,236,241,248,258],{"__ignoreMap":29},[34,201,202,205],{"class":36,"line":37},[34,203,204],{"class":44},"\"scripts\"",[34,206,207],{"class":78},": {\n",[34,209,210],{"class":36,"line":82},[34,211,213],{"class":212},"sAwPA","  \u002F\u002F Other default scripts\n",[34,215,216,219,221,224],{"class":36,"line":97},[34,217,218],{"class":48},"  \"format\"",[34,220,88],{"class":78},[34,222,223],{"class":44},"\"prettier --write .\"",[34,225,94],{"class":78},[34,227,228,231,233],{"class":36,"line":109},[34,229,230],{"class":48},"  \"lint-staged\"",[34,232,88],{"class":78},[34,234,235],{"class":44},"\"lint-staged\"\n",[34,237,238],{"class":36,"line":122},[34,239,240],{"class":78},"},\n",[34,242,243,246],{"class":36,"line":135},[34,244,245],{"class":44},"\"lint-staged\"",[34,247,207],{"class":78},[34,249,250,253,255],{"class":36,"line":146},[34,251,252],{"class":48},"  \"*.{js,ts,vue}\"",[34,254,88],{"class":78},[34,256,257],{"class":44},"\"prettier --write\"\n",[34,259,261],{"class":36,"line":260},8,[34,262,240],{"class":78},[16,264,265],{},"At this step, you would see that you have almost all files with corrections. You may want to commit it and save it.",[11,267,269],{"id":268},"step-3-automate-this-process-every-time-you-have-new-code-to-commit","Step 3: Automate this process every time you have new code to commit",[16,271,272],{},"Pre-commit hooks allow us to run a set of commands before the commit is finalized. We will be setting up the pre-commit hook to run Prettier every time we are about to commit. We will be using Husky to achieve this.",[16,274,275],{},"Initialize Husky:",[24,277,279],{"className":26,"code":278,"language":28,"meta":29,"style":29},"npx husky-init\n",[31,280,281],{"__ignoreMap":29},[34,282,283,285],{"class":36,"line":37},[34,284,162],{"class":40},[34,286,287],{"class":44}," husky-init\n",[16,289,290,291,294],{},"You may delete the ",[31,292,293],{},".husky\u002F_"," folder as it is not being used in this example. We are only using the pre-commit feature.",[16,296,297],{},"Update the file below:",[24,299,302],{"className":26,"code":300,"filename":301,"language":28,"meta":29,"style":29},"npm run lint-staged\n",".husky\u002Fpre-commit",[31,303,304],{"__ignoreMap":29},[34,305,306,308,311],{"class":36,"line":37},[34,307,41],{"class":40},[34,309,310],{"class":44}," run",[34,312,313],{"class":44}," lint-staged\n",[16,315,316,317,320,321,323],{},"Now, whenever we run ",[31,318,319],{},"git commit",", all the defined scripts will run before the commit finalizes. You may now proceed to change the format by tweaking the ",[31,322,70],{}," file.",[325,326,327],"style",{},"html pre.shiki code .svObZ, html code.shiki .svObZ{--shiki-default:#B392F0}html pre.shiki code .sU2Wk, html code.shiki .sU2Wk{--shiki-default:#9ECBFF}html pre.shiki code .sDLfK, html code.shiki .sDLfK{--shiki-default:#79B8FF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html pre.shiki code .s95oV, html code.shiki .s95oV{--shiki-default:#E1E4E8}html pre.shiki code .sAwPA, html code.shiki .sAwPA{--shiki-default:#6A737D}",{"title":29,"searchDepth":82,"depth":82,"links":329},[330,331,332,333],{"id":13,"depth":82,"text":14},{"id":21,"depth":82,"text":22},{"id":64,"depth":82,"text":65},{"id":268,"depth":82,"text":269},"Productivity","2025-02-12","Learn how to automate the formatting of your code using Prettier and Husky. This guide walks you through setting up Prettier for consistent code formatting and using Husky to enforce these standards with pre-commit hooks, ensuring a clean and uniform codebase for your team.","md",{},true,"\u002Fblog\u002F2025-02-12-automate-formatting-of-code-with-prettier-and-husky",{"title":6,"description":336},"blog\u002F2025-02-12-automate-formatting-of-code-with-prettier-and-husky","\u002Fimg\u002Fblog\u002Fautomate-formatting-of-code-with-husky-cover.webp","WJiDkYet2zG_xPFsOICyENw466jeXA3XLBw3qAWJQoY",{"id":346,"title":347,"body":348,"category":415,"date":416,"description":352,"extension":337,"meta":417,"navigation":339,"path":418,"seo":419,"stem":420,"thumbnail":421,"__hash__":422},"blogs\u002Fblog\u002F2019-08-11-endless-potential-of-blockchain-technology.md","Endless Potential of Blockchain Technology",{"type":8,"value":349,"toc":408},[350,353,356,375,379,382,386,389,392,395,398,401,405],[16,351,352],{},"There are various sectors where blockchain technology can be implemented and it is not restricted only to the realm of the financial sector. For instance, retail and e-commerce services, healthcare services, financial services and real estate industries.",[16,354,355],{},"There are a few characteristics of blockchain that are able to benefit the users and will be highlighted in this article.",[357,358,359,363,366,369,372],"ol",{},[360,361,362],"li",{},"Immutability of the data",[360,364,365],{},"Timestamp of the transactions",[360,367,368],{},"Traceability of the transactions",[360,370,371],{},"Transparency of the transactions",[360,373,374],{},"Randomness of the Block Hash",[376,377,362],"h3",{"id":378},"immutability-of-the-data",[16,380,381],{},"Since every transaction is added together and going through a hashing process to create the Merkle Root Hash and the blocks are linked together with the previous block by including the block hash of the previous block in the header of the next block and going through an expensive process of Proof-of-Work. The data could be said as immutable and will always be with the blockchain. Under this assumption, we are able to publish information that needs to be stored in the blockchain forever.",[376,383,385],{"id":384},"timestamp-of-the-transaction","Timestamp of the transaction",[16,387,388],{},"Every transaction needs to be broadcasted before it is added to the blockchain hence the time that the transaction is broadcasted is recorded as part of the header of the transaction that made up the transaction identity (TXID) and the time that the block is found is added to the block header to be sealed to the blockchain, we can safely use the time that the transaction is broadcasted or the time that on the block header as the time that this transaction have happened.",[376,390,368],{"id":391},"traceability-of-the-transactions",[16,393,394],{},"In some situation, we will want to trace the source of the funds. Blockchain provides traceability of the funds on the block explorer. But the developer should not constraint himself or herself to only the source of the coins that are on the Blockchain. Data can be added to Blockchain and that with proper planning the change of data can be traced on the public blockchain.",[376,396,371],{"id":397},"transparency-of-the-transactions",[16,399,400],{},"This characteristic does not apply to blockchain protocol but this is applied to a public blockchain like Trivechain. We are able to see all transactions that are happening and who is involved. For example, how do we show proof that we have transferred the crypto coin to another party? We show the receiving party the transaction on a public blockchain explorer.",[376,402,404],{"id":403},"randomness-of-the-block-hash","Randomness of the block hash",[16,406,407],{},"The block hash that is calculated with Proof-of-Work depends usually on a constraint that the block hash is higher in difficulty than the minimum proof of work limit, usually the block hash generates a certain number of 0 in front of the block hash and the hexadecimal after the leading zeros are random. This is a characteristic that makes it possible to make games that involves randomness. When we play games online, how do we ensure that the users that have rare or legendary weapon are a result of a random occurrence instead of a code that favour the developers? If the occurrence is computed based on the trailing hexadecimal of the block hash. The game will be fairer.",{"title":29,"searchDepth":82,"depth":82,"links":409},[410,411,412,413,414],{"id":378,"depth":97,"text":362},{"id":384,"depth":97,"text":385},{"id":391,"depth":97,"text":368},{"id":397,"depth":97,"text":371},{"id":403,"depth":97,"text":404},"Blockchain","2019-08-11",{},"\u002Fblog\u002F2019-08-11-endless-potential-of-blockchain-technology",{"title":347,"description":352},"blog\u002F2019-08-11-endless-potential-of-blockchain-technology","\u002Fimg\u002Fblog\u002Fendless-potential-of-blockchain-technology-cover.png","ybZIBTe7xoAUbgs9gR_1wqkMverAJznhWoj6nPD6UX0",{"id":424,"title":425,"body":426,"category":415,"date":627,"description":628,"extension":337,"meta":629,"navigation":339,"path":630,"seo":631,"stem":632,"thumbnail":633,"__hash__":634},"blogs\u002Fblog\u002F2019-03-12-triveasset-before-inscriptions.md","TriveAsset — Putting Assets on Bitcoin Before the Inscription Wave",{"type":8,"value":427,"toc":621},[428,434,441,445,448,451,475,480,494,497,501,504,526,529,551,555,558,565,572,601,607,611,618],[16,429,430],{},[431,432,433],"em",{},"An archival field note — documenting work from that era, written up for the record later.",[16,435,436,437,440],{},"We built TriveAsset — TA for short — to encode both fungible and non-fungible assets directly on Bitcoin. No sidechain, no smart-contract state machine. Just a Bitcoin transaction carrying a tiny \"dust\" output for ownership and an ",[31,438,439],{},"OP_RETURN"," payload for the asset's data. It sat squarely in the colored-coins lineage — the same broad instinct the industry would later chase again with \"inscriptions,\" though by a different mechanism. We were early. Early is not the same as polished, and I want to be honest about both halves of that sentence.",[11,442,444],{"id":443},"the-mechanism-plainly","The mechanism, plainly",[16,446,447],{},"Bitcoin doesn't have accounts. It has UTXOs — unspent transaction outputs. Your balance is just the set of outputs you can spend. TriveAsset piggybacks on that.",[16,449,450],{},"To issue an asset, you broadcast a transaction with two things in it:",[452,453,454,466],"ul",{},[360,455,456,457,461,462,465],{},"A tiny ",[458,459,460],"strong",{},"dust output"," — a few hundred satoshis sent to an address. This UTXO ",[431,463,464],{},"is"," the asset. Whoever can spend it, owns the asset. Transfer ownership by spending the dust to a new address.",[360,467,468,469,474],{},"An ",[458,470,471,473],{},[31,472,439],{}," output"," carrying the \"open data\" — the asset's rules and metadata: what it is, how many units, divisible or not, this operation's issue\u002Ftransfer\u002Fburn intent.",[16,476,477,479],{},[31,478,439],{}," is an unspendable, prunable output built for exactly this — attaching a small blob of data to a transaction. On Bitcoin that blob was capped at 80 bytes of payload, which matters a lot later.",[16,481,482,483,486,487,490,491,493],{},"The chain itself has no idea any of this means \"an asset.\" Bitcoin sees a normal transaction moving dust around. The ",[431,484,485],{},"meaning"," lives entirely off-chain: a ",[458,488,489],{},"wallet or indexer"," walks the blockchain, finds transactions tagged as TriveAsset, reads each ",[31,492,439],{},", follows the dust UTXOs as they're spent, and reconstructs who owns what. The blockchain stores the events; the indexer computes the state.",[16,495,496],{},"That's the whole trick. On-chain data, off-chain interpretation.",[11,498,500],{"id":499},"we-did-not-invent-this-and-that-matters","We did not invent this — and that matters",[16,502,503],{},"I want to place this honestly in its lineage, because the honest version is more useful than the flattering one.",[16,505,506,507,510,511,514,515,518,519,522,523,525],{},"Embedding asset meaning into Bitcoin's UTXOs is the ",[458,508,509],{},"colored coins"," family, and it predates us by years. Yoni Assia floated \"colored bitcoin\" in 2012; Meni Rosenfeld's colored-coins writeup landed the same year. Then came the protocol wave: ",[458,512,513],{},"Mastercoin"," (2013, later renamed ",[458,516,517],{},"Omni"," — the rail Tether first launched on in 2014), and ",[458,520,521],{},"Counterparty"," (2014), which was one of the first to use ",[31,524,439],{}," to carry asset data directly. Those projects proved you could run programmable asset infrastructure on top of Bitcoin without touching the base protocol.",[16,527,528],{},"TriveAsset stands on that shoulder. We didn't invent embedding assets on Bitcoin. What we did was build and ship our own take on it — a working tokenization layer for fungible and non-fungible assets — inside Trivechain, at a time when almost nobody in our region had operated this class of system end to end.",[16,530,531,532,535,536,539,540,543,544,546,547,550],{},"The honest, still-interesting claim is the narrow one: ",[458,533,534],{},"we were building asset-on-Bitcoin encoding years before the inscription wave made the idea mainstream."," When Casey Rodarmor shipped Ordinals in January 2023, and ",[31,537,538],{},"@domodata"," posted the BRC-20 schema that March, the mechanism was different — inscriptions write into Taproot ",[458,541,542],{},"witness"," data rather than an 80-byte ",[31,545,439],{}," — but the ",[431,548,549],{},"philosophy"," rhymed with the colored-coins lineage we were already living in: put the asset's data directly onto Bitcoin instead of into a smart-contract state machine, and let indexers reconstruct the rest. BRC-20 ran into a familiar set of tradeoffs — off-chain indexer consensus, fee overhead, no native on-chain state — the same class of problems we'd already hit, even where the specifics differed.",[11,552,554],{"id":553},"the-honest-contrast-it-was-clunkier-than-erc-20","The honest contrast: it was clunkier than ERC-20",[16,556,557],{},"If you've only worked with ERC-20, the UTXO approach feels like fighting the tool. That feeling is correct.",[16,559,560,561,564],{},"ERC-20 is ",[458,562,563],{},"account\u002Fstate-based",". One smart contract holds a clean global balance table — a mapping from address to balance — and the chain enforces it. You query the contract and it just tells you the truth. The state is native.",[16,566,567,568,571],{},"UTXO-embedded assets have ",[458,569,570],{},"no native state",". There is no balance table anywhere on-chain. You reconstruct it by replaying every relevant transaction through an indexer. Which means:",[452,573,574,580,586,595],{},[360,575,576,579],{},[458,577,578],{},"You depend on off-chain indexers."," Two indexers with slightly different rules can disagree about a balance. The chain won't referee — it doesn't know the asset exists.",[360,581,582,585],{},[458,583,584],{},"You fight the dust limit."," Every ownership record is a live UTXO you have to keep funded above dust. Assets bloat the UTXO set, and you're paying attention to satoshi-level accounting just to hold a token.",[360,587,588,594],{},[458,589,590,591,593],{},"You fight ",[31,592,439],{}," size."," 80 bytes is enough for a tag or a hash, not for rich metadata. You encode tightly, or you spill data across transactions, or you point to something off-chain.",[360,596,597,600],{},[458,598,599],{},"You pay fee overhead on everything."," Every mint, transfer, and burn is a full Bitcoin transaction with real miner fees, whether the asset is worth a lot or nothing.",[16,602,603,604,606],{},"None of that is fatal. All of it is friction. Sending an ERC-20 is one contract call; doing the equivalent with dust plus ",[31,605,439],{}," is a small archaeology project every time you want to know the truth. I'm not going to pretend the UX was competitive. It wasn't.",[11,608,610],{"id":609},"what-being-early-actually-taught-me","What being early actually taught me",[16,612,613,614,617],{},"Being early doesn't hand you the market. It hands you the ",[431,615,616],{},"shape of the problem"," before anyone agrees on a name for it. We hit the indexer-consensus problem, the dust-management problem, the metadata-size problem, and the fee-overhead problem years before \"BRC-20\" was a phrase people argued about on Twitter. When the inscription wave arrived and the whole ecosystem started tripping over those same four rocks, none of them were new to us.",[16,619,620],{},"That's the real lesson, and it's not a victory lap. Early only pays if you're still standing when the idea's time arrives. Being early is a form of tuition — you pay it in clunky UX and dead ends, and the return only shows up if you survive to the moment the market catches up. We built asset encoding on Bitcoin before the mainstream cared. That taught me the terrain. Whether the timing ever paid off is a different question, and an honest post keeps those two things apart.",{"title":29,"searchDepth":82,"depth":82,"links":622},[623,624,625,626],{"id":443,"depth":82,"text":444},{"id":499,"depth":82,"text":500},{"id":553,"depth":82,"text":554},{"id":609,"depth":82,"text":610},"2019-03-12","How we encoded fungible and non-fungible assets directly on Bitcoin using a dust UTXO plus OP_RETURN data — the same idea inscriptions later made mainstream, and the same tradeoffs they rediscovered.",{},"\u002Fblog\u002F2019-03-12-triveasset-before-inscriptions",{"title":425,"description":628},"blog\u002F2019-03-12-triveasset-before-inscriptions","\u002Fimg\u002Fblog\u002Ftriveasset-before-inscriptions-cover.svg","aRS4se0xvCpglNGH90PtOzj6w32OPW_9WXPPJvCjvqY",1783650495160]