rosetta-sdk-go

module
v0.7.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2022 License: Apache-2.0

README

Rosetta

Rosetta SDK

Go SDK to create and interact with Rosetta API implementations

Build once. Integrate your blockchain everywhere.

Overview

The rosetta-sdk-go provides a collection of packages used for interaction with the Rosetta API specification. Much of the code in this repository is generated from the rosetta-specifications repository.

Documentation

You can find the Rosetta API documentation at rosetta-api.org.

Check out the Getting Started section to start diving into Rosetta.

Our documentation is divided into the following sections:

SDK Packages

  • Types: Auto-generated Rosetta types
  • Client: Low-level communication with any Rosetta server
  • Server: Simplified Rosetta API server development
  • Asserter: Validation of Rosetta types
  • Fetcher: Simplified and validated communication with any Rosetta server
  • Parser: Tool for parsing Rosetta blocks
  • Syncer: Sync Rosetta blocks with customizable handling
  • Reconciler: Compare derived balances with node balances
  • Keys: Cryptographic operations for Rosetta-supported curves
  • Constructor: Coordinate the construction and broadcast of transactions

These packages are demoed extensively in examples and are utilized throughout the rosetta-cli tool.

Contributing

You may contribute to the rosetta-sdk-go project in various ways:

Read our Contributing documentation for more information.

When you've finished an implementation for a blockchain, share your work in the ecosystem category of the community site. Platforms looking for implementations for certain blockchains will be monitoring this section of the website for high-quality implementations they can use for integration. Make sure that your implementation meets the expectations of any implementation.

  • rosetta-specifications — The rosetta-specifications repository generates the SDK code in the rosetta-sdk-go repository.
  • rosetta-cli — Use the rosetta-cli tool to test your Rosetta API implementation. The tool also provides the ability to look up block contents and account balances.

Reference Implementations

To help you with examples, we developed complete Rosetta API reference implementations for Bitcoin and Ethereum. Developers of Bitcoin-like or Ethereum-like blockchains may find it easier to fork these reference implementations than to write an implementation from scratch.

You can also find community implementations for a variety of blockchains in the rosetta-ecosystem repository, and in the ecosystem category of our community site.

Using Golang

If you are comfortable with Golang, the easiest way to write a Rosetta Data API implementation is to use this repository. This Golang project provides a server package that empowers a developer to write a full Rosetta Data API server by only implementing an interface. This package automatically validates client requests and calls the functions you implement with pre-parsed requests (instead of in raw JSON).

This is a simple example of how to write an implementation using this package in rosetta-sdk-go.

Using Another Language

If you plan to use a language other than Golang, you will need to either codegen a server (using Swagger Codegen or OpenAPI Generator) or write one from scratch. If you choose to write an implementation in another language, we ask that you create a separate repository in an SDK-like format for all the code you generate so that other developers can use it. You can add your repository to the list in the rosetta-ecosystem repository, and in the ecosystem category of our community site. Use this repository (rosetta-sdk-go) for an example of how to generate code from this specification.

Syncer

The core of any integration is syncing blocks reliably. The syncer serially processes blocks from a Data API implementation (automatically handling re-orgs) with user-defined handling logic and pluggable storage. After a block is processed, store it to a DB or send a push notification...it's up to you!

Parser

When reading the operations in a block, it can be helpful to apply higher-level groupings to related operations, or match operations in a transaction to some set of generic descriptions (e.g., ensure there are two operations of equal but opposite amounts). The parser empowers any integrator to build abstractions on top of the low-level building blocks that the Rosetta API exposes.

SDK Development

While working on improvements to this repository, we recommend that you use these commands to check your code:

  • make deps to install dependencies
  • make gen to generate types and helpers
  • make test to run tests
  • make lint to lint the source code (including generated code)
  • make release to check if code passes all tests run by CircleCI

License

This project is available open source under the terms of the Apache 2.0 License.

© 2022 Coinbase

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL