Profile Lucas Sta Maria

I'm a third-year Computer Science and Mathematics student at Northeastern University interested in programming languages and developer tooling.

(λx.x x) (λx.x x)

ghcoin

There's an interesting observation to be made that both Git and cryptocurrencies are implemented with distributed Merkle trees (hash trees). This observation inspired me, Vir, and Leo to combine the two together.

This project was built for MLH's Hacking Birthday Bash hackathon. Here are the relevant repositories:

Overall a very fun and interesting project to work on. Unfortunately, it didn't win anything because it didn't adhere to the theme of "Birthday".

Implementation

We have a centralized store of accounts and their balances in ledger.csv. An account is tied to an individual's GitHub username.

To create a transaction, we reduce our own balance, then distribute the amount to other accounts. We commit our changes and create a pull request to the centralized repository (in this case, the main GitHub repository for the project). The pull request is then run against a GitHub Action: our verification script to determine the validity of the transaction.

In particular, three requirements must be satisfied for the pull request to be automatically merged:

  1. The transaction author's balance is lower than their previous balance,
  2. The other accounts in the ledger only have their balance increase or stay the same,
  3. The total sum of the coins in the ledger comes up to the previous amount.

Companion CLI

Manually modifying the ledger is tedious, inconvenient, and not user-friendly. To compensate, I created a CLI with Python that would handle transactions. I utilized modern Python features (namely, type annotations and match statements) and strived to write Pythonic code, even within the time constraints of the hackathon. Structural matching in particular was a joy to work with, especially with how it destructures cases.

Manual:

$ ghcoin

Control your transactions from the command line.

USAGE:
    ghcoin <command> <subcommand>

CORE COMMANDS:
    send <recipient> <amount>  Send the specified recipient the given amount
    balance [user ...]         Retrieve the balance of self or the specified user(s)
    list                       List valid recipients
    register                   Register self onto the ledger
    use-node                   Change the target remote ledger
    help, -h, --help           List this help message

Example usages:

$ ghcoin send priime0 100
$ ghcoin balance priime0 smjleo
$ ghcoin use-node https://github.com/plamorg/ghcoin