Skip to content

Latest commit

 

History

History
376 lines (236 loc) · 12 KB

File metadata and controls

376 lines (236 loc) · 12 KB

Rosetta.ConstructionApi

All URIs are relative to http://localhost

Method HTTP request Description
constructionCombine POST /construction/combine Create Network Transaction from Signatures
constructionDerive POST /construction/derive Derive an Address from a PublicKey
constructionHash POST /construction/hash Get the Hash of a Signed Transaction
constructionMetadata POST /construction/metadata Get Metadata for Transaction Construction
constructionParse POST /construction/parse Parse a Transaction
constructionPayloads POST /construction/payloads Generate an Unsigned Transaction and Signing Payloads
constructionPreprocess POST /construction/preprocess Create a Request to Fetch Metadata
constructionSubmit POST /construction/submit Submit a Signed Transaction

constructionCombine

ConstructionCombineResponse constructionCombine(constructionCombineRequest)

Create Network Transaction from Signatures

Combine creates a network-specific transaction from an unsigned transaction and an array of provided signatures. The signed transaction returned from this method will be sent to the `/construction/submit` endpoint by the caller.

Example

import Rosetta from 'rosetta';

let apiInstance = new Rosetta.ConstructionApi();
let constructionCombineRequest = new Rosetta.ConstructionCombineRequest(); // ConstructionCombineRequest | 
apiInstance.constructionCombine(constructionCombineRequest, (error, data, response) => {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
});

Parameters

Name Type Description Notes
constructionCombineRequest ConstructionCombineRequest

Return type

ConstructionCombineResponse

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

constructionDerive

ConstructionDeriveResponse constructionDerive(constructionDeriveRequest)

Derive an Address from a PublicKey

Derive returns the network-specific address associated with a public key. Blockchains that require an on-chain action to create an account should not implement this method.

Example

import Rosetta from 'rosetta';

let apiInstance = new Rosetta.ConstructionApi();
let constructionDeriveRequest = new Rosetta.ConstructionDeriveRequest(); // ConstructionDeriveRequest | 
apiInstance.constructionDerive(constructionDeriveRequest, (error, data, response) => {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
});

Parameters

Name Type Description Notes
constructionDeriveRequest ConstructionDeriveRequest

Return type

ConstructionDeriveResponse

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

constructionHash

TransactionIdentifierResponse constructionHash(constructionHashRequest)

Get the Hash of a Signed Transaction

TransactionHash returns the network-specific transaction hash for a signed transaction.

Example

import Rosetta from 'rosetta';

let apiInstance = new Rosetta.ConstructionApi();
let constructionHashRequest = new Rosetta.ConstructionHashRequest(); // ConstructionHashRequest | 
apiInstance.constructionHash(constructionHashRequest, (error, data, response) => {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
});

Parameters

Name Type Description Notes
constructionHashRequest ConstructionHashRequest

Return type

TransactionIdentifierResponse

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

constructionMetadata

ConstructionMetadataResponse constructionMetadata(constructionMetadataRequest)

Get Metadata for Transaction Construction

Get any information required to construct a transaction for a specific network. Metadata returned here could be a recent hash to use, an account sequence number, or even arbitrary chain state. The request used when calling this endpoint is often created by calling `/construction/preprocess` in an offline environment. It is important to clarify that this endpoint should not pre-construct any transactions for the client (this should happen in `/construction/payloads`). This endpoint is left purposely unstructured because of the wide scope of metadata that could be required.

Example

import Rosetta from 'rosetta';

let apiInstance = new Rosetta.ConstructionApi();
let constructionMetadataRequest = new Rosetta.ConstructionMetadataRequest(); // ConstructionMetadataRequest | 
apiInstance.constructionMetadata(constructionMetadataRequest, (error, data, response) => {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
});

Parameters

Name Type Description Notes
constructionMetadataRequest ConstructionMetadataRequest

Return type

ConstructionMetadataResponse

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

constructionParse

ConstructionParseResponse constructionParse(constructionParseRequest)

Parse a Transaction

Parse is called on both unsigned and signed transactions to understand the intent of the formulated transaction. This is run as a sanity check before signing (after `/construction/payloads`) and before broadcast (after `/construction/combine`).

Example

import Rosetta from 'rosetta';

let apiInstance = new Rosetta.ConstructionApi();
let constructionParseRequest = new Rosetta.ConstructionParseRequest(); // ConstructionParseRequest | 
apiInstance.constructionParse(constructionParseRequest, (error, data, response) => {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
});

Parameters

Name Type Description Notes
constructionParseRequest ConstructionParseRequest

Return type

ConstructionParseResponse

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

constructionPayloads

ConstructionPayloadsResponse constructionPayloads(constructionPayloadsRequest)

Generate an Unsigned Transaction and Signing Payloads

Payloads is called with an array of operations and the response from `/construction/metadata`. It returns an unsigned transaction blob and a collection of payloads that must be signed by particular addresses using a certain SignatureType. The array of operations provided in transaction construction often times can not specify all "effects" of a transaction (consider invoked transactions in Ethereum). However, they can deterministically specify the "intent" of the transaction, which is sufficient for construction. For this reason, parsing the corresponding transaction in the Data API (when it lands on chain) will contain a superset of whatever operations were provided during construction.

Example

import Rosetta from 'rosetta';

let apiInstance = new Rosetta.ConstructionApi();
let constructionPayloadsRequest = new Rosetta.ConstructionPayloadsRequest(); // ConstructionPayloadsRequest | 
apiInstance.constructionPayloads(constructionPayloadsRequest, (error, data, response) => {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
});

Parameters

Name Type Description Notes
constructionPayloadsRequest ConstructionPayloadsRequest

Return type

ConstructionPayloadsResponse

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

constructionPreprocess

ConstructionPreprocessResponse constructionPreprocess(constructionPreprocessRequest)

Create a Request to Fetch Metadata

Preprocess is called prior to `/construction/payloads` to construct a request for any metadata that is needed for transaction construction given (i.e. account nonce). The request returned from this method will be used by the caller (in a different execution environment) to call the `/construction/metadata` endpoint.

Example

import Rosetta from 'rosetta';

let apiInstance = new Rosetta.ConstructionApi();
let constructionPreprocessRequest = new Rosetta.ConstructionPreprocessRequest(); // ConstructionPreprocessRequest | 
apiInstance.constructionPreprocess(constructionPreprocessRequest, (error, data, response) => {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
});

Parameters

Name Type Description Notes
constructionPreprocessRequest ConstructionPreprocessRequest

Return type

ConstructionPreprocessResponse

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

constructionSubmit

TransactionIdentifierResponse constructionSubmit(constructionSubmitRequest)

Submit a Signed Transaction

Submit a pre-signed transaction to the node. This call should not block on the transaction being included in a block. Rather, it should return immediately with an indication of whether or not the transaction was included in the mempool. The transaction submission response should only return a 200 status if the submitted transaction could be included in the mempool. Otherwise, it should return an error.

Example

import Rosetta from 'rosetta';

let apiInstance = new Rosetta.ConstructionApi();
let constructionSubmitRequest = new Rosetta.ConstructionSubmitRequest(); // ConstructionSubmitRequest | 
apiInstance.constructionSubmit(constructionSubmitRequest, (error, data, response) => {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
});

Parameters

Name Type Description Notes
constructionSubmitRequest ConstructionSubmitRequest

Return type

TransactionIdentifierResponse

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json