Git Product home page Git Product logo

rosetta-geth-sdk's Introduction

Rosetta

Rosetta Generic go-ethereum-based SDK

Build once. Integrate your blockchain everywhere.

Overview

The rosetta-geth-sdk repository provides a collection of packages used for interaction with the Rosetta API specification. The goal of this SDK is to help accelerate Rosetta API implementation on go-ethereum based chains.

Rosetta is an open-source specification and set of tools that makes integrating with blockchains simpler, faster, and more reliable. The Rosetta API is specified in the OpenAPI 3.0 format.

Jump to:

Quick Examples

Complete SDK Example

This ethereum example provides a reference implementation of the Rosetta API for Ethereum in Golang. This example highlights how to load a configuration, load supported operation types and errors, create a new Ethereum client, and start the Rosetta server.

package main

import (
	"log"

	"github.com/coinbase/rosetta-geth-sdk/examples/ethereum/client"
	"github.com/coinbase/rosetta-geth-sdk/examples/ethereum/config"
	sdkTypes "github.com/coinbase/rosetta-geth-sdk/types"
	"github.com/coinbase/rosetta-geth-sdk/utils"
)

func main() {
	// Load configuration using the ENVs in the environment.
	cfg, err := config.LoadConfiguration()
	if err != nil {
		log.Fatalln("%w: unable to load configuration", err)
	}

	// Load all the supported operation types, status
	types := sdkTypes.LoadTypes()
	errors := sdkTypes.Errors

	// Create a new ethereum client by leveraging SDK functionalities
	client, err := client.NewEthereumClient()
	if err != nil {
		log.Fatalln("%w: cannot initialize client", err)
	}

	// Bootstrap to start the Rosetta API server
	err = utils.BootStrap(cfg, types, errors, client)
	if err != nil {
		log.Fatalln("%w: unable to bootstrap Rosetta server", err)
	}
}

The LoadConfiguration file loads all the Blockchain metadata and Rosetta configuration.

The NewEthereumClient file creates a new service client, which leverages SDK functionalities, and implements a few gas related interfaces.

Valid Tokens

See (examples/tokenList.json) for a list of supported ERC20 tokens.

SDK Packages

  • Client: Low-level communication with any go-ethereum based blockchain
  • Services: Rosetta RESTful services for Data and Construction APIs
  • Utils: Bootstrap code for starting up a Rosetta API server
  • Examples: Examples of how to build your Rosetta integration with the SDK

Configuring the SDK

See the Configuration file for more information on how to configure the SDK.

SDK interfaces and method overriding

The SDK defines a list of Client interfaces, which allows the Rosetta service to interact with a go-ethereum based blockchain.

The SDK provides a default implementation of the client module for a quick start. However, these interfaces require custom integration to override:

  1. GetBlockReceipts
  2. GetTransactionReceipt
  3. GetNativeTransferGasLimit

Development

Helpful commands for development:

Install dependencies

make deps

Run tests

make test

Lint the source code

make lint

Check for security concerns

make salus

Generate a coverage report

make coverage-local

Testing

To validate rosetta-geth-sdk, install rosetta-cli and run one of the following commands:

  • rosetta-cli check:data --configuration-file rosetta-cli-conf/testnet/config.json - This command validates that the Data API implementation is correct, using the ethereum testnet node. It also ensures that the implementation does not miss any balance-changing operations.
  • rosetta-cli check:construction --configuration-file rosetta-cli-conf/testnet/config.json - This command validates the Construction API implementation. It also verifies transaction construction, signing, and submissions to the testnet network.
  • rosetta-cli check:data --configuration-file rosetta-cli-conf/mainnet/config.json - This command validates that the Data API implementation is correct, using the ethereum mainnet node. It also ensures that the implementation does not miss any balance-changing operations.

Read the How to Test your Rosetta Implementation documentation for additional details.

Contributing

You may contribute to the rosetta-geth-sdk 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.

You can also find community implementations for a variety of blockchains in the rosetta-ecosystem 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:

Related Projects

  • rosetta-sdk-go — The rosetta-sdk-go SDK provides a collection of packages used for interaction with the Rosetta API specification.
  • rosetta-specifications — Much of the SDK code is generated from this 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.

License

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

© 2022 Coinbase

rosetta-geth-sdk's People

Contributors

shrimalmadhur avatar xiaying-peng avatar dependabot[bot] avatar ash-krishnan avatar jingweicb avatar racbc avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.