RSSAmplifier

Blog

Hiddentao Labs

Independent software consultant helping startups ship faster. 20+ years experience. Smart contracts, full-stack apps, fractional CTO. Based in Singapore.

hiddentao.comRSS feed ↗144 posts

Latest posts

The definitive guide to writing great skill files for AI agents

An agent skill file is an essential document for any web app you choose to deploy today. It tells AI agents how to use and interact with your web app. Without it an AI agent simply isn't going to be able to figure everything out about your product, especially so the more complex your product is. But what makes for a good skill file? Documenting API interfaces is the easy part. What makes a skill…

Bundling your Node.js web app into a single executable using Bun

In my recent project, Chatfall , I successfully bundled an entire Node.js web app into a single executable using Bun . A native executable binary is generated for every supported platform that internally contains all of the following: ElysiaJS backend. ReactJS frontend web app. Drizzle ORM migration scripts. Static assets (images, JS, etc) to be served up by the Node.js web server. Bundling…

Upgradeable NFT and ERC-20 tokens backed by a single smart contract

As a regular user of the Diamond Standard , one architectural pattern I keep having to impelement is that of multiple tokens backed by an upgradeable Diamond. Specifically, my project may have one or more associated ERC-20 and/or NFTs and I'd like the code for these to be upgradeable. Why not just implement ERC 1155 as a Diamond? Well, 1155 can handle multiple ERC-20 tokens and a single NFT…

Next.js custom server with cron jobs

For a turn-based game I'm working on I need to run a cron job at the server-side that processes all the moves placed by all players in order to calculate the results of the current round of play. Since I love using Next.is for my backends this meant getting a custom server up and running. There isn't that much documentation around Custom servers but getting one up and running was fairly…

OBS streaming to Discord with audio

As part of a project I am working on, I had to get OBS studio streaming into a Discord voice channel so that we could broadcast a stream to our community with all the benefits of the built-in Discord chat surrounding it. First of all, is this even possible? Turns out it is, though you have to use OBS Studio differently to how you would if you were streaming to Twitch, Youtube, etc. Note: All the…

Upgrading multiple proxy contracts in Solidity in one call

In a previous post I outlined how the Diamond Standard can be used to facilitate upgradeable smart contracts of virtually infinite size. If one recalls, the structure looks like the following: As I wrote in my previous post: Each implementation contract is called a facet, like the facets of a diamond. In the proxy's fallback function it looks up the facet which implements the incoming function…

Mailmask shutting down

This post was originally published at https://msk.sh/blog/mailmask-shutting-down . I started working on Mailmask about a year ago, just as the global pandemic was kicking off. I had always wanted a service like Mailmask for myself, that let you generate unlimited temporary email addresses on-the-fly so that you could more precisely hide your real email address from spammers. Mailmask was also my…

My first smart contract in Rust on Elrond VM

Elrond - a new Proof-of-Stake blockchain with full state sharding - is soon launching its mainnet . In anticipation of this I decided to get down and dirty with the Elrond SDK and see what it was like building smart contracts in Rust. My blockchain background is primarily Ethereum. I'm a Dapp developer (co-founded Kickback ) and most recently I've written the contracts for Nayms . Thus, as it…

Building your Next.js web app using GraphQL

I generally build my websites in Next.js nowadays. And I almost always use GraphQL as the API surface layer. It was a little tricky to setup initially and so, in this article I will map out all the details in case it's of help to others. File layout Firstly, here is roughly how my Next.js app's folders are laid out with respect to the GraphQL component parts: <Next.js project> /pages…

Upgradeable smart contracts using the Diamond Standard

In a recent post I talked about how we used the Proxy + Eternal Storage pattern to enable upgradeable smart contracts. In this pattern the Solidity fallback function is used in a Proxy contract to delegate all incoming functions to a separate implementation contract: After successfully implementing this pattern we then later on hit the problem of our contract bytecode size exceeding the allowed…

Advanced role-based access control in Solidity

Over at nayms.io we're building an on-chain insurance contracts marketplace which has a complex role hierarchies stipulating who can do what and in what context. For instance, a given insurance policy has an asset manager, client manager and broker. Each of these people themselves belong to entities (companies) and may have varying roles within their entities, e.g. entity admin, manager, entity…

Nested delegate call in Solidity

Are nested delegate calls possible within Solidity? of course. I had a situation whereby I was using the Proxy upgradeability pattern but my implementation had gotten too large to deploy. So I wanted to split it up into sub-implementations, which meant needing to delegate from within a delegate. I couldn't find any examples online so I built my own and tested it out. Here is the code below. I'll…

What is needed for Ethereum to go mass-market

By the term mass market I mean being adopted and used on a wide scale for building apps. I mean having Ethereum Dapps that are used by millions of users. We haven't got this level of usage yet (putting aside for now that the Eth 1.0 network wouldn't be able to handle such a transaction load). I'm interested in figuring out the factors that matter and the path forward towards mass-market usability.…

Upgradeable smart contracts with eternal storage

For the Nayms project we've opted to build upgradeable smart contracts so that we can do permissioned upgrades of our smart contract logic whilst keeping our on-chain data unchanged. In attempting to figure out how to design for upgradeable contracts I looked at the OpenZepellin project's approaches as well as other commentary on the idea:…

Maker OTC on-chain orderbook deep-dive

This post is a deep-dive into MakerDAO's Over-the-counter (OTC) Ethereum smart contract that can be used to facilitate the trading of ERC-20 tokens. The orderbook is on-chain, which means that all offers and trades are conducted fully on the blockchain with no need for an external backend service. This is different to other projects such as 0x , which only perform settlement on-chain (i.e. the…

How to use Serializable Isolation with Postgres transactions

Postgres is my current RDBMS of choice when it comes to building on the server-side. Like most respectable RBMSes, Postgres allows for multiple queries to be executed within a single atomic transaction . Transactions operate in isolation from each other, and one would expect that one transaction cannot operate on data currently being operated on within another concurrent transaction. However this…

Building a multi-lingual static site with Gatsby

NOTE: The gatsby-plugin-intl plugin no longer works with the latest version of Gatsby, so I've disabled it for now. This past week I ported hiddentao.com (the site you're reading this on) from Jekyll + Github pages over to Gatsby + Zeit . This change had been a long-time coming. The major reason for re-doing my site was to add support for multi-lingual posts. I chose Gatsby as the static site…

Architecting microservices for effective development and deployment

Microservice architecture is very popular right now. The last few places I've worked at have all embraced the micoservice philosophy of architecting systems whereby, instead of building one big monolothic service which does everything your backend needs to do, you instead build numerous services which are each responsible for just one aspect of your backend stack. These numerous services would…

React useReducer hook for form handling

I've started porting over a recent React project to use the new Hooks API . Porting a few state values is relatively simple with the useState hook, but when it comes to larger state objects (e.g. for forms) the useReducer hook comes in handy. If you've built with Redux before then useReducer is very straightforward to understand, as it uses the concept of a Dispatcher that handles Actions , just…

Deploying single-page apps on Zeit using Now

This is quick post to illustrate how to deploy single-page static web apps to Zeit using the now cli. Let's assume we are building a React app and that our build scripts have created an optimized production build in the build/ folder of our project. This is the folder we wish to serve on Zeit when requests are made to our domain example.com . Let's assume our build folder looks like the following:…

Using bitmaps for efficient Solidity smart contracts

Smart contracts on Ethereum cost gas to run, and since gas is paid for in Ether, it's generally a good idea to minimize the gas cost of running one's contract. In this sense, writing a smart contract is similar to writing a complex program for a resource-constrained computer - be as efficient as possible, both in terms of memory use and and CPU cycles. One well known technique for optimizing…

Authentication in GraphQL via directives and custom Apollo links

A requirement of our Ethereum Dapp is that we sign the user into our backend prior to allowing them to make an modification to either on-chain (smart contract) or off-chain (cloud db) data. Since we're using GraphQL for our frontend to backend API connection we decided to introduce a directive - @auth - for use with our GraphQL queries and mutations that would indicate when the user needed to…

Mixpanel server-side proxy to bypass blockers

For my new startup - Kickback - we decided to launch a static landing page as a precursor to the full product (which will be ready in a few weeks). On our landing page we have a call-to-action button near the bottom for users who wish to register their interest in our service: Naturally, we wanted to track these clicks and visits through analytics, and we chose Mixpanel . Unfortunately, Brave…

Setup CouchDB and Futon behind a secure Nginx proxy

I recently had to setup a self-hosted CouchDB solution on DigitalOcean with access secured via HTTPS (using Nginx). This post details the steps I took. Install CouchDB and Futon Note: These instructions are based on the DigitalOcean instructions . I ran the following commands on a fresh Ubuntu 16.04 installation as root user. Install basic tools: $ apt-update $ apt install…

Updating a Google spreadsheet via the Javascript API

For some recent client work I needed to record the results of running performance tests in a conveniently accessible place for the rest of the team, i.e. a Google spreadsheet . The tests were being run in CI, meaning that we had to be able to update the spreadsheets from the CI server itself using the programmatic API. Our spreadsheet was private (i.e. only visible within our organisation). But…

React.js cached function binding for efficient props

When building React components it's sometimes easy to end up in a situation whereby you have a list of identical child components which each expect a callback function that behaves slightly different for each child. For example, let's say we have an array of links and we wish to know within our callback which link (i.e. the index number) was clicked. Here is how one may set this up: // Link.js…

Tabbed pages using React Native NavigationExperimental

In a previous post I outlined how to use React Native's NavigationExperimental CardStack with Redux in your app. In this post I will expand on this further to show how you can do in-page "tabbed" navigation for certain pages whilst working within the same Redux structure. First of all, this is what I mean by in-page tabbed navigation: As you can see, the tabbed pages can be navigated to as…

React Native push notification using Batch and Fastlane

Following on my previous post on setting up Continuous Deployment for React Native , this post outlines how to get push notifications working reliably for both Android and iOS using Batch as the intermediary that sits between your server and Google's and Apple's push servers. For the app I'm working on there were a number of requirements: Ability to push a message to devices in batches of 1000's…

Get custom fonts working in React Native

This post outlines how to get custom fonts working reliably in React Native (tested in 0.40). Most crucially, our font files have to be named correctly. I recommend using the following format for file names: OpenSans.ttf - Regular weight OpenSans-Italic.ttf - Regular weight, Italic style OpenSans-Light.ttf - Light weight OpenSans-LightItalic.ttf - Light weight, Italic style OpenSans-SemiBold.ttf -…

Using React Native Navigation CardStack with Redux

Although React Native's NavigationExperimental CardStack is somewhat documented I found myself having to look through the source code and some other parts of the web to fully figure out how to hook everything up with Redux. In this post I will outline the steps I took to get everything working. Here are the packages I'm using: react-native - 0.40.0 react-redux - 5.0.1 redux - 3.6.0 Note: To keep…

Continuous Integration for React Native with TestFlight and TestFairy deployment

I started working on a greenfield React Native project two weeks ago and the first order of business was to get continuous deployment setup so that the rest of the team could easily trigger and receive test builds of the latest code. In this post I will outline the process and configuration I used to get this setup and working. Our Basic requirements: Every time we push changes to our qa Git…

Mocha multiple reporters for CircleCI and Slack

On a recent project I had to get our automated tests running within our CircleCI builds in such a way that test results got reported to Slack . Although CircleCI has built-in support for reporting build failures to Slack one cannot customise the notification content. We wanted test failures to reported in a way which allowed us to quickly see which tests had failed and why. And thus…

React hot-module-reload in Electron desktop apps

In a previous post I outlined how to get React hot-module-reload working in Browserify builds, using the Livereactload plugin. In this one I will outline the additional steps needed to get this whole thing working within an Electron.js desktop app. If you wish to access Electron APIs within you UI window you would normally enable the nodeIntegration flag when creating a BrowserWindow , as such: //…

Redux asynchronous dispatcher pattern

Having worked with React and Redux for a while one problem I keep having to solve is how to asynchronously dispatch actions. For a while I was using redux-thunk to accomplish this, but recently I've developed a new pattern which removes the need for such middleware in the first place. Using thunks (old pattern) First, let's consider the old pattern using thunk-based action creators: //…

React.js Hot-Module-Replacement with Browserify

For my latest project I decided to try and get Hot-Module-Replacement (HMR) working with React.js, but using Browserify. Most React HMR setups use Webpack because that's what the community seems to have standardized around but I prefer Browserify and how it operates, especially since I find it's integration into gulp scripts more intuitive than that of Webpack's. Your mileage may vary. In order to…

Getting geth client mining to work in Travis CI builds

Yesterday I finally got geth-private automated builds working on Travis CI. There were two main problems in getting the builds working: The geth sub-processes launched by during tests weren't always existing even though Node.js was telling me that they were. The tests which relied on mining to happen were always failing. The second problem was occurring due to the fact that in order to mine, Geth…

We need a decentralized, censorship-resistant Twitter-like platform

We need a decentralized, censhorship-resistant Twitter-like platform for open dialogue and impartial crowd-sentiment analysis. Note: I sent this in as an application to Vinay Gupta's Hexayurt Capital . Current social networking platforms such as Twitter are centrally controlled and thus extremely vulnerable to censorship. The platforms' value and wealth is derived from the content created by users…

Trigger a Travis CI build from another project's build

For Waigo I wanted the website to get rebuilt every time the core framework got updated. This is because the actual documentation is stored in the core framework repo, and gets downloaded and transformed into HTML during the documentation website's build process. Travis CI doesn't have any way of setting up inter-project build dependencies so I decided to do this using their API. I mostly followed…

Setting up HTTPS for Github organization pages with custom domains

Thanks to Robin Winslow for the original post . Github Organization pages are awesome, but they do not support HTTPS, presumably because doing so would require Github to serve up your domain-specific SSL certificate for incoming requests - which would be a real pain for them to manage. Robin Winslow has written a great tutorial which explains how get around this limitation by also setting up…

EtherPing - get notified when you receive Ethereum payments

My friend Jeff Lau and I this week finished work on EtherPing , a simple web service which notifies you by email when your Ethereum address receives a payment. EtherPing monitors the global Ethereum network for transactions sent to your specified address and emails you according to the notification rules you have setup. You can get notified as soon as a transaction appears on the network and then…

Thinodium - a light-weight Object Document Mapper for Node.js

I've just released Thinodium , a flexible yet light-weight Object Document Mapper (ODM) for Node.js. In this post I'm going to talk about what it is, why it's useful, and my motivations for building it the way I did. What is an ODM? An ODM is a tool which allows you to interact with database tables as if they're objects (in the OOP sense). The benefit of this approach is that you get to interact…

Setting up geth Ethereum node to run automatically on Ubuntu

For a recent project I'm working on I needed to get geth running as a background service on Ubuntu so that I could connect to it via HTTP-RPC and obtain blockchain information. In this post I will outline the steps I took to make this work on my Digital Ocean droplet. I created a $5 per month droplet (512 MB RAM) and setup 1 GB of swap space on it as follows: $ fallocate -l 1024MB /swapfile $…

geth-private - easily setup private Ethereum blockchains from the command-line and Node

I've recently been getting into Ethereum development. As part of that I want to be able to setup a local, private blockchain whenever needed so that I can easily and quickly test my contracts and dapps prior to deploying them to the live network. I found a great tutorial by Ade Duke which helped me get setup with a private blockchain, but the process was a bit cumbersome, and furthermore I…

Taking the next steps in remote working

I've been thinking lately about the next step. Nearly four years ago I left London to travel in Asia and eventually landed in Taiwan, where I've now been for 3 years. Along the way I've traded in my daily commute to become a remote freelancer. I love working this way. I get to use my skills to help companies and people, no matter where on the globe they might be. On the flip side I am able to…

Client-side encryption for strong security - guidelines

I recently released version 2 of Heartnotes - my secure, encrypted diary app. This was a major rewrite which changed it from being a purely offline app into one which synchronized with a server back-end. The challenge with this was to ensure that a good user experience could be maintained given these changes. Heartnotes' security comes from its implementation of client-side encryption . All data…

Logarama - hierarchical, level-based browser-side logging library

A few days ago I released logarama , a Javscript logging library for browser-side code. Logarama came out of my approach to logging in various React apps I've been building lately. None of the existing logging libraries out there (and boy, there are many) did quite what I wanted so I built my own. Here is how it looks in practice: var Logger = require('logarama'); var appLogger = new Logger('app',…

Heartnotes - offline, encrypted diary using Electron.js + React.js

I am proud to announce the release of Heartnotes , an offline, encrypted personal diary app for desktop, built using Electron and React . Heartnotes has been a labour of love for a couple of months now, in between various other projects, and it's my first desktop app for any platform. What does it do exactly? It allows you to keep a personal diary - one you can write to even when offline. All your…

React.js + Flux server-side rendering with Koa

I recently had to get server-side rendering working on a React.js client project. We had augmented our front-end React app with flummox and react-router and I wanted to be sure that we could re-use these components on the server-side without much extra work. I'm going to document our final file structure and code in this article. ## Front-end Our front-end code is laid out as such: frontend/…

Sending file logs to Loggly in a Docker container

I'm going to outline how I automate the sending of file logs to Loggly inside my Docker containers. This article is a minor follow-on to my previous article on automated deployments , which gives a good overview of my overall deployment process. In this one I will show you how to use the latest Loggly API to send your file logs across. I'm going to assume that you are building your docker…

Why I am asking for a refund from the ind.ie project

Today I asked for a refund from the ind.ie project for the donation I'd made to them last November. For those of you unfamiliar with ind.ie it is a project and team headed by Aral Balkan that has as its goal the promotion and development of independently funded (i.e. non-Venture Capitalist-backed) technology and products that respect and protect your privacy and let you own and control your data…

Hiddentao Labs · RSS Amplifier