Cardano Go Live Coding Session #003

published: 2024-03-28

by James


UTxO RPC is a collaborative project from TxPipe and Blink Labs that was funded in Project Catalyst Fund 11. You can read the proposals here:

This week at Cardano Go Live Coding, we took our first look at what these projects will mean for the Cardano developer community. UTxO RPC is about a lot more than Go Development. It provides a common specificiation for how Go, Rust, Python, and JavaScript developers can build applications Cardano. This week's session was a great place for any developer to understand how.

In case you missed it, here's a link to the video on YouTube.

This Week at Cardano Go Live Coding

In our first two sessions, we gave some general structure to how we can work together during these weekly sessions.

This week, our Miro board went from looking like this:


To looking like this:


To start the session, I asked two questions:

  1. For the needs of Andamio, what might we build into Andamio CLI?
  2. For the purposes of learning and experimenting, what can we just play with?

Chris had a great answer to the second question: a lot of what we might want to do maps to emerging, exciting work going on with UTxO RPC.

🎉 Now the fun starts! 🎉

Three ways to "query tip"

To understand why developers are going to love UTxO RPC, let's look at an example together. Suppose that we want to write a Go function that gets the most recent block on a blockchain. There are a few ways to do it.

#1: With an API

A simple approach would be to make a request to a Cardano API provider like Blockfrost, and wrap it in some Go boilerplate:

This is convenient because all we need is an API endpoint, and just like that, we have the data we need! But as you can see, there's a lot of boilerplate for simply handling the JSON response from the API. What if we didn't have to retrieve and parse JSON to get the same result?

#2: With gOuroboros, as shown in Go Live Coding #001

Another way to write a queryTip function is to use lower-level tools like gOuroboros, from Blink Labs. In this example, we can see how gouroboros establishes a direct connection (in this case with a synced Cardano Node at cfg.Address), and gets the current tip of the blockchain.

What's nice about this approach is that we are not translating any data from JSON. The gOuroboros client just provides it in a format that's easy to read. On line 39, we get tip from the client. Then on lines 45 and 46 we print directly from that data.

See the project repo for full code

Still, there's a lot of boilerplate, this time for making the connection to our data source. What if we didn't have to include all of that, or pull in all of the gouroboros library every time we wanted to use it?

#3: With UTxO RPC

Here is what the same function might look like with UTxO RPC. It combines the convenience of using and endpoint like Blockfrost, with the native data types exposed by a native library like gOuroboros.

We simply have to grab the baseUrl (that's our data source) and create a client (just like in example #1). Then, we can run functions directly on that client. What's more, these functions will have the same names is Rust, Python, and JavaScript! Check out these docs: the specifications for each Module are the same for any supported language. This means that across programming languages, developers will be able to use the same logic to build applications.

Check out this example on the UTxO RPC GitHub

The Data's got to come from somewhere...

In the example above, the baseUrl is This is what TxPipe is building to deliver on the gRPC ❤️ Cardano: A streaming API for Cardano using Dolos by TxPipe project. Dolos is "a new type of Cardano node, fine-tuned to solve a very narrow scope: keeping an updated copy of the ledger and replying to queries from trusted clients, while requiring a small fraction of the resources". It creates a way to serve the data we need for UTxO RPC to work.

We'd all like to make sure that this layer is robust! To deliver on the Fund 11 proposal linked above, Blink Labs is building cardano-node-api as another way to provide the data for UTxO RPC.

At Gimbalabs, we are excited to make sure that these services are accessible. The variety of data providers coming online right now, and the variety of ways that these services can be deployed and shared gives us confidence that the Cardano application ecosystem will be build on robust, reliable, and distributed foundations.

What's Next?

  • At Cardano Go Live Coding, we'll continue to dive into the details of how cardano-node-api and UTxO RPC work. We'll also look at examples of how application developers can use them.
  • Just like we can write a queryTip function in a few different ways, we can apply similar patterns to transaction building. In the next live coding sessions, we will start to look at some examples.

About Cardano Go Live Coding

Cardano Go Live Coding meets on Mondays from 1300-1400 UTC.

Follow the project:

  1. Notion page - public dashboard
  2. Andamio CLI on GitHub

Register for Weekly Live Coding Sessions

If you’re just getting started