V1 of Codeonchain provided a way to upload files to the metanet via a command line interface with a Github-like web interface. V2 of Codeonchain is a complete rewrite of the website where all of the functionality of the command line tool has been moved to the web, plus additional features. At this stage the command line tool has not been updated for V2. This article covers the main features of Codeonchain V2 as well as some of the under-the-hood details.

Features

Create new repositories

Upload files

Create folders

Create links to existing files/folders/transactions

Download folder contents as a zip

Storage of master keys in local storage

Add attribution details to every file uploaded

.bsvignore file to ignore files

Getting Started

The home page of Codeonchain shows your repos. To get started you can create a new repo or view existing repos in the featured and recent tabs.

Creating a Repo

The only thing you need to create a repo is to provide a name for the repo. That’s it!

Just enter a repository name to get started.

About the Master Key

Codeonchain uses the metanet protocol which is an innovative way of storing tree-like data on chain, which is ideal for file storage.

A key aspect of the metanet protocol is that all changes to the tree require a key derived from a master key. This prevents anyone else from updating your tree!

For convenience, Codeonchain will store Master Keys in local storage.

The challenge with keys is where to store them. When you create a new repo, a new master key is generated for you. You can copy this and store it somewhere, without it you won’t be able to make any further changes to the tree. For convenience you can store the master key in the browser’s local storage. Local storage is only accessible by the website that created it (in this case codeonchain.network). A limitation is that local storage is browser-specific, your stored master keys won’t be available in any other browser or device. However, you can export the master keys and import them in another browser.

You can export and import master keys between browsers

If you don’t store the master key in local storage it will not be listed in the ‘My Repos’ tab and you will need to enter the master key every time any change is made.

Uploading Files

Drag and drop files or folders to upload

You can drag and drop files directly onto the file list in the browser or select the ‘+ Files’ button. You can upload a folder of files or just files. Uploading is a two step process. Firstly, when you click ‘Add Files’ Codeonchain will estimate how many transactions are required and the fee for each transaction. A Money Button will then be provided to pay for the upload. After you swipe the Money Button the upload of transactions can begin.

Upload limitations

Bitcoin currently has a limit of 25 unconfirmed chained transactions. This means a transaction which depends on the result of a previous transaction up to 25 times. This is a reasonable limit as it would become difficult for Bitcoin nodes to track more than that. Unfortunately this means that if we want to upload more than 25 transactions at a time we will need to wait for the Money Button funding transaction to be confirmed, which could take around 10 minutes.

What is a transaction? Each folder and file will consume a single transaction. Bitcoin SV has a transaction size limit of roughly 100KB, so any files larger than 90KB are split into multiple transactions, with an additional transaction which acts as the index (this is the B://cat format). Therefore a 120KB file will use 3 transactions.

Ignoring Files with .bsvignore

When uploading a folder of files there may be some files you want to ignore. To ignore specific files create a .bsvignore file in the folder with names of files or folders you don’t want to upload. You can verify what will be uploaded in the list of files displayed. Also pay attention to the size of each file as this will directly affect the upload cost. You may want to ignore larger files if they aren’t necessary.

This is the source code for Codeonchain. Large folders such as ‘node_modules’ have been ignored.

The .bsvignore file used to upload the Codeonchain source code.

Attributions and the Sponsor field

Add contributors to receive credit and tips

When creating repos and uploading files there is an ‘Attributions…’ button, this allows you to enter details about people responsible for the content. In addition it allows you to enter payment information which allows viewers of the content to easily tip you.

The sponsor field should be a BSV address or a Pay Mail address. You can enter the amount to tip the contributor and also set the currency of that amount. You can add multiple contributors and when a viewer makes a tip, each contributor will be paid simultaneously.

If the contributors change for different uploads, don’t delete and re-create them, use the checkbox at the top of each contributor which allows you to select whether to include that contributor in this upload.

Links

Links are a powerful feature that allows you to keep links to existing content. This could be used, for example, to keep a list of onchain videos. There is no requirement for you to pay the transaction fees to re-upload the videos, just a small fee to a create a link to the video. You can also add Attribution information to the link to allow for tips to be made for content which wasn’t uploaded with attribution.

To create a link you need a copy of its transaction. You no doubt have seen the long 64-digit hexadecimal numbers beside file names, these are the transaction ids of the files. When you enter a transaction id in the ‘New Link’ window it will automatically retrieve the original and fill in the name for you. This is the name of the original file (if it has one), you can override the name with something different and it will still link to the original file.

Download

You can download the contents of any folder as a zip with the ‘Download’ button. Note that at the moment the download function doesn’t follow links. Instead links create a file with the link name and store the transaction ID which the link refers to in it. That way you can still keep a copy of the links.

Importing and Exporting

Master keys can be imported and exported as JSON files. Import is non-destructive, it merges new items with existing. If there are duplicates it overwrites with the imported one.

Deleting, moving, renaming files

There currently isn’t a way to delete, move, or rename files, folders, links, or repos. In the future, deletion could be provided by replacing the metanet node with an empty node.

Updating a repo

If you want to change the name of a repo or change the attributions the only way is to create a new empty repo. You can replace the existing repo by reusing its Master Key when creating the new repo. This will effectively hide the previous repo. The new repo will be empty and require all files to be uploaded again.

Refunds

If something goes wrong in the upload, and you’ve already swiped the Money Button, it’s possible that the funds may be available to be refunded. You can click the node address (the first line under the name of the folder in the banner) and see if it has any available funds. To send to your Money Button, go to the Money Button website and click ‘Add Money’ and copy and paste the BSV address into the refund field and press the ‘Refund’ button.

Click the link below the folder name to see if any funds are available to be refunded.

Codeonchain in detail

Transaction Format

Codeonchain uses the Bitcom protocol format separated by ‘|’ pipes. Here are the protocols used in Codeonchain transactions:

OP_FALSE OP_RETURN

Metanet protocol — ‘meta’

— ‘meta’ File protocol — some kind of file protocol including B://, B://cat, Directory, or Link

— some kind of file protocol including B://, B://cat, Directory, or Link Data Integrity Protocol — SHA512 hash of file contents, this is only present for B:// and B://cat files

— SHA512 hash of file contents, this is only present for B:// and B://cat files Derivation Path Protocol — A derivation path used to derive the key for the metanet child based on the master key, e.g. ‘m/0/4/2’

— A derivation path used to derive the key for the metanet child based on the master key, e.g. ‘m/0/4/2’ Attribution Protocol list — A list of Attribution protocols, if provided by the user, otherwise does not exist in transaction

list — A list of Attribution protocols, if provided by the user, otherwise does not exist in transaction Repo Protocol — Used by the root node to store metadata about the repo. Note that attribution information is stored using the Attribution Protocol.

Migrating from Codeonchain V1

V2 is a breaking change from V1, so no V1 repos are visible in V2. It is unlikely that there will be such significant breaking changes in the future. The changes involved the introduction of OP_FALSE and the change of the storage format to use the Bitcom operator which should make future updates backwards compatible. Additionally the repo doesn’t use the bsvpush.json file for metadata, instead it uses the Repo and Attribution Protocols.

At this stage there is no ETA on updating the bsvpush command line tool.

Acknowledgements

Codeonchain wouldn’t be possible without the following tools:

_unwriter’s amazing tools. Currently Codeonchain relies heavily on _unwriter’s BOB.

MoneyButton is used to fund all uploads, a brilliant UI and API. The MoneyButton bsv js lib is also used to create the transactions. and keys.

For uploading files, Codeonchain uses BitIndex which provides a very nice JavaScript interface to the blockchain.

For retrieving larger media, particular images, video, and audio, Codeonchain relies on Bico.Media.

Finally thanks to all of the folks on _unwriter’s Atlantastic Slack channel for their invaluable help and support.