Ports
UTxO RPC

UTxO RPC

This page provides instructions on how to interact with the UTxO RPC service offered by Demeter.

About UTxO RPC Port

UTxO RPC (u5c for short) is an interface tailored for interactions with UTxO-based blockchains, prioritizing performance and developer experience. By providing a common contract, a range of SDKs, and thorough documentation, UtxoRpc aims to facilitate seamless integration across an heterogenous ecosystems of clients and data providers. Utilizing event-driven patterns and the capabilities of Proto3, the interface supports efficient communication, cross-language compatibility, and adaptability between systems.

Enabling Access

To enable access in your project, you need to add a Cardano UTxO RPC Port resource:

  1. Login to Demeter.run (opens in a new tab)
  2. Select your project (opens in a new tab)
  3. From your project's dashboard, click "Add Resource"
  4. Find the resource "Cardano UTxO RPC Port" card and click on the "Deploy" button
  5. Click "Create Resource"
  6. Select the network to connect
  7. Click "Create Resource" once again

Getting Started with UTxO RPC via Demeter

This guide will help you get started with interacting with the UTxO RPC service offered by Demeter using grpcurl. We'll cover everything from installing grpcurl to making your first requests to the UTxO RPC endpoint.

Introduction to Grpcurl

grpcurl is to gRPC what curl is to HTTP. While HTTP APIs are widely understood and commonly used, gRPC is gaining popularity for its efficiency and performance, particularly in microservices communication. However, gRPC's binary protocol can seem less accessible because traditional tools like curl don't work with it. This is where grpcurl comes in—a command-line tool that simplifies interactions with gRPC services, much like curl does for HTTP.

Installing Grpcurl

You can install grpcurl on various operating systems. Detailed installation instructions and binaries are available on its official GitHub repository (opens in a new tab).

Connecting to the UTxO RPC Service

To interact with the UTxO RPC service provided by Demeter, you will need to use grpcurl along with your API key.

Listing Available Services

To list the available services on the UTxO RPC endpoint, run the following command:

grpcurl -H 'dmtr-api-key: <api-key>' -H 'content-type: application/grpc' api.utxorpc.cloud:443 list

This will output a list of services available on the endpoint:

  • grpc.reflection.v1alpha.ServerReflection
  • utxorpc.v1alpha.query.QueryService
  • utxorpc.v1alpha.submit.SubmitService
  • utxorpc.v1alpha.sync.SyncService
  • utxorpc.v1alpha.watch.WatchService

Describing a Service or Method

You can further describe a specific service or method. For example, to describe the FetchBlock method provided by the SyncService, run:

grpcurl \
  -H 'dmtr-api-key: <api-key>' -H 'content-type: application/grpc' \
  api.utxorpc.cloud:443 describe utxorpc.v1alpha.sync.SyncService.FetchBlock

This command will output details about the FetchBlock method, including its request and response structure.

Fetching a Block Using SyncService

Once you understand the request format, you can execute a method. For instance, to fetch a specific block using the SyncService, use the following command with the appropriate parameters:

grpcurl \
  -H 'dmtr-api-key: <api-key>' -H 'content-type: application/grpc' \
  -d '{"ref": [{"index": "68364075", "hash": "hxGMj8HY/u4YSKl2Wk6m8bocd9iQeMeelrh1Db8umuY="}]}'  \
  api.utxorpc.cloud:443 utxorpc.v1alpha.sync.SyncService.FetchBlock

In this example, the index represents the slot of the block, and the hash is the block hash encoded in base64 in Cardano. The response will include details about the block, such as its header, transactions, and other relevant information.

Conclusion

Demeter's UTxO RPC service offers a robust and flexible interface for interacting with Cardano's UTxO-based blockchain. By utilizing UTxORPC on Demeter, developers can seamlessly integrate blockchain functionalities into their applications with minimal effort. The platform's event-driven architecture and efficient communication protocols ensure that you can build scalable and performant solutions.

For those looking for a more programmatic approach, UTxORPC provides a range of SDKs in various programming languages. You can explore the available SDKs and see if your language of choice is supported by visiting the UTxORPC GitHub repository (opens in a new tab).