Skip to main content

Flow of operations

Intermediate
Tutorial

Overview

This section will give you an overview of how the flow of operations in the construction API works. It will guide you through each of the necessary endpoints that you will have to call in order to post a valid transaction with your signature to the ICP ledger. As an example of such a transaction this guide will use a simple transfer between accounts.

It is recommended to first read through the interactions of each endpoint to acquire an understanding of how the flow of operations works. Although the example of transferring tokens is only one use case of the construction API of Rosetta, it serves as a good example on what to expect from the interaction with the Construction-API. The other functionalities that are supported by ICP Rosetta through the construction API follow a similar flow of operations.

Prerequisites

  • You have a Rosetta instance running at: http://127.0.0.1:8081.

Key generation

For the purpose of this guide, you need to have a private key available with which you can sign messages.

The Rosetta architecture is built so that no private keys are ever sent to Rosetta. All the signing and thus handling of private keys can be done offline.

Rosetta supports multiple types of keys. The two that are used most often are Edwards2559 and Secp256k1. If you want to use Rosetta together with dfx you will be using ECDSA keys with an Secp256k1 curve type. For a guide on how to create a new identity you can look at the relevant dfx section. For this guide we will be using the identity.pem that is created with dfx identity new.

Construction API endpoints

See construction API overview for a high-level overview of the transaction flow. This documentation will provide code snippets for interacting with Rosetta through regular curl commands as well as providing you with a Rosetta-client example implementation in Python. Feel free to use these code snippets as a starting point to write your own Rosetta-client in your language of choice. The endpoints that make up the flow of operations are the following: