4C starting notes
19 Jan 2022
I’ve recently started as a part-time person at the Cambridge Centre for Carbon Credits (4C), where I’ll be working on the implementation side of things. It looks like there’s some fun work to be had here in terms of secure reporting of climate data, but that’s down the line: this is my first day on the job, and I’m mostly just trying to get up to speed on what 4C have been looking at already and what technologies they’re working with (and get accounts set up etc.).
If you want an overview of what 4C is trying to achieve, then this video by Anil is a good place to start:
It’s rare during my contract work that I get to operate in the open, as I’m usually working on commercially sensitive things, so given this opportunity I thought I’d try to keep some notes as I go along, mostly for myself, but also to help show the others on the team what I’ve been up to, and perhaps others will find some bits useful.
In the run up to starting at 4C I had to finally get around to understanding an area of techology I’d been happily ignoring until now: blockchains, and smart contracts. 4C will be using the Tezos system to store carbon data and smart contracts to pay out based on that data, and so even though I’m likely to be working on the data ingress side, I figured it was finally time for me to understand how these things work.
From this prep, I can recommend two documents if you’d like a crash course in this area.
Firstly, if you want a top down overview on how blockchains/smart contracts have thus far been used and their societal impact, then I recommend David Gerard’s book Attack Of The 50 Foot Blockchain (a hat tip to Laura for this and the following recommendation). AotFFBC is quite an easy read, and whilst it lacks technical depth, makes for a good primer on the space if you don’t want to understand the details. It is a bit of an older book, being now five years old, so doesn’t cover things like NFTs for instance, but there’s enough here to get you going, and as I say, it’s a fairly easy read.
From a technical perspective, if you want to know what an actual blockchain is in bits and bytes, then I can recommend Blockchain Demystified by Jean Bacon et al. Unfortunately this is a published academic paper, and I thus wasn’t able to find a link to the document itself at short notice, so I’ll see if I can find one in the near future. But if you can find a copy then it does a good job at providing a simplified overview of what blockchains are trying to achieve in terms of security and privacy, and how the actual data structures and network algorithms work to achieve that.
I also did read both the original Bitcoin whitepaper and Tezos whitepaper. The later for hopefully obvious reasons, and the former because every other document in the space assumes you’ve read it. Confusingly the usual citation URL given for the bitcoin paper doesn’t work, so the version I’ve linked to there is I hope the original, but how can I be certain given it’s not signed?
Regardless, the origin bitcoin paper (assuming that is what I read) is quite an easy read, and in fact doesn’t talk much about detail at all, and doesn’t mention the bitcoin currency that it was the foundation for. It just covers the general algorithms and data structures required for a proof-of-work based crytocurrency without pinning itself to a specific instance of that.
The Tezos whitepaper is sort of the opposite, with the opening page getting straight into the math as it definies itself as a sort of meta-blockchain - in Tezos the rules of the blockchain can be updated over time on the chain itself. One of the important things to Tezos has been auditability of the platform, so this level of detail makes sense, but it was quite a case of whiplash going straight from one paper to the next!
I have to confess that I only skim read the Tezos whitepaper as a result, but did find this overview by B9labs a nice supplement if you want a higher-level crash coarse in the tezos architecture.
Having had my fill of paper reading and admin, I thought I’d try doing some actual proding on Tezos to try and fill in some of the gaps I felt I had in my understanding and to check that what I thought I understood I actually did - in general I learn better with some practical application of knowledge.
The main learnings from this step was that the Tezos developer getting started docs need a bit of love, as they’re a bit out of date with respect to where Tezos is now, and they use terms without explaining them in quite a few places.
I started with the first developer tutorial, entitled Digital Assets on Tezos, but if you try following the instructions there to set up the Tezos command line client it just won’t work, as it refers to servers that no longer exist, and if you try to use their current test servers (which I found here) then the Ubuntu stable client tools don’t like some of the API responses. Instead, I’d recommend just skipping to using your own docker Tezos test node, which is covered under the Sandboxing section. With this I was able to follow the basic steps of setting up my client as one of the pre-made accounts in the Sandbox and executing a minimal contract that simply adds “Hello, world!” to the blockchain.
At this stage, rather than continue with the tutorial, I wanted to look at the blockchain and see if I could find the transaction I’d just created. At first I just used curl to prod my Sandbox server, as Tezos does nicely just use a JSON API over HTTP, which is handy. But I realised there were a lot of transactions on the chain, and prodding it by hand wasn’t going to work, so instead I wrote some Go to let me find my transactions.
This was mildly frustrating for two reasons. Firstly, I could not find clear documentation for the API, despite it being in theory a simple JSON protocol, so I just fell back to using an existing Tezos Go wrapper, tzgo. This worked fine, and has good Golang package documentation, so is a good route to follow if Go is your thing.
Secondly, the tutorials and API use terms that aren’t properly explained. For example: the tutorial wants you to use a “faucet” to get an account without explaining how that works and why it’s called that. The API uses the term “height”, which only occurs in the original white-paper once without proper explanation as to what it means in this context - I infer it’s because the blockchain is actually a tree, and the “height” is the longest branch on that tree, but if you think you’re working on a chain, then it’s a term that isn’t expected. None of this is insurmountable, but it certainly adds to frustration as you try to bootstrap yourself.
Still, after a little trial and error I did manage to find the transactions I’d created on the chain and start to verify the integrity of the chain somewhat, but it did feel an unnecessarily uphill struggle at times.
And that’s it for my first day, or days given the time to write these notes. I’ll try keep these shorter in future, but if along the way there’s anything people want me to expand on please do drop me an email as “michael” at this domain and I’ll see what I can do.